2 Replies Latest reply on May 9, 2013 7:09 PM by hypino

    AS 7.1.1.Final Remote Look-up Class Loader Issue

    hypino

      Hi, I'm new here so if this question isn't well formatted or does'nt give enough information I apologize in advance.


      The issue I am having with my application has to do with a class that is being instantiated across classloaders, due to classloader isolation in JBoss

       

      After I look-up a remote bean (that happens to be on the same server, however a different .ear file), I make a method call to return a List of Id's.

       

      eg.

      {code}List<Id> ids = (List<Id>) remote.getIds();{code}

       

      The cast here works fine, as expected. However, when I go to loop through the Id's, this is where the ClassCastException arises.

       

      eg.

      {code}
      for (Id id : ids)
      \{
           ...
      \}

      {code}

       

      Causes this:

       

      {code}

      09:02:44,238 ERROR [com.owfg.banner.bean.BannerBean] (EJB default - 2)   An unexpected error has occurred while getting user profile: : java.lang.ClassCastException: com.companyname.interfaces.data.Id cannot be cas

      t to com.companyname.interfaces.data.Id

      {code}

       

      A few searches have revealed that the problem could be that the Id is being created in the other .ear application (that this application is remoting to) and then trying to be cast to the a different instantiation of the class in the local .ear, the root problem being two different classloaders.

       

      Assuming this being the problem, how do I work around this? One such solution I've found is that I should take the API module out of the remote .ear (as well as the local ear) and place the code in a common module and have both applications put a "Dependencies" reference to it in their respective manifest files. Would this be the way to go about it? I've not found any clear documentation on how this is done.

       

      Thanks in advance.

        • 1. Re: AS 7.1.1.Final Remote Look-up Class Loader Issue
          hypino

          Update:

           

          I've attempted to make the API a global module, but this didn't work. In retrospect this is pretty obvious; just because it's a global module doesn't mean it's going to be loaded by the same class loader.

           

          Or maybe I did something wrong. Regardless a global module is not the best practice, I'd rather not do it this way.

          • 2. Re: AS 7.1.1.Final Remote Look-up Class Loader Issue
            hypino

            Fixed this issue.

            Turns out it was indeed because of the class loading issue. It was resolved when I changed this property in standalone-full.xml:

             

            {code}<iiop enable-by-default="false" use-qualified-name="false"/>{code}

             

            Changed it from false to true. Turns out I made a mistake above when I said making it a global module wouldn't work, I just configured something incorrectly, it totally works.