6 Replies Latest reply on Sep 3, 2013 9:24 AM by jaikiran pai

    Creating multiple instance of one EJB-Class causes "No EJB receiver available"-Exception

    goot Newbie

      I have a Tomcat running on the frontend side while my EJBs are running on a JBoss AS 7.1

      My (stateful) EJB Class is not annotated as a singleton.

       

      Anyway, when I try to lookup two EJBs at the same time, I receive an exception message about a missing EJB receiver.

      I need to provide this EJB for dozens of users at the same time.

       

      When I restart the Tomcat user, I can call the EJBs again, maybe this happens because the ejb-user is already logged in to the JBoss?

      Is there anything I can do to avoid this error?

       

      WARN : org.jboss.ejb.client.remoting.ChannelAssociation - Unsupported message received with header 0xffffffff
      Looking EJB via JNDI
      hi there, I'm a bean!
      Looking EJB via JNDI
      WARN : org.jboss.ejb.client.remoting.ChannelAssociation - Unsupported message received with header 0xffffffff
      javax.naming.NamingException: Failed to create proxy [Root exception is java.lang.IllegalStateException: No EJB receiver available for handling [appName:foo_business_ear-ear,modulename:foo_business_ear-ejb,distinctname:] combination]
          at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:115)
          at org.jboss.ejb.client.naming.ejb.EjbNamingContext.lookup(EjbNamingContext.java:96)
          at javax.naming.InitialContext.lookup(Unknown Source)
          at foo.frontend.controller.UserController.logIn(UserController.java:63)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
          at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
          at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
          at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
          at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
          at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
          at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
          at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
          at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
          at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
          at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
          at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
          at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.IllegalStateException: No EJB receiver available for handling [appName:foo_business_ear-ear,modulename:foo_business_ear-ejb,distinctname:] combination
          at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:517)
          at org.jboss.ejb.client.EJBClient.createSession(EJBClient.java:161)
          at org.jboss.ejb.client.naming.ejb.EjbNamingContext.doCreateProxy(EjbNamingContext.java:135)
          at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:113)
          ... 35 more
      
      
      
      
      
      

       

       

      EDIT:

       

      I just shutdown my tomcat and Jboss returned the following info in the log

       

      
      
      
      
      
      15:07:07,436 INFO  [org.jboss.as.naming] (Remoting "goot_acer" task-3) JBAS011806: Channel end notification received, closing channel Channel ID 33e234dd (inbound) of Remoting connection 18dc0e9b to /127.0.0.1:57933
      15:15:13,892 INFO  [org.jboss.as.naming] (Remoting "goot_acer" task-3) JBAS011806: Channel end notification received, closing channel Channel ID 39f241ee (inbound) of Remoting connection 31360c30 to /127.0.0.1:57939
      20:50:00,877 ERROR [org.jboss.remoting.remote.connection] (Remoting "goot_acer" read-1) JBREM000200: Remote connection failed: java.io.IOException: Eine vorhandene Verbindung wurde vom Remotehost geschlossen (Existing connection with remote host was closed)
      20:50:00,878 ERROR [org.jboss.remoting.remote.connection] (Remoting "goot_acer" read-1) JBREM000200: Remote connection failed: java.io.IOException: Eine vorhandene Verbindung wurde vom Remotehost geschlossen (Existing connection with remote host was closed)
      20:50:00,879 INFO  [org.jboss.as.naming] (Remoting "goot_acer" task-4) JBAS011806: Channel end notification received, closing channel Channel ID 2c7127a9 (inbound) of Remoting connection 4f086115 to null
      20:50:00,880 INFO  [org.jboss.as.naming] (Remoting "goot_acer" task-1) JBAS011806: Channel end notification received, closing channel Channel ID 77f38359 (inbound) of Remoting connection 77f8a1af to null
      21:42:49,392 INFO  [org.jboss.as.naming] (Remoting "goot_acer" task-3) JBAS011806: Channel end notification received, closing channel Channel ID 7e3f2867 (inbound) of Remoting connection 35de82e9 to null
      21:52:19,986 ERROR [org.jboss.remoting.remote.connection] (Remoting "goot_acer" read-1) JBREM000200: Remote connection failed: java.io.IOException: Eine vorhandene Verbindung wurde vom Remotehost geschlossen (Existing connection with remote host was closed)
      21:52:19,991 ERROR [org.jboss.remoting.remote.connection] (Remoting "goot_acer" read-1) JBREM000200: Remote connection failed: java.io.IOException: Eine vorhandene Verbindung wurde vom Remotehost geschlossen (Existing connection with remote host was closed)
      21:52:19,993 INFO  [org.jboss.as.naming] (Remoting "goot_acer" task-1) JBAS011806: Channel end notification received, closing channel Channel ID 15f38b65 (inbound) of Remoting connection 37b05625 to null
      21:52:19,996 INFO  [org.jboss.as.naming] (Remoting "goot_acer" task-4) JBAS011806: Channel end notification received, closing channel Channel ID 3f1c7ecc (inbound) of Remoting connection 5e5be8a3 to null
      
      
      

       

       

       

      EDIT: This is my lookup Code

       

       

      final Properties initialContextProperties = new Properties();
      
      
      initialContextProperties.put(Context.INITIAL_CONTEXT_FACTORY,
      "org.jboss.naming.remote.client.InitialContextFactory");
      
      
      
      
      initialContextProperties.put(Context.PROVIDER_URL,
      "remote://localhost:4447");
      
      initialContextProperties.put(Context.URL_PKG_PREFIXES,
      "org.jboss.ejb.client.naming");
      
      initialContextProperties.put("jboss.naming.client.ejb.context","true");
      
      initialContextProperties
      .put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT",
      "false");
      
      initialContextProperties.put(Context.SECURITY_PRINCIPAL, "username");
      initialContextProperties.put(Context.SECURITY_CREDENTIALS, "password");
      
      EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(
      initialContextProperties);
      ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(
      cc);
      EJBClientContext.setSelector(selector);
      
      context = new InitialContext(initialContextProperties);
      System.out.println("Looking EJB via JNDI ");
      String typeOfEJB = "stateful";
      remote = (LoginBeanRemote) context
      .lookup("ejb:foo_business_ear-ear/foo_business_ear-ejb//LoginBean!foo.business.login.LoginBeanRemote"
      + "?" + typeOfEJB);
      System.out.println(remote.helloBean());
      
        • 1. Re: Creating multiple instance of one EJB-Class causes "No EJB receiver available"-Exception
          Wolf-Dieter Fink Master

          Not sure what you try to achieve.

          Do you need to connect with different user credentials?

          When the problem happen?

          Could you show the relevant lookup and invocation code?

          • 2. Re: Creating multiple instance of one EJB-Class causes "No EJB receiver available"-Exception
            goot Newbie

            I added the lookup source to my post.

            The problem happens when I try to lookup for more than one time, no matter if I created a new session on the  frontend side or not.

            • 3. Re: Creating multiple instance of one EJB-Class causes "No EJB receiver available"-Exception
              jaikiran pai Master

              Please upgrade to a later  version of JBoss AS/WildFly Downloads There have been numerous fixes after 7.1.1.Final.

              • 4. Re: Creating multiple instance of one EJB-Class causes "No EJB receiver available"-Exception
                Wolf-Dieter Fink Master

                The IC and Selector creation for lookup is a mix of remote-naming and ejb-client.

                You should read the ejb-client and the remote-naming section of the documentation and use one of it, I recommend to use the ejb-client approach as remote-naming does not support all features. I suppose if you use the jboss-ejb-client.properties file it might work, but you are not able to set the properties programatic.

                 

                Nevertheless whether it work or not you should upgrade to a newer version as Jaikiran already mentioned. Also you have a new feature to connect, see scoped-context documentation

                • 5. Re: Re: Creating multiple instance of one EJB-Class causes "No EJB receiver available"-Exception
                  goot Newbie

                  I removed the selector part from the lookup and I updated to WildFly 8.0 Alpha 4

                   

                  According to

                   

                  http://jaitechwriteups.blogspot.de/2013/07/wildfly-800alpha3-released-with-support.html

                  JNDI Lookup Failing

                   

                  I edited my lookup code and set the provider url to "http-remoting://localhost:8080". Also I added the new jboss-client.jar to my classpath.

                   

                  When I try to lookup this will return a message about the missing http-remoting scheme.

                   

                   

                  javax.naming.NamingException: Failed to create remoting connection [Root exception is org.jboss.remoting3.UnknownURISchemeException: No connection provider for URI scheme "http-remoting" is installed]
                    at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)
                    at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:121)
                    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
                    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
                    at javax.naming.InitialContext.init(Unknown Source)
                    at javax.naming.InitialContext.<init>(Unknown Source)
                    at recc.frontend.controller.UserController.logIn(UserController.java:69)
                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                    at java.lang.reflect.Method.invoke(Unknown Source)
                    at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
                    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
                    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
                    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
                    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
                    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
                    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
                    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
                    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
                    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
                    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
                    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
                    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
                    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
                    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
                    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
                    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
                    at java.lang.Thread.run(Unknown Source)
                  Caused by: org.jboss.remoting3.UnknownURISchemeException: No connection provider for URI scheme "http-remoting" is installed
                    at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:265)
                    at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:251)
                    at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:349)
                    at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:333)
                    at org.jboss.naming.remote.client.EndpointCache$EndpointWrapper.connect(EndpointCache.java:105)
                    at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:55)
                    at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateCachedNamingStore(InitialContextFactory.java:166)
                    at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:139)
                    at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:104)
                    ... 38 more
                  
                  

                   

                  What am I missing here?

                  • 6. Re: Re: Re: Creating multiple instance of one EJB-Class causes "No EJB receiver available"-Exception
                    jaikiran pai Master

                    The line numbers of remote-naming project doesn't match with the latest libraries. So I think you have a mismatch with the library versions on the client side. How are you managing the library versions on the client classpath?

                     

                    Other than fixing the classpath, all you need is making sure the code is right. It should be something like this like explained in the documentation here https://docs.jboss.org/author/display/WFLY8/Scoped+EJB+client+contexts

                     

                    final Properties jndiProps = new Properties();
                            // Property to enable scoped EJB client context which will be tied to the JNDI context
                            jndiProps.put("org.jboss.ejb.client.scoped.context", true);
                            // Property which will handle the ejb: namespace during JNDI lookup
                            jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
                    
                            final String connectionName = "foo-bar-connection";
                            jndiProps.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
                            // add a property which lists the connections that we are configuring. In
                            // this example, we are just configuring a single connection named "foo-bar-connection"
                            jndiProps.put("remote.connections", connectionName);
                            // add a property which points to the host server of the "foo-bar-connection"
                            jndiProps.put("remote.connection." + connectionName + ".host", "localhost");
                            // add a property which points to the port on which the server is listening for EJB invocations
                            jndiProps.put("remote.connection." + connectionName + ".port", "8080");
                            // add the username and password properties which will be used to establish this connection
                            jndiProps.put("remote.connection." + connectionName + ".username", "username");
                            jndiProps.put("remote.connection." + connectionName + ".password", "password");
                    
                    
                            Context ejbJNDIContext = new InitialContext(jndiProps).lookup("ejb:"); 
                            try {
                                System.out.println("Looking EJB via JNDI "); 
                                String typeOfEJB = "stateful"; 
                                remote = (LoginBeanRemote) context.lookup("foo_business_ear-ear/foo_business_ear-ejb//LoginBean!foo.business.login.LoginBeanRemote" + "?" + typeOfEJB); 
                                System.out.println(remote.helloBean()); 
                            } finally {
                                ejbJNDIContext.close();
                            }