4 Replies Latest reply on May 5, 2006 1:18 PM by jesse_sweetland

    JAAS LoginModule NoClassDefFoundError

    maniarkm

      Hi,

      I have created a custom LoginModule called PasswordLoginModule and I have entered it in the login-config.xml

      <application-policy name="ServiceLogin">

      <login-module code="com.nielsen.book.admin.security.PasswordLoginModule" flag="required">
      </login-module>

      </application-policy>

      I have added the policy file to the commandline options when starting JBoss in the run.bat.

      I am using the below code to authenticate a user.

      public boolean authenticate(){
      try {
      ctx = new LoginContext("ServiceLogin", new SearchCallbackHandler(request));
      }
      catch(LoginException le) {
      System.err.println("LoginContext cannot be created. "+ le.getMessage());
      return false;
      }
      catch(SecurityException se) {
      System.err.println("LoginContext cannot be created. "+ se.getMessage());
      return false;
      }
      try {
      ctx.login();
      }
      catch(LoginException le) {
      System.out.println("Authentication failed. " + le.getMessage());
      return false;
      }
      System.out.println("Authentication succeeded.");

      return true;
      }

      However, the LoginContext throws a NoClassDefFoundError.

      I have the class in a library sitting on default/lib.

      I am stumped as to why the LoginContext can't instantiate my LoginModule.

      Any ideas?

      Mark Britten

        • 1. Re: JAAS LoginModule NoClassDefFoundError
          jaikiran

          Check out the contents of your jar file using:

          jar -tf yourJar.jar

          Post the output

          • 2. Re: JAAS LoginModule NoClassDefFoundError
            maniarkm

            The class file is in the jar. I have made sure of that.

            However, I am confused. How can I access other files in the same jar but not find this one?

            • 3. Re: JAAS LoginModule NoClassDefFoundError
              jesse_sweetland

              This is an old thread, but I just encountered the same issue and I've found something that might help.

              My login module calls a web service to authenticate. I put the JAR for my LoginModule in default/lib and added an entry in login-config.xml for the security domain used by my web application. The LoginModule class itself is found and instantiated, but the web service classes through a NoClassDefFoundError. I added some debug statements and noticed that the thread context class loader is WebappClassLoader. I tried putting my JAR in the WEB-INF/lib folder of my web application, and got past the original error, but failed with a NoClassDefFoundError on one of the JAX-RPC classes (JAX-RPC libs are in default/lib). I suspect that if I also copied the JAX-RPC JARs into WEB-INF/lib it would actually work, but this isn't a very elegant solution (especially with multiple web applications).

              The Class Loading Use Case Wiki has a note at the bottom about needing to add specific use cases for WARs, since the WebappClassLoader is involved, and mentioned settings in jboss-web.xml that might influence how the WebappClassLoader delegates to JBoss's UCL. I couldn't find any details on those settings . . . does anyone have any ideas?

              Thanks,

              - Jesse

              • 4. Re: JAAS LoginModule NoClassDefFoundError
                jesse_sweetland

                Followup:

                I copied the JAX-RPC stuff into WEB-INF/lib and the LoginModule works, but now I get linkage errors all over the place in the web application proper (specifically from JBPM stuff, which is deployed as a SAR in default/deploy).

                Short of copying the world into WEB-INF/lib, is there any way to resolve this class loading issue?