2 Replies Latest reply on Feb 22, 2007 1:23 PM by cuoz

    Custom LoginModule and ClassCastException

    edek234

      Hi,

      I wrote my own login module for operating on user accounts as beans.
      After JBoss restart everything is fine, but after I reload my EAR the following appears

      java.lang.ClassCastException: $Proxy94
       at ms.gpw.login.impl.LoginPasswordLoginModule.login(LoginPasswordLoginModule.java:70)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
       at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
       at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
       at java.security.AccessController.doPrivileged(Native Method)
       at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
       at javax.security.auth.login.LoginContext.login(LoginContext.java:579)
       at ms.gpw.login.servlet.DoLoginServlet.doPost(DoLoginServlet.java:46)
       ...
      


      This is during obtaining from JNDI a local stateless session bean interface.
      The login modules are in server/default/lib in a .jar.
      Everything else is packacked in the EAR (so far a few servlets in a WAR and EJB3 .jar
      containing account data beans).

      Am I doing something wrong? Is it a bug or is it a feature?

      Thanks,
      Edek

        • 1. Re: Custom LoginModule and ClassCastException

          Hi edek5472,

          I had the same problem... I think classes for your bean are loaded from different resources (one in .../lib and one out of the ear-file). Two instances of one type are different, if they were loaded through different class-loaders (e.g. different resources).

          I'm sorry, but I have no solution found yet...

          Hope that helps...

          Carsten

          • 2. Re: Custom LoginModule and ClassCastException

            While I haven't done this type of stuff in a login module, I generally find I need to use scoped class loading by specifying loader-repository elements in the jboss-app.xml file to keep things separated. With scoped class loaders, I am able to hot-deploy any parts of my app without having problems in the other parts.

            Hope that helps,
            Gary.