2 Replies Latest reply on Jul 23, 2012 11:49 AM by Wolf-Dieter Fink

    Unable to access EJB from a second JBOSS 7.1 server instance

    amitsoprna Newbie

      Hi

       

      We have a Utility class with the following code inside it.

       

      private static Hashtable<String, String> initContextEnv = new Hashtable<String, String>();

      private static final String PKG_INTERFACES = "org.jboss.ejb.client.naming";

      public static final String PROPERTY_PROVIDER_URL_VALUE = "remote://localhost:4447";

      public static final String JNDI_PREFIX = "ejb:my_beans/my_beans//";

       

       

      initContextEnv.put(Context.URL_PKG_PREFIXES, PKG_INTERFACES);

      initContextEnv.put(Context.PROVIDER_URL, PROPERTY_PROVIDER_URL_VALUE);

       

      initialContext = new InitialContext(initContextEnv);

       

          public final <T> T getEJB(Class<T> beanClass) throws NamingException {

             
              String ejbName = beanClass.getSimpleName() + IMPL;
              String remoteInterfaceName = beanClass.getName();

       

              String jndiName = JNDI_PREFIX + ejbName + "!" + remoteInterfaceName;

       

              Object ref = initialContext.lookup(jndiName);
              return beanClass.cast(ref);
          }

       

      All my stateless session beans are there in the my_beans.jar file which is deployed on server instance 1 as below:

       

      Server instance1

       

      my_beans.ear

        |---------------my_beans.jar

        |---------------my_persistence_beans.jar

       

      When I deploy my second application on the same server instance then it works fine and I am able to succesfully invoke methods on these stateless session beans using the above utility class.

       

      Server instance 1

       

      my_application_one.ear

      |---------------my_application.war

      |---------------META_INF

                             |----------------jboss-deployment-structure.xml

       

      Wherein the jboss-deployment-structure.xml has the following contents:

       

      <?xml version='1.0' encoding='UTF-8'?>

      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">

        <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

        <deployment>

          <dependencies>

              <module name="deployment.my_beans.ear.my_beans.jar" export="true" />

              <module name="deployment.my_beans.ear.my_persistence_beans.jar" export="true" />

          </dependencies>

        </deployment>

      </jboss-deployment-structure>

       

      But when I try to invoke methods on these stateless session beans from other server instance it throws an exception

       

      Server Instance 2:

       

      my_application2.ear

           |----------------my_application2.war

                                        |------------WEB-INF

                                                             |--------lib

                                                                        |--------my_jar_containing_remote_interfaces_of_stateles_session_beans_and_utility_class.jar

       

      07:56:44,086 ERROR [tv.myorg.web.controllers.LoginController] (http-192.168.149.129-192.168.149.129-8580-2) Authenticating user with emailAddress = admin1@myorg.com: java.lang.IllegalStateException: No EJB receiver available for handling [appName:my_beans,modulename:my_beans,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@456c56

              at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]

              at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]

              at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]

              at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]

              at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]

              at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]

              at $Proxy24.login(Unknown Source)       at tv.myorg.services.client.AuthenticationClientImpl.login(AuthenticationClientImpl.java:59) [myorg_client.jar:]

              at tv.myorg.apt.web.controllers.LoginController.handleRequest(LoginController.java:86) [myorg.jar:]

              at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) [spring-webmvc.jar:2.5]

              at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874) [spring-webmvc.jar:2.5]

              at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808) [spring-webmvc.jar:2.5]

              at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476) [spring-webmvc.jar:2.5]

              at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441) [spring-webmvc.jar:2.5]

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

              at tv.myorg.web.filters.MyorgEncodingAndClientCacheFilter.doFilter(MyorgEncodingAndClientCacheFilter.java:65) [myorg.jar:]

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]

              at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

              at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]

              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]

              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]

              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]

              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]

              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]

              at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_07]

       

      What am I missing here? Do I need to include some jar? I have tried various ways to access EJBs by googling and implementing those solutions but nothing was fruitful. Need some directions

       

      attached is my standalone.xml file.

       

      I am using JBOSS7.1 migrating my application from JBOSS4.2. I have created the second server instance by copying the standalone folder of JBOSS. and then giving the server base directory while starting the second server instance as the renamed and copied standalone folder.