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

    AS 7.1.1.Final Remote Look-up Class Loader Issue

    Tyler Allison Newbie

      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.



      {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.



      for (Id id : ids)



      Causes this:



      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



      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.