2 Replies Latest reply on Nov 17, 2014 6:37 PM by amitsoprna

    Wildfly wildfly-8.1.0.Final remote ejb invocation and class loading issue

    amitsoprna Newbie

      Hi,

       

      Following are the details about the problem I am facing:

       

      We have one ear that has the stateless EJBs deployed in it and these EJBs are utilized by various other applications (ears deployed within same server or different server instances) to do some common stuff. And this was working with JBOSS 6.

       

      Now I am trying to upgrade to wildfly-8.1.0.Final and I am done with most of the migration stuff but stuck on this one. So need some help in crossing this hurdle...

       

      The ear that has the Stateless EJBs deployed in it has the following structure:

       

      myappwithstatelessejbs.ear

                          |----------META-INF

                                         |----------application.xml

                          |----------entityBeans.jar  ** This jar has the entity beans

                          |----------appwithstatelessejbs.war

                                         |----------META-INF

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

                                                        |--------classes          ** My application classes

                                                        |--------lib

                                                                  |-----app.jar  ** This is the actual jar that contains all the EJBs


      The application.xml for it looks like this:

       

      <application>

          <display-name>myappwithstatelessejbs</display-name>

          <module>

              <ejb>entityBeans.jar</ejb>

          </module>

          <module>

              <web>

                  <web-uri>appwithstatelessejbs.war</web-uri>

                  <context-root>appwithstatelessejbs</context-root>

              </web>

          </module>

      </application>

       

      Now I have another ear that gets deployed in the same JBOSS server instance (or may go in other) for which the structure is like this:

       

      mysecondappthatcallsstatelessejbs.ear

                          |----------META-INF

                                         |----------jboss-ejb-client.properties

                                         |----------application.xml

                          |----------lib

                                      |----------xyz.jar **lib has a lot of jars that the application needs

                                      |----------jarcontainingremoteinterfaces.jar  ** The lib directory has this jar too that contains the remote interfaces for all the stateless EJBs and some other classes that use them

                          |----------secondappthatcallsstatelessejbs.war

                                         |----------META-INF

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

                                                        |--------classes          ** My application classes that use the EJBs


      The application.xml for it looks like this:

       

      <application>

          <display-name>mysecondappthatcallsstatelessejbs</display-name>

          <module>

              <web>

                  <web-uri>secondappthatcallsstatelessejbs.war</web-uri>

                  <context-root>secondappthatcallsstatelessejbs</context-root>

              </web>

          </module>

      </application>

       

      And the jboss-ejb-client.properties has the following content:

       

      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.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false

       

      remote.connection.default.username=ejbuser

      remote.connection.default.password=password#1

       

      The EJB Locator on the client side in the second ear has following code:

       

      Properties jndiProps = new Properties();

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

      Context initialContext = new InitialContext(jndiProps);

      Object ejbRef = initialContext.lookup("ejb:/myappwithstatelessejbs/appwithstatelessejbs/myEJBImplName!myEJBRemoteInterfaceName");

       

      But when the application execute the above lookup line it is throwing following exception:

       

      16:23:51,730 ERROR [com.myorganization.config.MainClassthatInvoksTheEjb] (MSC service thread 1-8) MainClassthatInvoksTheEjb failed: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

          at com.myorganization.otherpackage.OtherClass.methodThatInvokesEJB(OtherClass.java:140) [jarcontainingremoteinterfaces.jar:]

          at com.myorganization.config.MainClassthatInvoksTheEjb.methodThatInvokesEJB(MainClassthatInvoksTheEjb.java:138) [classes:]

          at com.myorganization.config.MainClassthatInvoksTheEjb.methodThatInvokesEJB(MainClassthatInvoksTheEjb.java:47) [classes:]

          at com.myorganization.config.MainClassthatInvoksTheEjb.postProcessBeanFactory(MainClassthatInvoksTheEjb.java:35) [classes:]

          at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:541) [spring.jar:2.5]

          at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:515) [spring.jar:2.5]

          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348) [spring.jar:2.5]

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

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

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

          at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126) [spring-webmvc.jar:2.5]

          at javax.servlet.GenericServlet.init(GenericServlet.java:244) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]

          at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:214) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]

          at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:119) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]

          at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:505) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]

          at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:88)

          at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)

          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_25]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_25]

          at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_25]

      Caused by: java.lang.reflect.InvocationTargetException

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_25]

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_25]

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_25]

          at java.lang.reflect.Method.invoke(Method.java:483) [rt.jar:1.8.0_25]

          at com.myorganization.shared.api.BaseFactory.getInstance(BaseFactory.java:118) [jarcontainingremoteinterfaces.jar:]

          ... 21 more

      Caused by: javax.naming.NamingException: EJBCLIENT000037: Could not load ejb proxy class myEJBRemoteInterfaceName [Root exception is java.lang.ClassNotFoundException: myEJBRemoteInterfaceName from [Module "deployment.mysecondappthatcallsstatelessejbs.ear.secondappthatcallsstatelessejbs.war:main" from Service Module Loader]]

          at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:188) [jboss-ejb-client-2.0.1.Final.jar:2.0.1.Final]

          at org.jboss.ejb.client.naming.ejb.EjbNamingContext.lookup(EjbNamingContext.java:176) [jboss-ejb-client-2.0.1.Final.jar:2.0.1.Final]

          at javax.naming.InitialContext.lookup(InitialContext.java:417) [rt.jar:1.8.0_25]

          at javax.naming.InitialContext.lookup(InitialContext.java:417) [rt.jar:1.8.0_25]

          at com.myorganization.ejb.client.util.ServiceLocator.getEJB(ServiceLocator.java:103) [jarcontainingremoteinterfaces.jar:]

          ... 26 more

      Caused by: java.lang.ClassNotFoundException: myEJBRemoteInterfaceName from [Module "deployment.mysecondappthatcallsstatelessejbs.ear.secondappthatcallsstatelessejbs.war:main" from Service Module Loader]

          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]

          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]

          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]

          at java.lang.Class.forName0(Native Method) [rt.jar:1.8.0_25]

          at java.lang.Class.forName(Class.java:344) [rt.jar:1.8.0_25]

         at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:186) [jboss-ejb-client-2.0.1.Final.jar:2.0.1.Final]

          ... 32 more

       

      In short when a class in the war file of second ear tries to lookup an EJB its complaining about not finding the remote interface class eventhough it is present in the ear's lib directory inside a jar. Please note that although the same class in the war is able to access some other class from the same jar in the lib directory that has the EJB remote interfaces. This appears weird to me.

       

      Does anyone has any insight here for me. I would be very thankful to you for any guidance that you may provide here.

       

      I tried putting the jar containing the ejb remote interfaces at various places like directly under ear rather than putting in the ear's lib. I also tried putting it in the war's lib directory but all of those options made no difference.

       

      And I have checked it multiple time that the remote interface being looked for here is present in that jar.

       

      Thanks

        • 1. Re: Wildfly wildfly-8.1.0.Final remote ejb invocation and class loading issue
          amitsoprna Newbie

          Any help here? I have seen various threads on class-loading issues but somehow not able to infer the solution for the problem that I am facing ?

           

          Thanks !!

          • 2. Re: Wildfly wildfly-8.1.0.Final remote ejb invocation and class loading issue
            amitsoprna Newbie

            Oki I found my mistake it was wrong lookup name that the code was forming, it was using simple name for the interface whereas it should have used the fully qualified name of the interface. But now I am getting following exception:

             

            5:25:12,512 INFO  [org.jboss.ejb.client] (MSC service thread 1-5) JBoss EJB Client version 2.0.1.Final

            ....: java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:myappwithstatelessejbs, moduleName:appwithstatelessejbs, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@649d9512

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

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

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

                at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:253) [jboss-ejb-client-2.0.1.Final.jar:2.0.1.Final]

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

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

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

            ......................................................................

                at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:541) [spring.jar:2.5]

                at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:515) [spring.jar:2.5]

                at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348) [spring.jar:2.5]

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

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

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

                at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126) [spring-webmvc.jar:2.5]

                at javax.servlet.GenericServlet.init(GenericServlet.java:244) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]

                at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:214) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]

                at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:119) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]

                at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:505) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]

                at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:88)

                at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_25]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_25]

                at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_25]