英文:
ClassNotFoundException jdk.net.* in Wildfly
问题
我的应用程序在升级到最新的MongoDB驱动程序后,在启动时出现了问题。我正在使用Wildfly 19、JDK14,并确认在编译时jdk.net.*可用。显然它们要么没有进入运行时环境,要么存在安全问题。我猜测模块被阻止了,但我一直没有找到如何访问它的方法。
日志输出:
13:28:07,673 INFO [org.mongodb.driver.cluster] (cluster-ClusterId{value='5f304e47acf25e32b55f0c16', description='null'}-srv-cluster0-hpilc.azure.mongodb.net) 将发现的服务器 cluster0-shard-00-00-hpilc.azure.mongodb.net:27017 添加到集群的客户端视图
13:28:07,675 INFO [org.mongodb.driver.cluster] (cluster-ClusterId{value='5f304e47acf25e32b55f0c16', description='null'}-srv-cluster0-hpilc.azure.mongodb.net) 将发现的服务器 cluster0-shard-00-01-hpilc.azure.mongodb.net:27017 添加到集群的客户端视图
13:28:07,783 INFO [org.mongodb.driver.cluster] (cluster-ClusterId{value='5f304e47acf25e32b55f0c16', description='null'}-cluster0-shard-00-02-hpilc.azure.mongodb.net:27017) 在连接到服务器 cluster0-shard-00-02-hpilc.azure.mongodb.net:27017 时监视线程中发生异常: com.mongodb.MongoException: java.lang.NoClassDefFoundError: jdk/net/ExtendedSocketOptions
at deployment.goa.war//com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:157)
at deployment.goa.war//com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.lookupServerDescription(DefaultServerMonitor.java:188)
at deployment.goa.war//com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:144)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.NoClassDefFoundError: jdk/net/ExtendedSocketOptions
at deployment.goa.war//com.mongodb.internal.connection.SocketStreamHelper.setExtendedSocketOptions(SocketStreamHelper.java:83)
at deployment.goa.war//com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:53)
at deployment.goa.war//com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:79)
at deployment.goa.war//com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65)
at deployment.goa.war//com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:143)
... 3 more
Caused by: java.lang.ClassNotFoundException: jdk.net.ExtendedSocketOptions from [Module "deployment.goa.war" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
... 8 more```
<details>
<summary>英文:</summary>
My app just started blowing up on startup after upgrading to latest MongoDB drivers. Using Wildfly 19, JDK14, and I've confirmed that at compile time jdk.net.* are available. Clearly they're either not making it into the runtime environment or there is a security issue. My guess is that the module is being blocked, but I've not been able to figure out how to get access to it.
Log output:
```13:28:07,652 INFO [org.mongodb.driver.cluster] (cluster-ClusterId{value='5f304e47acf25e32b55f0c16', description='null'}-srv-cluster0-hpilc.azure.mongodb.net) Adding discovered server cluster0-shard-00-02-hpilc.azure.mongodb.net:27017 to client view of cluster
13:28:07,673 INFO [org.mongodb.driver.cluster] (cluster-ClusterId{value='5f304e47acf25e32b55f0c16', description='null'}-srv-cluster0-hpilc.azure.mongodb.net) Adding discovered server cluster0-shard-00-00-hpilc.azure.mongodb.net:27017 to client view of cluster
13:28:07,675 INFO [org.mongodb.driver.cluster] (cluster-ClusterId{value='5f304e47acf25e32b55f0c16', description='null'}-srv-cluster0-hpilc.azure.mongodb.net) Adding discovered server cluster0-shard-00-01-hpilc.azure.mongodb.net:27017 to client view of cluster
13:28:07,783 INFO [org.mongodb.driver.cluster] (cluster-ClusterId{value='5f304e47acf25e32b55f0c16', description='null'}-cluster0-shard-00-02-hpilc.azure.mongodb.net:27017) Exception in monitor thread while connecting to server cluster0-shard-00-02-hpilc.azure.mongodb.net:27017: com.mongodb.MongoException: java.lang.NoClassDefFoundError: jdk/net/ExtendedSocketOptions
at deployment.goa.war//com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:157)
at deployment.goa.war//com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.lookupServerDescription(DefaultServerMonitor.java:188)
at deployment.goa.war//com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:144)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.NoClassDefFoundError: jdk/net/ExtendedSocketOptions
at deployment.goa.war//com.mongodb.internal.connection.SocketStreamHelper.setExtendedSocketOptions(SocketStreamHelper.java:83)
at deployment.goa.war//com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:53)
at deployment.goa.war//com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:79)
at deployment.goa.war//com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65)
at deployment.goa.war//com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:143)
... 3 more
Caused by: java.lang.ClassNotFoundException: jdk.net.ExtendedSocketOptions from [Module "deployment.goa.war" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
... 8 more```
</details>
# 答案1
**得分**: 2
使用Wildfly 10.1,JDK 8。将以下代码块添加到文件 `jboss-deployment-structure.xml` 中的 `dependencies` 部分解决了该问题。
``` lang-xml
<system export="true">
<paths>
<path name="jdk/net"/>
</paths>
</system>
英文:
Using Wildfly 10.1, JDK 8. Adding the following block to the file jboss-deployment-structure.xml
inside the dependencies
section solved the problem.
<system export="true">
<paths>
<path name="jdk/net"/>
</paths>
</system>
答案2
得分: 1
在Wildfly的standalone.xml文件中添加以下内容:
<global-modules>
<module name="jdk.net" slot="main" />
</global-modules>
放在<subsystem xmlns="urn:jboss:domain:ee:5.0">
块内。
英文:
Figured it out. In the Wildfly standalone.xml file add
<global-modules>
<module name="jdk.net" slot="main" />
</global-modules>
inside of the <subsystem xmlns="urn:jboss:domain:ee:5.0"> block
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论