6
经过了一段时间,我在远程访问了JBoss 7.1.1下的无状态EJB运行。使用Properties对象: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事情到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
的例外:
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但失败了,所以它是如何看起来像那么?
对于建设查找字符串,你可以参考这里:https://docs.jboss.org/author/display/AS72/Remote+EJB+调用+通过JNDI + + - + EJB +客户端+ API +或+远程命名+项目。在jboss服务器启动时,对于远程连接,查找字符串通常在“java:jboss/exported /”之后 – dellgg