从Websphere部署在JBoss上的远程查找EJB

时间:2015-07-20 14:12:31

标签: jboss websphere lookup

我已经在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

2 个答案:

答案 0 :(得分:0)

从ClassNotFoundException我认为你需要在org.jboss.xnio模块上创建一个依赖项。有关详细信息,请参阅:https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7?_sscc=t

答案 1 :(得分:0)

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)的新版本,它可以正常使用。