1 2 Previous Next 17 Replies Latest reply on Aug 16, 2012 3:26 AM by fpezzati

    Problem with: No EJB receiver available

    fpezzati

      Hello,

       

      I'm facing strange behaviour. Sometimes, when I try to invoke a session bean, I run into the following exception:

       

      com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.util.List myServlet.getData() throws myException' threw an unexpected exception: java.lang.IllegalStateException: No EJB receiver available for handling [appName:myAppNameEE,modulename:myModuleEJB,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@3e23bd28

          at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385)

          at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)

          at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)

          at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)

          at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)

          at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

          at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

          at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)

          at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)

          at com.myapp.server.myServletController.doFilter(LoginControllerFilter.java:51)

          at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)

          at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)

          at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)

          at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)

          at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)

          at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)

          at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)

          at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)

          at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)

          at org.mortbay.jetty.Server.handle(Server.java:324)

          at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)

          at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)

          at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)

          at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)

          at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)

          at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)

          at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)

      Caused by: java.lang.IllegalStateException: No EJB receiver available for handling [appName:myAppEE,modulename:myModuleEJB,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@3e23bd28

          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 $Proxy36.findAllUfficio(Unknown Source)

          at com.myapp.ejb.session.delegates.myDelegate.getData(myDelegate.java:29)

          at com.myapp.web.server.myServlet.getData(myServlet.java:161)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)

          ... 25 more

       

      It usually happens when run my GWT application from Eclipse. The exception does not occur always. Sometimes it occurs fewer than others. Sometimes it occurs pretty every time I call a session bean and it's a pain. I read tutorial (https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI?_sscc=t) and I am pretty sure to have the jboss-ejb-client.properties in the right place. I can't figure out what's going on. TIA.

       

      Francesco

        • 1. Re: Problem with: No EJB receiver available
          wdfink

          Maybe your classpath change if using Eclipse (different run-configurations)?

           

          How your client code and jboss-ejb-client looks like?

          • 2. Re: Problem with: No EJB receiver available
            fpezzati

            Hello! Thank you for the reply. Here's how my jboss-ejb-client looks like:

             

            endpoint.name=myAppEE/myAppEJB

            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

             

            it is located in:

             

            myAppEJB\ejbModule\com\myApp\ejb\conf

             

            This application is deployed under JBoss, the servlet is executed by the eclipse embedde jetty server. The very strange thing is sometimes the servlet do two or more invocation about the session bean. The first one or the first two do succesfully, the last ones return the exception.

             

            Francesco

            • 3. Re: Problem with: No EJB receiver available
              wdfink

              Are you in the same server? Is it possible to use injection?

               

              Could it be that you have multiple threads setting the context? If yes this can have an influence because the invocation must resolve the localtion of the EJB.

              • 4. Re: Problem with: No EJB receiver available
                fpezzati

                There are two applications: the ejb one is running on JBoss, the servlet is running on the eclipse's embedded jetty. I'm not using injection (pretty newbie on jboss7).

                 

                Francesco

                • 5. Re: Problem with: No EJB receiver available
                  wdfink

                  Ok, so it is a 'different JVM' remote client.

                   

                  But is the servet running in different thread at the same time? Or do you have different servlets running concurrently?

                  How your source-code looks like for the ejb-call?

                  Do you have debug logs for one running and one failed request?

                   

                  ATM I've no exact idea what goes wrong ....

                  • 6. Re: Problem with: No EJB receiver available
                    fpezzati

                    Here you are. I run two queries twice. The first time both queries succeed. The second time i got the exception " java.lang.IllegalStateException: No EJB receiver available for handling ...".

                     

                    This is the JBoss 7 consolle:

                    ...

                    16:18:54,709 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "sample.war"

                    16:18:54,709 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "myAppEE.ear"

                    16:20:11,446 INFO  [org.jboss.ejb.client] (pool-4-thread-1) JBoss EJB Client version 1.0.5.Final

                    16:20:12,258 INFO  [com.siweb.ambrogio.ejb.session.TipoScadenzaSession] (EJB default - 1) myAppSession.getAllTipoScadenzaBy.

                    16:20:12,679 INFO  [stdout] (EJB default - 1) Hibernate: select ... where 1=1 and ...

                    16:20:13,163 INFO  [stdout] (EJB default - 2) Hibernate: select count(...) ... where 1=1 and ...

                    16:20:22,897 INFO  [org.jboss.as.naming] (Remoting "tshb01" task-1) JBAS011806: Channel end notification received, closing channel Channel ID 4511f9c3 (inbound) of Re

                    moting connection 024c535d to null

                     

                    And this is the server.log:

                    ...

                    16:20:13,179 DEBUG [org.hibernate.loader.Loader] (EJB default - 2) Result set row: 0

                    16:20:13,179 DEBUG [org.hibernate.loader.Loader] (EJB default - 2) Result row:

                    16:20:13,179 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (EJB default - 2) Releasing JDBC connection

                    16:20:13,179 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (EJB default - 2) Released JDBC connection

                    16:20:13,179 DEBUG [org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler] (EJB default - 2) HHH000163: Logical connection releasing its physical connection

                    16:20:13,179 DEBUG [org.hibernate.engine.internal.StatefulPersistenceContext] (EJB default - 2) Initializing non-lazy collections

                    16:20:13,179 DEBUG [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (EJB default - 2) myAppDS: returnConnection(71f5ba55, false) [2/19]

                    16:20:13,194 DEBUG [org.jboss.as.jpa] (EJB default - 2) EJB default - 2:[transaction scoped EntityManager]: closing entity managersession

                    16:20:13,194 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (EJB default - 2) Aggressively releasing JDBC connection

                    16:20:22,897 DEBUG [org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver] (Remoting "tshb01" read-1) Channel Channel ID 53faf859 (inbound) of Remoting connection 024c535d to /127.0.0.1:61700 closed

                    16:20:22,897 DEBUG [org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver] (Remoting "tshb01" read-1) Channel Channel ID 6d582a7b (inbound) of Remoting connection 024c535d to /127.0.0.1:61700 closed

                    16:20:22,897 DEBUG [org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver] (Remoting "tshb01" read-1) Channel Channel ID 661690c8 (inbound) of Remoting connection 024c535d to /127.0.0.1:61700 closed

                    16:20:22,897 DEBUG [org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver] (Remoting "tshb01" read-1) Channel Channel ID 042162d8 (inbound) of Remoting connection 024c535d to /127.0.0.1:61700 closed

                    16:20:22,897 DEBUG [org.jboss.naming.remote.server.RemoteNamingService] (Remoting "tshb01" read-1) Channel Channel ID 4511f9c3 (inbound) of Remoting connection 024c535d to /127.0.0.1:61700 closed.

                    16:20:22,897 DEBUG [org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver] (Remoting "tshb01" read-1) Channel Channel ID 0c4d63f1 (inbound) of Remoting connection 024c535d to /127.0.0.1:61700 closed

                    16:20:22,897 INFO  [org.jboss.as.naming] (Remoting "tshb01" task-1) JBAS011806: Channel end notification received, closing channel Channel ID 4511f9c3 (inbound) of Remoting connection 024c535d to null

                    16:20:39,232 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Start expire sessions StandardManager at 1341498039232 sessioncount 0

                    16:20:39,232 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) End expire sessions StandardManager processingTime 0 expired sessions: 0

                    16:20:39,232 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Start expire sessions StandardManager at 1341498039232 sessioncount 0

                    16:20:39,232 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) End expire sessions StandardManager processingTime 0 expired sessions: 0

                    16:21:39,323 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Start expire sessions StandardManager at 1341498099323 sessioncount 0

                    16:21:39,323 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) End expire sessions StandardManager processingTime 0 expired sessions: 0

                    16:21:39,323 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Start expire sessions StandardManager at 1341498099323 sessioncount 0

                    16:21:39,323 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) End expire sessions StandardManager processingTime 0 expired sessions: 0

                    16:22:39,396 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Start expire sessions StandardManager at 1341498159396 sessioncount 0

                    16:22:39,396 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) End expire sessions StandardManager processingTime 0 expired sessions: 0

                    16:22:39,396 DEBUG [org.apache.catalina.session.ManagerBase] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Start expire sessions StandardManager at 1341498159396 sessioncount 0

                    • 7. Re: Problem with: No EJB receiver available
                      wdfink

                      I suppose the logs are the target. But you will not see what happen if the Exception is thrown because this will happen on client side.

                       

                      Also you did not answered my questions regarding concurency and how the source code of the client looks like.

                      • 8. Re: Problem with: No EJB receiver available
                        fpezzati

                        Here is my code. The servlet call the businness delegate which call the session bean. What do you mean with "concurrency" there is a Servlet (the one that follow in this post, which is the one that I use to call ejb side app) and a servlet which implements javax.servlet.Filter. I hope I give you all the info you need. Thank you.

                         

                        The businness delegate:

                         

                        public class myAppServerDelegate extends ServerDelegate{

                            private Logger logger = Logger.getLogger(myAppServerDelegate.class.getName());

                           

                            private myAppRemote theSession = null;

                           

                            public myAppServerDelegate() throws Exception {

                                try {

                                    theSession = (myAppRemote) getJndiContext().lookup(getJindiLookupName(myAppServerDelegate.class, myAppRemote.class));

                                } catch (NamingException e) {

                                    throw (e);

                                }

                            }

                         

                            public List<myDataDTO> getAllmyDataBy(String a, String b,

                                    String c, String d,Integer e,

                                    Integer f) throws ServerDelegateException {

                                    return theSession.getAllmyDataBy(a, b, c, d,e,f);

                            }

                           

                            public Integer getCountmyDataBy(String a, String b, String c, String d) throws ServerDelegateException {

                                return theSession.getCountmyDataBy(a, b, c, d);

                            }

                           

                            ...

                           

                            public String getServiceMessage() {

                                return theSession.getServiceMessage();

                            }

                           

                            ...

                        }

                         

                        The session bean:

                         

                        @Stateless

                        public class myAppSession implements myAppRemote {

                            private Logger logger = Logger.getLogger(myAppSession.class.getName());

                            @PersistenceContext

                            protected EntityManager entityManager;

                            @EJB

                            private myAppHomeLocal beanmyApp;

                         

                            ...

                           

                            public String getServiceMessage() {

                                return "MESSAGGIODISERVIZIO";

                            }

                         

                            public List<myDataDTO> getAllmyDataBy(String a,String b,

                                    String c, String d,Integer e,

                                    Integer f) throws ServerDelegateException {

                                logger.info("myAppSession.getAllmyDataBy.");

                                    List<myData> entityList = findByParms(a, b, c, d,e,f);

                                    return myDataAssemblyDTO.getmyDataDTOList(entityList);

                            }

                           

                            public Integer getCountmyDataBy(String a,String b, String c, String d) throws ServerDelegateException {

                                return findByParmsCount(a, b, c, d);

                            }

                           

                            ...

                        }

                         

                        The servlet:

                         

                        ...

                        @SuppressWarnings("serial")

                        public class MyGenericServiceImpl extends RemoteServiceServlet implements MyGenericService {

                            private MyAppServerDelegate myAppServerDelegate = null;

                           

                            public MyGenericServiceImpl() throws Exception{

                                super();

                                myAppServerDelegate = new MyAppServerDelegate();

                            }

                           

                            private MyAppServerDelegate getDelegate()    {

                                return myAppServerDelegate;

                            }

                           

                            private myGWTException buildLocalExceptionFromServerException(ServerDelegateException sde)    {

                                myGWTException x = new myGWTException();

                                x.setParms(sde.guiMessage,sde.timestamp,sde.tipoEvento);

                                return x;

                            }

                           

                            @Override

                            public PagingLoadResult<myDataBean> getAllmyDataBy(String a, String b, String c, PagingLoadConfig plc) throws MyGWTException {

                                try    {

                                    String cs = ((UserSessionBean)this.getThreadLocalRequest().getSession().getAttribute("user")).getCodiceStudio();

                                    List<myDataBean> tsb = MyDataClientAssembly.getMyDataBeanList(myAppServerDelegate.getAllmyDataBy(cs, a, b, c, plc.getOffset(), plc.getLimit()));

                                    return new BasePagingLoadResult<MyDataBean>(tsb, plc.getOffset(), myDataServerDelegate.getCountmyDataBy(cs, a, b, c));

                                } catch (ServerDelegateException sde)    {

                                    throw buildLocalExceptionFromServerException(sde);

                                }

                            }

                         

                            @Override

                            public String getServiceMessage() {

                                return getDelegate().getServiceMessage();

                            }

                         

                            @Override

                            public Integer getCountmyDataBy(String a, String b, String c) throws AmbrogioGWTException {

                                try    {

                                    String cs = ((UserSessionBean)this.getThreadLocalRequest().getSession().getAttribute("user")).getCs();

                                    return myAppServerDelegate.getCountmtDataBy(cs, a, b, c);

                                } catch (ServerDelegateException sde)    {

                                    throw buildLocalExceptionFromServerException(sde);

                                }

                            }

                        }

                        • 9. Re: Problem with: No EJB receiver available
                          wdfink

                          How the ServerDelegate looks like?

                           

                          Do you call the myAppServerDelegate constructor more than one?

                          • 10. Re: Problem with: No EJB receiver available
                            fpezzati

                            Hello again. Here is the ServerDelegate. Yes it is called more than one, it's called everytime I invoke a businnes delegate's method.

                             

                            public class ServerDelegate {

                             

                                static public String getJindiLookupName( Class<?> theBeanClass, Class<?> theSessionClass) throws NamingException    {

                                   

                                    String jbossServerName = System.getProperty("jboss.server.name");

                                           

                                    if (jbossServerName== null ||  "".equals(jbossServerName)){

                                        return "myAppEE/myAppEJB/"+ theBeanClass.getSimpleName() + "!" + theSessionClass.getName();

                                       

                                    }else{

                                        return "java:global/myAppEE/myAppEJB/" + theBeanClass.getSimpleName() + "!" + theSessionClass.getName();

                                    }       

                                }

                             

                                static public Context getJndiContext() throws NamingException    {

                                    System.out.println("ServerDelegate.getJndiContext");

                                    final Properties jndiProperties = new Properties();

                                           

                                    String jbossServerName = System.getProperty("jboss.server.name");

                                   

                                    if (jbossServerName== null ||  "".equals(jbossServerName)){

                                        jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());

                                        jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:4447");

                                        jndiProperties.put("jboss.naming.client.ejb.context", true);

                                        jndiProperties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");

                                    }             

                                    return new InitialContext(jndiProperties);       

                                }

                            }

                            • 11. Re: Problem with: No EJB receiver available
                              fpezzati

                              Digging more into the problem I found one more strange thing. If I invoke a sessionBean by a simple java app (old good main class) with this lookup string:

                               

                              ejb:AmbrogioEE/AmbrogioEJB//MySession!com.app.ejb.session.MyRemote

                               

                              everything works fine. But, if my BusinessDelegate use the same lookup string I got this exception:

                               

                              javax.naming.NameNotFoundException: ejb:myAppEE/myAppEJB//MySession!com.app.ejb.session.MyRemote -- service jboss.naming.context.java.jboss.exported.ejb:myAppEE.myAppEJB."MySession!com.app.ejb.session.MyRemote"

                                  at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)

                                  at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)

                                  at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)

                                  at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)

                                  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                                  at java.lang.Thread.run(Thread.java:662)

                               

                              Both servlet and main class uses the properties:

                               

                              jndiproperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

                              jndiproperties.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());

                              jndiproperties.put(Context.PROVIDER_URL, "remote://localhost:4447");

                              jndiproperties.put("jboss.naming.client.ejb.context", true);

                              jndiproperties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");

                               

                              Last: as everithing does not work while running GWT on Eclipse's embedded Jetty and EJB on JBoss, if GWT .war module and EJB .jar are running together on the same JBoss, it works.

                               

                              Pretty confused about this. Any help? TIA.

                               

                              Francesco

                              • 12. Re: Problem with: No EJB receiver available
                                fpezzati

                                Anyone? Maybe I lack some infos/stuff? Thanks in advance.

                                 

                                Francesco

                                • 13. Re: Problem with: No EJB receiver available
                                  wdfink

                                  Hi Francesco,

                                  you should not use the remote-naming approach (remote://...).

                                  The ejb-client stuff will be different to former versions.

                                   

                                  Do you run the GWT (I suppose Google Web Toolkit) in a JBoss server? In that case I would use the "ejb:...." naming and configure the outbound-connections described here.

                                  You might use injection or use the InitialContext().lookup("ejb:..."). You should not create the IC multiple times, specialy if you use the remote-naming because there everytime new connections will be created, see this doc.

                                  • 14. Re: Problem with: No EJB receiver available
                                    fpezzati

                                    Hello Wolf,

                                     

                                    I read carefully the docs you link to me. I added a user by add-user program (and added credential to my ServerDelegate class). I also modified the code to avoid to create IC multiple times. The jndi lookup strings are correct, accordingly to EJB 3.1 spec.

                                    When I run the gwt app, into the same JBoss where ejb app is, everything works fine. When I run the gwt in dev-mode using Eclipse (using the embedded Jetty AS, so it's a remote AS) the problem persist. TIA.

                                     

                                    Francesco

                                    1 2 Previous Next