ejb - Java EE 7 and Wildfly 10.1.0 - IllegalStateException: EJBCLIENT000025 -
i created following ejb-module:
1) remote interface
package calculator.beans; import javax.ejb.remote; @remote public interface calculatorremote { public int addnum(int num1, int num2); }
2) bean implements interface
package calculator.beans; import javax.ejb.stateless; @stateless public class calculatorbean implements calculatorremote { @override public int addnum(int num1, int num2) { return num1 + num2; } }
3) next created property-file 'jboss-ejb-client.properties'
endpoint.name=client-endpoint remote.connectionprovider.create.options.org.xnio.options.ssl_enabled=false remote.connections=default remote.connection.default.host=127.0.0.1 remote.connection.default.port = 8080 remote.connection.default.connect.options.org.xnio.options.sasl_policy_noanonymous=false remote.connection.default.username=appuser remote.connection.default.password=apppassword
after deployment wildfly fine. following information:
info [org.jboss.as.ejb3.deployment] (msc service thread 1-4) wflyejb0473: jndi bindings session bean named 'calculatorbean' in deployment unit 'deployment "calculatorejb.jar"' follows: java:global/calculatorejb/calculatorbean!calculator.beans.calculatorremote java:app/calculatorejb/calculatorbean!calculator.beans.calculatorremote java:module/calculatorbean!calculator.beans.calculatorremote java:jboss/exported/calculatorejb/calculatorbean!calculator.beans.calculatorremote java:global/calculatorejb/calculatorbean java:app/calculatorejb/calculatorbean java:module/calculatorbean 4) created java client
package calculator.client; import java.util.hashtable; import javax.naming.context; import javax.naming.initialcontext; import javax.naming.namingexception; import calculator.beans.calculatorremote; public class remoterechnerclient { public static void main(string[] args) { try { final hashtable<string, string> jndiproperties = new hashtable<>(); jndiproperties.put(context.url_pkg_prefixes, "org.jboss.ejb.client.naming"); final context ctx = new initialcontext(jndiproperties); string crname = calculatorremote.class.getname(); calculatorremote cr = (calculatorremote) ctx.lookup("ejb:calculatorejb/beans/calculatorbean!" + crname); system.out.println("result: " + cr.addnum(5, 4)); } catch (namingexception ex) { ex.printstacktrace(); } } } the code simple enough. if run client following error-message:
apr 06, 2017 3:30:26 pm org.jboss.ejb.client.ejbclient <clinit> info: jboss ejb client version 2.0.1.final apr 06, 2017 3:30:26 pm org.xnio.xnio <clinit> info: xnio version 3.3.0.final apr 06, 2017 3:30:26 pm org.xnio.nio.nioxnio <clinit> info: xnio nio implementation version 3.3.0.final apr 06, 2017 3:30:26 pm org.jboss.remoting3.endpointimpl <clinit> info: jboss remoting version 4.0.6.final apr 06, 2017 3:30:27 pm org.jboss.ejb.client.remoting.versionreceiver handlemessage info: ejbclient000017: received server version 2 , marshalling strategies [river] apr 06, 2017 3:30:27 pm org.jboss.ejb.client.remoting.remotingconnectionejbreceiver associate info: ejbclient000013: successful version handshake completed receiver context ejbreceivercontext{clientcontext=org.jboss.ejb.client.ejbclientcontext@3c0f93f1, receiver=remoting connection ejb receiver [connection=org.jboss.ejb.client.remoting.connectionpool$pooledconnection@31dc339b,channel=jboss.ejb,nodename=john-waynes-macbook-pro]} on channel channel id b98547a5 (outbound) of remoting connection 0c84e8ba /127.0.0.1:8080 exception in thread "main" java.lang.illegalstateexception: ejbclient000025: no ejb receiver available handling [appname:calculatorejb, modulename:beans, distinctname:] combination invocation context org.jboss.ejb.client.ejbclientinvocationcontext@2758fe70 @ org.jboss.ejb.client.ejbclientcontext.requireejbreceiver(ejbclientcontext.java:749) @ org.jboss.ejb.client.receiverinterceptor.handleinvocation(receiverinterceptor.java:116) @ org.jboss.ejb.client.ejbclientinvocationcontext.sendrequest(ejbclientinvocationcontext.java:186) @ org.jboss.ejb.client.ejbinvocationhandler.sendrequestwithpossibleretries(ejbinvocationhandler.java:253) @ org.jboss.ejb.client.ejbinvocationhandler.doinvoke(ejbinvocationhandler.java:198) @ org.jboss.ejb.client.ejbinvocationhandler.doinvoke(ejbinvocationhandler.java:181) @ org.jboss.ejb.client.ejbinvocationhandler.invoke(ejbinvocationhandler.java:144) @ com.sun.proxy.$proxy0.addnum(unknown source) @ calculator.client.remoterechnerclient.main(remoterechnerclient.java:27) /users/manhthangd/library/caches/netbeans/8.2/executor-snippets/run.xml:53: java returned: 1 build failed (total time: 3 seconds) i using netbeans 8.2, java ee 7 , wildfly 10.1.0-final. can solve problem?
your jndi lookup name incorrect.
you need use highlighted portion of:
java:jboss/exported/calculatorejb/calculatorbean!calculator.beans.calculatorremote
ie.
calculatorremote cr = (calculatorremote) ctx.lookup("ejb:calculatorejb/calculatorbean!" + crname); where did "ejb:calculatorejb/beans/calculatorbean!" from?
Comments
Post a Comment