0 Replies Latest reply on May 19, 2018 10:07 AM by Hlulani Mhlongo

    Wildfly Swarm - JASPIC Module not working (Classloader Issue)

    Hlulani Mhlongo Newbie

      BTW: this works perfectly on normal Wildfly

      I've been banging my head against the wall with this one the custom jboss module (SAM) does not seem to load correctly, even though I've defined the module correctly

       

      
      <module xmlns="urn:jboss:module:1.6" name="com.company.sam">
        <resources>
          <artifact name="com.company:company-sam:${project.version}"/>
          <artifact name="com.auth0:java-jwt:${java-jwt.version}"/>
        </resources>
        <dependencies>
          <module name="com.fasterxml.jackson.core.jackson-annotations"/>
          <module name="com.fasterxml.jackson.core.jackson-core"/>
          <module name="com.fasterxml.jackson.core.jackson-databind"/>
          <module name="org.apache.commons.codec"/>
        </dependencies>
      </module>
      
      
      
      

       

      I've also defined the project-defaults.yaml as follows:

      swarm:
          security:
              security-domains:
                  company-sd:
                      jaspi-authentication:
                          auth-modules:
                              company-auth:
                                  code: com.company.security.auth.CompanyServerAuthModule
                                  flag: required
                                  module: com.company.sam
                                  module-options:
                                      algorithm: RSA
                                      public.key: blahblahblahblahblah

       

      I'm still a bit new to wildfly swarm and are trying  to migrate some of my code to use Wildfly-Swarm, instructions to replicate can be found here GitHub - mhlulani/jaspic-module at 0.0.1,

      Below is the error I get:

       

      2018-05-18 23:08:12,631 ERROR [io.undertow.request] (default task-6) UT005023: Exception handling request to /company-service/api/customer/list: java.lang.NoClassDefFoundError: Failed to link com/company/security/auth/CompanyServerAuthModule (Module "com.company.sam" from BootModuleLoader@50caa560 for finders [BootstrapClasspathModuleFinder, BootstrapModuleFinder(org.wildfly.swarm.bootstrap), ClasspathModuleFinder, ContainerModuleFinder(swarm.container), ApplicationModuleFinder(swarm.application), org.wildfly.swarm.bootstrap.modules.DynamicModuleFinder@2a266d09]): javax/security/auth/message/module/ServerAuthModule
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
      at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
      at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:77)
      at org.jboss.modules.Module.loadModuleClass(Module.java:713)
      at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400)
      at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
      at org.jboss.as.security.plugins.ModuleClassLoaderLocator$CombinedClassLoader.loadClass(ModuleClassLoaderLocator.java:92)
      at org.jboss.security.auth.message.config.SecurityActions$3.run(SecurityActions.java:78)
      at org.jboss.security.auth.message.config.SecurityActions$3.run(SecurityActions.java:69)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.jboss.security.auth.message.config.SecurityActions.loadClass(SecurityActions.java:68)
      at org.jboss.security.auth.message.config.JBossServerAuthConfig.createSAM(JBossServerAuthConfig.java:243)
      at org.jboss.security.auth.message.config.JBossServerAuthConfig.getAuthContext(JBossServerAuthConfig.java:178)
      at org.jboss.security.plugins.auth.JASPIServerAuthenticationManager.secureResponse(JASPIServerAuthenticationManager.java:158)
      at org.wildfly.extension.undertow.security.jaspi.JASPICSecureResponseHandler.handleRequest(JASPICSecureResponseHandler.java:57)
      at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
      at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
      at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
      at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
      at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
      at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
      at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
      at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
      at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
      at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
      at io.undertow.server.Connectors.executeRootHandler(Connectors.java:326)
      at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:812)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)

       

      Any feedback is appreciated, if any more information is required please let me know in the comments or tweeter (@mhlulani)

      thank you