4 Replies Latest reply on May 3, 2013 5:59 AM by wantdrink

    Fail to lookup Stateless EJB3.0 in EAP6.0 with the @stateless(name=xxx) assigned

    wantdrink

      Hi All,

       

      I got an error 'EJBCLIENT000025: No EJB receiver available for handling' exception  when lookup Stateless EJB in client if I assign a EJB 'name' for the bean.

       

      I have a war project named 'as7project' and there is a stateless EJB, and below is the correct code that the bean can be found successfully:

       

      package com.sample.ejb;

       

      public interface SampleBeanRemote {
      public String echo(String s);

      }

       

       

      package com.sample.ejb;

      import javax.ejb.Remote;
      import javax.ejb.Stateless;

       

      @Remote
      @Stateless

      public class SampleBeanRemoteImpl implements SampleBeanRemote {

       

      @Override
      public String echo(String s) {

        return "Hello " + s;
      }

      }

       

      And lookup EJB as below:

        final Hashtable jndiProperties = new Hashtable();
        jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

        final Context context = new InitialContext(jndiProperties);


        final String appName = "";
        final String moduleName = "as7project";
        final String distinctName = "";
        final String beanName = SampleBeanRemoteImpl.class.getSimpleName();

        final String viewClassName = SampleBeanRemote.class.getName();

        return (SampleBeanRemote) context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);

       

      And the file jboss-ejb-client.properties in config folder:

      endpoint.name=client-endpoint
      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
      #remote.connection.default.username=admin123
      #remote.connection.default.password=fmarchioni

       

      The lookup succeeded.

       

      Then I want to test the EJB JNDI name if I assign the EJB 'name' to this bean, and I added '@Stateless(name = "SampleBeanRemote")' as below:

      @Remote
      @Stateless(name = "SampleBeanRemote")
      public class SampleBeanRemoteImpl implements SampleBeanRemote {

      @Override
      public String echo(String s) {

        return "Hello " + s;
      }

      }

      Then I got exception with the old lookup code as below:

      javax.ejb.NoSuchEJBException: No such EJB[appname=,modulename=as7project,distinctname=,beanname=SampleBeanRemoteImpl]
      at org.jboss.ejb.client.remoting.NoSuchEJBExceptionResponseHandler.processMessage(NoSuchEJBExceptionResponseHandler.java:64)
      at org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver.handleMessage(ChannelAssociation.java:396)
      at org.jboss.remoting3.remote.RemoteConnectionChannel$5.run(RemoteConnectionChannel.java:437)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
      at java.lang.Thread.run(Thread.java:662)
      Exception in thread "main" java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:, moduleName:as7project, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@6cb8
      at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:588)
      at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)
      at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
      at org.jboss.ejb.client.EJBClientInvocationContext.retryRequest(EJBClientInvocationContext.java:206)
      at org.jboss.ejb.client.EJBReceiverInvocationContext.retryInvocation(EJBReceiverInvocationContext.java:95)
      at org.jboss.ejb.client.remoting.NoSuchEJBExceptionResponseHandler.processMessage(NoSuchEJBExceptionResponseHandler.java:78)
      at org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver.handleMessage(ChannelAssociation.java:396)
      at org.jboss.remoting3.remote.RemoteConnectionChannel$5.run(RemoteConnectionChannel.java:437)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
      at java.lang.Thread.run(Thread.java:662)

      I changed the distinctName in lookup code as

       

        final String distinctName = "SampleBeanRemote";

       

      And it still failed.

      So we cann't use the EJB annotation 'name' or 'mappedName' in JBoss EAP6?

      Or if we assign the 'name' property for EJB bean we need to change the JNDI lookup for it?

      Attached please find the Eclipse web project source code. Thanks a lot.