2 Replies Latest reply on Jun 3, 2015 10:43 AM by Sergiu Pienar

    Incompatible class returned by EJB remote call

    Sergiu Pienar Apprentice

      Using WildFly 8.2.0 Final.

       

      I have an EAR that holds and a jar file, and 2 wars. The jar file contains the EJBs that do the business logic.

      I also have a WAR outside the EAR that is doing remote calls to the ejb.jar inside the EAR.

       

      The structure would be:

       

      EAR ----

                    --- ejb.jar

                    --- war1.war

                    --- war2.war

       

      clientWAR ----

       

      The call sequence would be: 1.) clientWar -> does a remote call to and EJB located in ejb.jar inside the EAR

                                                2.) The called EJB returns a configuration class

                                                3.) The client should be able to further use the configuration class

       

      The problem is that when I'm trying to do (inside the client) something like ConfigClass (returned by EAR) instanceof ConfigClass (which is known by the WAR) this always returns false, leaving me to believe that the classes are somehow incompatbile.

      The config classes belong in the WAR but they are loaded dynamically into the EAR (as separate jars) using Groovy.

       

      The same process works perfectly fine when I`m returning a byte[] from the ejb.jar and on the client war I`m deserializing it.

        • 1. Re: Incompatible class returned by EJB remote call
          David Lloyd Master

          You might be performing a local invocation instead of a remote invocation.  Make sure you really are getting the remote interface when you make the call.  Also make sure the client WAR has copies of all the classes involved in the invocation.  If it doesn't, the invocation logic may fall back to deserializing a version of a class from the EAR, which might link against a class that is defined in both the EAR and the WAR (resulting in surprise ClassCastExceptions).

          • 2. Re: Incompatible class returned by EJB remote call
            Sergiu Pienar Apprentice

            Hi, thanks for your input.

             

            1.) How can I check that I really am getting the remote view ? The current lookup for the remote interface is:

             

            lookup(null, "java:jboss/exported/myEAR/all-ejbs/RuleExecutorBean!com.rule.RuleExecutorRemote", com.rule.RuleExecutorRemote.class)
            
            

             

            which returns Proxy for remote EJB StatelessEJBLocator{appName='myEAR', moduleName='all-ejbs', distinctName='', beanName='RuleExecutorBean', view='interface com.rule.RuleExecutorRemote'}

             

            could it be that since I'm not passing any HashTable as the 1st argument to the lookup it will fallback to a local view ?

             

            2.) I checked and the client war does have copies of all the classes involved under WEB-INF/classes.

            Also, I've tried the same thing from a standalone app, calling the bean and checking for ConfigClass (returned one) instanceof ConfigClass and it all worked ok. The standalone app is using the getRemote(final Hashtable environment).