JBoss Wildfly 10:在JBoss 7

时间:2017-01-03 08:44:57

标签: java jboss wildfly jndi rmi

我试图通过JNDI从Wildfly 10远程调用JBoss 7上的EJB3.1应用程序。

从独立的Java客户端执行代码工作得很好,部署在Wildfly中,我收到一个ClassCastException:

java.lang.ClassCastException: org.xnio.SingleOption cannot be cast to org.xnio.Option

以下是我使用的属性:

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=true
remote.connectionprovider.create.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connections=default
remote.connection.default.host=some.server
remote.connection.default.port=4647
remote.connection.default.connect.options.org.xnio.Options.SSL_ENABLED=true
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.clusters=ejbremote.cluster.ejb.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.cluster.ejb.connect.options.org.xnio.Options.SSL_ENABLED=true
remote.connection.default.username=user
remote.connection.default.password=password
org.jboss.ejb.client.scoped.context=true
java.naming.factory.url.pkgs=org.jboss.ejb.client.naming

Project有jboss-as-ejb-client-bom依赖项:

<dependency>
    <groupId>org.jboss.as</groupId>
    <artifactId>jboss-as-ejb-client-bom</artifactId>
    <version>7.2.0.Final</version>
    <type>pom</type>
</dependency>

Lookup看起来很标准:

Context ctx = new InitialContext(properties);
Service service = (Service) ctx.lookup(Service.JNDI_PATH);

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

检查您如何打包应用程序,我想您在已部署的存档中包含org.xnio库。 在这种情况下,它将由导致此错误的不同类加载器加载。

答案 1 :(得分:0)

将包含以下内容的jboss-deployment-structure.xml添加到WAR的顶层:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
  <deployment>
    <dependencies>
      <module name="org.jboss.xnio"></module>
    </dependencies>
  </deployment>
</jboss-deployment-structure>