2016-03-25 3 views
0

私は、JBossサーバーと別のJBossサーバーの下で実行されているEJBステートレスを持っています。クライアント側でcontext.lookup(...)は、ejb3リモートオブジェクトインターフェイスにオブジェクトを返しました

、私は次のコードを使用しています:このコードを実行中

final Properties initialContextProperties = new Properties(); 
initialContextProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); 
initialContextProperties.put(Context.PROVIDER_URL, "remote://127.0.0.1:8083"); 
initialContextProperties.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); 
initialContextProperties.put("jboss.naming.client.ejb.context", true); 

final InitialContext contexte = new InitialContext(initialContextProperties); 
Object remoteObj = contexte.lookup("ejb:my-web-app/MyEjbRemoteImpl!my.ejb.remote.MyEjbRemoteInterface"); 
MyEjbRemoteInterface myEjb = (my.ejb.remote.MyEjbRemoteInterface) remoteObj; 

を、私はこの例外を持っている:

org.jboss.ejb.client.naming.ejb.EjbNamingContext cannot be cast to my.ejb.remote.MyEjbRemoteInterface 

は、これらの依存関係は、クライアント側のクラスパスにあります:

<dependency> 
    <groupId>org.jboss</groupId> 
    <artifactId>jboss-remote-naming</artifactId> 
    <version>2.0.4.Final</version> 
</dependency> 
<dependency> 
    <groupId>org.jboss.xnio</groupId> 
    <artifactId>xnio-nio</artifactId> 
    <version>3.3.6.Final</version> 
</dependency> 

ご存知ですか?

問題は、ルックアップメソッドの文字列パラメータにあったあなたの助けをありがとう

+0

<dependency> <groupId>org.jboss.as</groupId> <artifactId>jboss-as-ejb-client-bom</artifactId> <version>7.2.0.Final</version> <type>pom</type> </dependency> 
セクション[リモートアクセスJNDIオブジェクトの前提条件]で述べたように(https://docs.jboss.org/author/display/AS72/ JBossのドキュメンテーションの* Remote + EJB + invocations + + JNDI + - + EJB + client + API +または+ remote-naming + project)*リモートネーミングプロジェクトを使用しているときに使用されるJNDI名は常に** java: jboss/exported/**名前空間*。したがって、検索文字列から 'ejb:'を削除する必要があります。 – aribeiro

答えて

0

。それはのようにする必要がありますejb:/my-web-app//MyEjbRemoteImpl!my.ejb.remote.MyEjbRemoteInterface。一般ejb:AppName/EjbModuleName/DistinctName/EjbRemoteBeanImpName!ejb.remote.interface.Name

必要なすべての依存関係を好む:

関連する問題