从 Websphere 部署在 JBoss 上的远程查找 EJB
Remote lookup EJB deployed on JBoss from Websphere
我已经在 JBoss 上部署了 EJB,我想从 Websphere 上查找它。我使用 maven 来管理我的项目。这是我用来查找 EJB
的代码
Properties props = new Properties();
props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
props.put(Context.PROVIDER_URL, "remote://192.168.0.11:4447");
props.put(Context.SECURITY_PRINCIPAL, "user");
props.put(Context.SECURITY_CREDENTIALS, "pass");
props.put("jboss.naming.client.ejb.context", true);
InitialContext ctx = new InitialContext(props);
return (IEjbInterface) ctx.lookup("my-ear/my-app/MyClass!my.class.interfaces.IEjbInterface");
我为查找添加了以下依赖项
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-ejb-client-bom</artifactId>
<type>pom</type>
<version>7.1.1.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-jms-client-bom</artifactId>
<type>pom</type>
<version>7.1.1.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-naming</artifactId>
<version>7.1.1.Final</version>
</dependency>
此代码在独立应用程序中运行,但当包装在部署在 Websphere 上的 WAR 中时,查找会抛出以下异常
java.lang.ClassNotFoundException: org.xnio.BrokenPipeException
从 ClassNotFoundException 我认为你需要创建对 org.jboss.xnio 模块的依赖。有关更多信息,请参阅:https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7?_sscc=t
bom jboss-as-ejb-client-bom 7.1.1.Final 包含 org.jboss.xnio 库,但它是版本 3.0.3.GA。 7.2.0.Final bom 引用了较新版本的 xnio (3.0.7.GA),它可以正常工作。
我已经在 JBoss 上部署了 EJB,我想从 Websphere 上查找它。我使用 maven 来管理我的项目。这是我用来查找 EJB
的代码Properties props = new Properties();
props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
props.put(Context.PROVIDER_URL, "remote://192.168.0.11:4447");
props.put(Context.SECURITY_PRINCIPAL, "user");
props.put(Context.SECURITY_CREDENTIALS, "pass");
props.put("jboss.naming.client.ejb.context", true);
InitialContext ctx = new InitialContext(props);
return (IEjbInterface) ctx.lookup("my-ear/my-app/MyClass!my.class.interfaces.IEjbInterface");
我为查找添加了以下依赖项
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-ejb-client-bom</artifactId>
<type>pom</type>
<version>7.1.1.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-jms-client-bom</artifactId>
<type>pom</type>
<version>7.1.1.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-naming</artifactId>
<version>7.1.1.Final</version>
</dependency>
此代码在独立应用程序中运行,但当包装在部署在 Websphere 上的 WAR 中时,查找会抛出以下异常
java.lang.ClassNotFoundException: org.xnio.BrokenPipeException
从 ClassNotFoundException 我认为你需要创建对 org.jboss.xnio 模块的依赖。有关更多信息,请参阅:https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7?_sscc=t
bom jboss-as-ejb-client-bom 7.1.1.Final 包含 org.jboss.xnio 库,但它是版本 3.0.3.GA。 7.2.0.Final bom 引用了较新版本的 xnio (3.0.7.GA),它可以正常工作。