2013-01-15 24 views
6

uzun bir süre sonra, JBoss 7.1.1 altında vatansız bir EJB çalışmasına uzaktan erişim sağladım. kullanarak Özellikleri nesne: Yani bu ince çalışırJBoss 7: JNDI araması

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")); 

ama şimdi jndi.properties dosyasına Jndi şey koymak istiyorum ama başarısız oldu, bu dosya nasıl gözüktüğü:

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 

istisna:

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) 

zaten birkaç Doco geçti ama başarısız oldu, yani nasıl o gibi bakmak zorunda?

cevap

7
Tamam

, bu yüzden ben cevap buldum ...

Önce iki özellikleri dosyaları, JNDI.properties artı jboss-ejb-client.properties olması gerekir.

jndi.properties: hatta özelliklerini belirtmeden bir tılsım gibi kod çalıştırılmasını sağlayacaktır üzerinde sınıf ikisi de sahip

# 
# 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 kod içinde. Yine

kafa karıştırıcı

+0

arama dizesi inşası için burada referans verebilir ... arama dizesi yapıdır: https://docs.jboss.org/author/display/AS72/Remote+EJB+ invokasyonlar + yoluyla + Jndi + - + EJB + istemci + API + veya + uzaktan adlandırma + proje. Jboss sunucusunun başlangıcında, uzak link için arama dizisi normalde "java: jboss/exported /" – dellgg