4 Replies Latest reply on May 28, 2014 12:51 PM by boldt

    WildFly 8: Remote EJB-lookup fails on first deploy

    boldt

      Dear all,

       

      I created my first WildFly appliaction and I found a weird behaviour (bug?). I tried to create a MWE, which is available here [1]. This repository contains 4 small maven-projects:

       

      (1) hello-commons: Contains (a) an Interface, (b) a class wrapping a JNDI-remote lookup and (c) the corresponding implementation of the interface which calls the Remote EJB (with the JNDI-remote lookup) (a local EJB)

      (2) hello-remote: Contains just the remote EJB

      (3) hello-client: Contains a simple class with a main method, which calls the Remote EJB (with the JNDI-remote lookup)

      (4) hello: Contains a servelt, which uses the EJB

       

      The README in the project above explains my setup, where I deployed the hello and the hello-remote project in the same AS. Afterwards I ran the hello-client (in Eclipse) where I see the message from the remote EJB. As soon I open the URL in the browser, I am getting a "javax.servlet.ServletException: UT010013: Could not instantiate de.dennis_boldt.HelloServlet". The whole log is available here [2]. This expetion is thrown, because the lookup in [3] fails; even this class is uses by both, the EJB and the client. If I redeploy the hello project (see README), the servlet works as expected.

       

      What am I doing wrong?

       

      Kind regards,

      Dennis

       

      [1] https://github.com/boldt/wildfly8-helloworld

      [2] http://paste.dennis-boldt.de/2014/wildfly-log

      [3] https://github.com/boldt/wildfly8-helloworld/blob/master/hello-commons/src/main/java/de/dennis_boldt/HelloJndi.java

        • 1. Re: WildFly 8: Remote EJB-lookup fails on first deploy
          jaikiran

          Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "org.jboss.ejb.client.EJBClientContext.registerConnection(Lorg/jboss/remoting3/Connection;)V" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/jboss/naming/remote/client/ejb/RemoteNamingStoreEJBClientHandler, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, org/jboss/ejb/client/EJBClientContext, have different Class objects for the type oss/remoting3/Connection;)V used in the signature
              at org.jboss.naming.remote.client.ejb.RemoteNamingStoreEJBClientHandler.associate(RemoteNamingStoreEJBClientHandler.java:78) [jboss-remote-naming-2.0.0.Final.jar:2.0.0.Final]
              at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.<init>(RemoteNamingStoreV1.java:71) [jboss-remote-naming-2.0.0.Final.jar:2.0.0.Final]
              at org.jboss.naming.remote.protocol.v1.VersionOne.getRemoteNamingStore(VersionOne.java:50) [jboss-remote-naming-2.0.0.Final.jar:2.0.0.Final]
              at org.jboss.naming.remote.protocol.Versions.getRemoteNamingStore(Versions.java:55) [jboss-remote-naming-2.0.0.Final.jar:2.0.0.Final]
              at org.jboss.naming.remote.client.RemoteContextFactory.createVersionedStore(RemoteContextFactory.java:73) [jboss-remote-naming-2.0.0.Final.jar:2.0.0.Final]
              at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:202) [jboss-remote-naming-2.0.0.Final.jar:2.0.0.Final]
              at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149) [jboss-remote-naming-2.0.0.Final.jar:2.0.0.Final]
              at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130) [jboss-remote-naming-2.0.0.Final.jar:2.0.0.Final]
              at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272) [jboss-remote-naming-2.0.0.Final.jar:2.0.0.Final]
              at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79) [jboss-remote-naming-2.0.0.Final.jar:2.0.0.Final]
              at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83) [jboss-remote-naming-2.0.0.Final.jar:2.0.0.Final]
              at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_25]
              at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_25]
              at de.dennis_boldt.HelloJndi.getHello(HelloJndi.java:28) [hello-commons-0.0.1-SNAPSHOT.jar:]
              at de.dennis_boldt.HelloImpl.<init>(HelloImpl.java:18) [hello-commons-0.0.1-SNAPSHOT.jar:]
              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.7.0_25]
              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [rt.jar:1.7.0_25]
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.7.0_25]
              at java.lang.reflect.Constructor.newInstance(Constructor.java:526) [rt.jar:1.7.0_25]
              at org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:110) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
              ... 117 more

          Are you packaging any JBoss specific jar files like the ones containing the org.jboss.ejb.client or org.jboss.remoting3 packages? If yes, remove them from your deployed application packaging.

          • 2. Re: WildFly 8: Remote EJB-lookup fails on first deploy
            boldt

            Refering to [1], I need to set this property:

             

              jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

             

            This class is shipped with the wildfly-ejb-client-bom. You can have a look into my packed wars here [2].

             

            [1] https://docs.jboss.org/author/display/WFLY8/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project

            [2] https://github.com/boldt/wildfly8-helloworld-war

            • 3. Re: WildFly 8: Remote EJB-lookup fails on first deploy
              wdfink

              You should not set

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

              this is for the ejb-client approach which is recommended by the way.


              Also you should not pack any server side jar's into your war application (like xnio* jboss* jars).

              With maven you need to check that all projects which set the dependency include scope=provided

              • 4. Re: WildFly 8: Remote EJB-lookup fails on first deploy
                boldt

                I removed the property org.jboss.ejb.client.naming [1]. I siill have the same issue; the hello-project just works on the second deploy.

                 

                I also exchanged the wildfly-ejb-client-bom with the shipped jboss-client.jar [2]. For this, I ran th following within the {WIDFLY}/bin/client/ directory:

                 

                mvn install:install-file -Dfile=jboss-client.jar -DgroupId=de.dennis_boldt -DartifactId=jboss-client -Dversion=1.0.0 -Dpackaging=jar

                 

                Also the same issue; the hello-project just works on the second deploy. Btw: Is there any differece between the wildfly-ejb-client-bom and the shipped jboss-client.jar?

                 

                I also tried the approach with the property-files; I can't get this work at all.

                 

                Maybe someone can provide me a small fix (e.g., a github pull request?). Probably it is just a small fix, which cost me already plenty of time


                [1] https://github.com/boldt/wildfly8-helloworld/commit/6c17a1dac60e3255a6965768705b70f5d6d8e462

                [2] https://github.com/boldt/wildfly8-helloworld/commits/jboss-client