java - 使用 Java 9 运行应用程序,模块 java.base 不是 "opens java.io"

标签 java ejb wildfly java-9

我尝试使用 Java 9 运行我的应用程序(前端使用 Java Swing 开发,服务器使用部署在 Wildfly 8 上的 EJB 开发)。 当客户端尝试建立 EJB 连接时出现以下异常:

    09:53:42,358 INFO  [xnio] XNIO version 3.2.0.Final
09:53:42,465 INFO  [nio] XNIO NIO Implementation Version 3.2.0.Final
09:53:42,507 DEBUG [nio] Started channel thread 'Remoting "config-based-naming-client-endpoint" I/O-1', selector sun.nio.ch.WindowsSelectorImpl@4b4a5caf
RmiServiceFactpry ExceptionInInitializerError
java.lang.ExceptionInInitializerError
    at org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver.<init>(RemotingConnectionEJBReceiver.java:148)
    at org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver.<init>(RemotingConnectionEJBReceiver.java:106)
    at org.jboss.ejb.client.EJBClientContext.registerConnection(EJBClientContext.java:465)
    at org.jboss.naming.remote.client.ejb.RemoteNamingStoreEJBClientHandler.associate(RemoteNamingStoreEJBClientHandler.java:78)
    at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.<init>(RemoteNamingStoreV1.java:71)
    at org.jboss.naming.remote.protocol.v1.VersionOne.getRemoteNamingStore(VersionOne.java:50)
    at org.jboss.naming.remote.protocol.Versions.getRemoteNamingStore(Versions.java:55)
    at org.jboss.naming.remote.client.RemoteContextFactory.createVersionedStore(RemoteContextFactory.java:73)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:202)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)
    at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)
    at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)
    at java.naming/javax.naming.InitialContext.lookup(Unknown Source)
    at com.dataloy.client.core.RmiServiceFactory.createRemote(RmiServiceFactory.java:105)
    at com.dataloy.client.core.RmiServiceFactory.getServiceImpl(RmiServiceFactory.java:96)
    at com.dataloy.core.AbstractServiceFactory.getService(AbstractServiceFactory.java:58)
    at com.dataloy.DataloyEngine.getService(DataloyEngine.java:198)
    at com.dataloy.DataloyEngine.login(DataloyEngine.java:548)
    at com.dataloy.client.login.LoginPanel.doLogin(LoginPanel.java:511)
    at com.dataloy.client.login.LoginPanel.access$500(LoginPanel.java:56)
    at com.dataloy.client.login.LoginPanel$5.run(LoginPanel.java:452)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make java.io.OptionalDataException(boolean) accessible: module java.base does not "opens java.io" to unnamed module @312002a1
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source)
    at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Unknown Source)
    at java.base/java.lang.reflect.Constructor.setAccessible(Unknown Source)
    at org.jboss.marshalling.Marshalling$OptionalDataExceptionCreateAction$1.run(Marshalling.java:385)
    at org.jboss.marshalling.Marshalling$OptionalDataExceptionCreateAction$1.run(Marshalling.java:381)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at org.jboss.marshalling.Marshalling$OptionalDataExceptionCreateAction.<init>(Marshalling.java:381)
    at org.jboss.marshalling.Marshalling$OptionalDataExceptionCreateAction.<init>(Marshalling.java:376)
    at org.jboss.marshalling.Marshalling.<clinit>(Marshalling.java:374)
    ... 23 more

我发现 Java 9 中引入的新模块管理存在一些问题,但我不明白应该怎么做。

问候, 安德里亚

最佳答案

根据 this answer您需要将 --add-opens java.base/java.io=ALL-UNNAMED 添加到启动应用程序的 java 命令中。

关于java - 使用 Java 9 运行应用程序,模块 java.base 不是 "opens java.io",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42667837/

相关文章:

java - 格式化字符串到日期转换而不更改java中的格式

ejb - CDI WELD @ConversationScoped @Stateful EJB talk.end() & @Remove SFSB

java - Docker 容器化单体应用程序

java - 如何将图标添加到抽屉导航中

multithreading - EntityManager 线程安全和 Java EE

自动化任务的 Java EE 身份验证/授权

java - 如何在 Wildfly 8.2 Final 中将 lib 添加到模块中?

Java EE、Hibernate、MySql UTF-8 查询不起作用

java - 如何以编程方式添加 EJB 拦截器?

java - 内部带有微调器的 ListView : 1st Item of the listview affects its last item