0 Replies Latest reply on Feb 2, 2010 6:18 PM by simulex inc

    Problem in sar and ear class loading

    simulex inc Newbie

      I have ejb[UserBean] which saves the user details to the database. The EJB project is dependent on hibernate and I had to provide its own class-loader in jboss-web.xml. [UserData.ear]


      I want to invoke this bean when the user logs in to the JBoss Portal.For this I created a Listener and registered it using jboss-service.xml. The class (UserLoginEventListener) implements PortalEventListener and listens for the UserAuthenticationEvent. I have the jar for the ejb in the lib folder sar/lib. [LoginEvent.sar]


      When I try to invoke the ejb from UserLoginEventListener, I get the ClassCastException. I understand this is because the UserBean is loaded by two class-loaders(one from the .ear and other from .sar) . If I try to remove the ejb jar (expecting that it will find the bean class from ear loader) I get NoClassDefFoundError.


      In the jboss-service.xml(for .sar), if I specify class-loader, then it fails to deploy the sar as now it doenst find JBossServiceModelMBean class which is required to register the service.


      Is there a way that I can share the class-loader for .sar and for .ear so that the ejb class will be loaded only once avoiding ClassCastException? Or is there a better way to do it?