ClassNotFoundException jdk.net.* in Wildfly

huangapple go评论87阅读模式
英文:

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&#39;ve confirmed that at compile time jdk.net.* are available.  Clearly they&#39;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&#39;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=&#39;5f304e47acf25e32b55f0c16&#39;, description=&#39;null&#39;}-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=&#39;5f304e47acf25e32b55f0c16&#39;, description=&#39;null&#39;}-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=&#39;5f304e47acf25e32b55f0c16&#39;, description=&#39;null&#39;}-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=&#39;5f304e47acf25e32b55f0c16&#39;, description=&#39;null&#39;}-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 &quot;deployment.goa.war&quot; 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
&lt;system export=&quot;true&quot;&gt;
   &lt;paths&gt;
      &lt;path name=&quot;jdk/net&quot;/&gt;
   &lt;/paths&gt;
&lt;/system&gt;
英文:

Using Wildfly 10.1, JDK 8. Adding the following block to the file jboss-deployment-structure.xml inside the dependencies section solved the problem.

&lt;system export=&quot;true&quot;&gt;
   &lt;paths&gt;
      &lt;path name=&quot;jdk/net&quot;/&gt;
   &lt;/paths&gt;
&lt;/system&gt;

答案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

&lt;global-modules&gt;
&lt;module name=&quot;jdk.net&quot; slot=&quot;main&quot; /&gt;            
&lt;/global-modules&gt;

inside of the <subsystem xmlns="urn:jboss:domain:ee:5.0"> block

huangapple
  • 本文由 发表于 2020年8月10日 03:51:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/63330702.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定