2013-01-15 14 views
6

JBoss 7.1.1の下で実行されるステートレスEJBへのリモートアクセスをかなりの期間行った後。オブジェクトプロパティを使用して:JBoss 7:JNDI参照

Properties jndiProps = new Properties(); 
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, 
    "org.jboss.naming.remote.client.InitialContextFactory"); 
jndiProps.put(Context.PROVIDER_URL,"remote://localhost:4447"); 
jndiProps.put(Context.SECURITY_PRINCIPAL, "remote"); 
jndiProps.put(Context.SECURITY_CREDENTIALS, "remotepwd"); 
jndiProps.put("jboss.naming.client.ejb.context", true); 
Context ctx = new InitialContext(jndiProps); 

String lookupString = "//HelloWorld/HelloWorldBean!org.acme.test.HelloWorld"; 
HelloWorld hw = (HelloWorld) ctx.lookup(lookupString); 
System.out.println("Response: "+ hw.sayHello("Hi there")); 

のでこれは罰金に動作しますが、今、私はjndi.propertiesファイルにJNDIのものを入れたいが、失敗しました、これは、ファイルがどのように見えるかです:

java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory 
java.naming.factory.url.pkgs=org.jboss.ejb.client.naming 
java.naming.provider.url=remote://localhost:4447 
java.naming.security.principal=remote 
java.naming.security.credentials=remotepwd 

例外:

Exception in thread "main" java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:HelloWorld,distinctname:] combination for invocation context [email protected] 
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584) 
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119) 
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) 
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) 
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) 
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) 
at $Proxy0.sayHello(Unknown Source) 
at de.brockhaus.test.client.TestClient.main(TestClient.java:35) 

私はすでに複数のdocoを通過しましたが、失敗しました。どのようにしてそのように見えるのですか?

答えて

7

OK、私は答え自分自身を見つけた...

まず、プロパティファイル、jndi.propertiesプラスjboss-ejb-client.propertiesを持っている必要があります。

jndi.properties:でもプロパティを指定せずに魅力のようなコードの実行を行いますクラスパス上にそれらの両方を有する

# 
# jboss-ejb-client.properties 
# 
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false 
remote.connections=default 
remote.connection.default.host=localhost 
remote.connection.default.port = 4447 
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 

# 
# jndi.properties 
# 
java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory 
java.naming.factory.url.pkgs=org.jboss.ejb.client.naming 
java.naming.provider.url=remote://localhost:4447 
java.naming.security.principal=remote 
java.naming.security.credentials=remotepwd 

jboss-ejb-client.propertiesコード内。それでも

混乱は

+0

検索文字列の構築のために、あなたはここで参照することがあります...検索文字列の構築です:https://docs.jboss.org/author/display/AS72/Remote+EJB+ + JNDI + - + EJB +クライアント+ API +または+リモートネーミング+プロジェクトを介した呼び出し。 jbossサーバの起動時に、リモートリンクの場合、通常、 "java:jboss/exported /"の直後に検索文字列があります。 – dellgg