1 2 Previous Next 17 Replies Latest reply on Feb 14, 2018 7:05 AM by Thomas Isaksen

    Module problem again.

    Thomas Isaksen Newbie

      I can't seem to wrap my head around modules.

       

      Working on an HttpHandler which has a module.xml. In addition I have created several modules which are working fine but now I have defined two more which are "org.springframwork" and "org.apache.ignite" (see attached module defs.)

       

      The main module is defined under D:\wildfly-10.1.0.Final\modules

           \no\toyota\gatekeeper\main

      The two other modules are defined under

      D:\wildfly-10.1.0.Final\modules\system\layers\base

           \org\apache\ignite\main\

           \org\springframework\main\

       

      The problem now is that I get a ClassNotFoundException from the module "org.wildfly.extension.io:main" on a class in my org.apache.ignite module. But I can't understand why it's not found, my modules are defined correctly under the path given in the exception:

       

       

       

      I have double checked that I have all the required jar files and I am 100% sure not a single file is missing.

       

       

      11:01:41,816 ERROR [io.undertow.request] (default I/O-13) UT005071: Undertow request failed HttpServerExchange{ POST /gatekeeper/credentials/1.0/authenticate request {Postman-Token=[2346d713-9d8b-4f2e-a8dc-5910c852fa8d], Accept=[*/*], cache-control=[no-cache], accept-encoding=[gzip, deflate], User-Agent=[PostmanRuntime/7.1.1], Connection=[keep-alive], Content-Type=[application/json], content-length=[49], Host=[dev.toyota.no:8080]} response {}}: java.lang.RuntimeException: WFLYUT0064: Failed to configure handler class no.toyota.gatekeeper.handler.TokenBouncerHandler

              at org.wildfly.extension.undertow.deployment.ConfiguredHandlerWrapper.wrap(ConfiguredHandlerWrapper.java:78)

              at org.wildfly.extension.undertow.filters.CustomFilterDefinition.createHttpHandler(CustomFilterDefinition.java:100)

              at org.wildfly.extension.undertow.filters.FilterService.createHttpHandler(FilterService.java:57)

              at org.wildfly.extension.undertow.filters.FilterRef.createHttpHandler(FilterRef.java:69)

              at org.wildfly.extension.undertow.LocationService.configureHandlerChain(LocationService.java:104)

              at org.wildfly.extension.undertow.Host.configureRootHandler(Host.java:119)

              at org.wildfly.extension.undertow.Host.getOrCreateRootHandler(Host.java:173)

              at org.wildfly.extension.undertow.Host$HostRootHandler.handleRequest(Host.java:303)

              at io.undertow.server.handlers.NameVirtualHostHandler.handleRequest(NameVirtualHostHandler.java:64)

              at io.undertow.server.handlers.error.SimpleErrorPageHandler.handleRequest(SimpleErrorPageHandler.java:78)

              at io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)

              at io.undertow.server.handlers.ChannelUpgradeHandler.handleRequest(ChannelUpgradeHandler.java:158)

              at io.undertow.server.protocol.http2.Http2UpgradeHandler.handleRequest(Http2UpgradeHandler.java:95)

              at io.undertow.server.handlers.DisallowedMethodsHandler.handleRequest(DisallowedMethodsHandler.java:61)

              at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)

              at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:243)

              at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:134)

              at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:58)

              at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)

              at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)

              at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)

              at org.xnio.nio.WorkerThread.run(WorkerThread.java:567)

      Caused by: java.lang.reflect.InvocationTargetException

              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.wildfly.extension.undertow.deployment.ConfiguredHandlerWrapper.wrap(ConfiguredHandlerWrapper.java:56)

              ... 21 more

      Caused by: class org.apache.ignite.IgniteException: Failed to instantiate Spring XML application context (make sure all classes used in Spring configuration are present at CLASSPATH) [springUrl=file:/D:/apache-ignite-fabric-2.3.0-bin/config/gatekeeper-token-config.xml]

              at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:966)

              at org.apache.ignite.Ignition.start(Ignition.java:350)

              at no.toyota.gatekeeper.ignite.IgniteUtil.getCache(IgniteUtil.java:34)

              at no.toyota.gatekeeper.doorman.ExpressionEngine.<init>(ExpressionEngine.java:33)

              at no.toyota.gatekeeper.handler.TokenBouncerHandler.<init>(TokenBouncerHandler.java:43)

              ... 26 more

      Caused by: class org.apache.ignite.IgniteCheckedException: Failed to instantiate Spring XML application context (make sure all classes used in Spring configuration are present at CLASSPATH) [springUrl=file:/D:/apache-ignite-fabric-2.3.0-bin/config/gatekeeper-token-config.xml]

              at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:387)

              at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:104)

              at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:98)

              at org.apache.ignite.internal.IgnitionEx.loadConfigurations(IgnitionEx.java:673)

              at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:874)

              at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:783)

              at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:653)

              at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:622)

              at org.apache.ignite.Ignition.start(Ignition.java:347)

              ... 29 more

      Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.ignite.configuration.IgniteConfiguration] for bean with name 'ignite.cfg' defined in URL [file:/D:/apache-ignite-fabric-2.3.0-bin/config/gatekeeper-token-config.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.ignite.configuration.IgniteConfiguration from [Module "org.wildfly.extension.io:main" from local module loader @1c2c22f3 (finder: local module finder @18e8568 (roots: D:\wildfly-10.1.0.Final\modules,D:\wildfly-10.1.0.Final\modules\system\layers\base))]

              at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1385)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:641)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:609)

              at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1484)

              at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1007)

              at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:741)

              at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)

              at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)

              at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:381)

              ... 37 more

      Caused by: java.lang.ClassNotFoundException: org.apache.ignite.configuration.IgniteConfiguration from [Module "org.wildfly.extension.io:main" from local module loader @1c2c22f3 (finder: local module finder @18e8568 (roots: D:\wildfly-10.1.0.Final\modules,D:\wildfly-10.1.0.Final\modules\system\layers\base))]

              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)

              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)

              at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)

              at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:401)

              at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1432)

              at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1377)

              ... 45 more

        • 1. Re: Module problem again.
          jaikiran pai Master

          What does the filter definition look like in the standalone/domain xml file? Have you specified the correct value for the "module" attribute in that file? It should point to the module name which has the filter class. The xsd has more details wildfly/wildfly-undertow_3_1.xsd at 10.1.0.Final · wildfly/wildfly · GitHub

          • 2. Re: Module problem again.
            Thomas Isaksen Newbie

            It points to my module correctly: <filter name="tokenBouncerHandler" class-name="no.toyota.gatekeeper.handler.TokenBouncerHandler" module="no.toyota.gatekeeper"/>

            The filter is running fine but the ClassNotFoundException issue happened at the moment I introduced the org.apache.ignite and org.springframework modules.

            • 3. Re: Module problem again.
              Vladimir Zhuravlevich Newbie

              Hi,

               

              Looks like you have to add ignite as a dependency in the spring module, because in your case spring_module.xml doesn't know about ignite.

              Usually it would be better to split all jar/libs to modules and go through all dependencies (GitHub - zhurlik/gradle-jboss-modules-plugin: This is a plugin for gradle allows to create modules to be able to use the…  can be helpful).

               

              Thanks,

              Vlad

              • 4. Re: Module problem again.
                Thomas Isaksen Newbie

                Hi

                 

                I tried adding Ignite as a dependency but I am getting the exact same exception either way.

                 

                However, I did try to put a reference to my Ignite module in the module org.wildfly.extension.io and the Ignite classes are found now. (Still getting other ClassNotFound issues but anyway)

                 

                So I wonder why I had to add it to this wildfly module, obviously I have no clue but maybe you do ?

                 

                 

                 

                Although I do not use Gradle (yet) I will check out your project, it looks interesting for sure.

                 

                 

                 

                ./t

                • 5. Re: Module problem again.
                  Vladimir Zhuravlevich Newbie

                  If you can simplify/extract and send me your modules with jar files I can figure out how to fix it.

                  I just need your libs (or versions if they are from public maven repo) and a simple class that you would like to up

                   

                  thanks,

                  vlad

                  • 6. Re: Module problem again.
                    Thomas Isaksen Newbie

                    Thanks a lot. I will do that

                    • 7. Re: Module problem again.
                      Thomas Isaksen Newbie

                      Hi Vladimir

                       

                      I have created a simplified version of my HttpHandler. Download here IgniteHandler.zip - Google Drive

                      I have created a modules folder with two subfolders 'no' and 'system' where I have placed my HttpHandler called IgniteHandler and three other modules, org.apache.ignite, org.springframework and javax.cache

                       

                      I don't think you will have to install Apache Ignite to work on the classloading issue but if you do, just download version 2.3 from ignite.apache.org, unzip and set IGNITE_HOME env. variable then start with $IGNITE_HOME/bin/ignite.sh.

                      My HttpHandler is set up to use default ignite config so there should be no issues.

                       

                      I suppose you know very well how to configure a filter but in standalone.xml I have the following config:

                       

                           <filter-ref name="igniteHandler" priority="100"/>

                       

                           <filter name="igniteHandler" class-name="no.toyota.gatekeeper.handler.IgniteHandler" module="no.toyota.gatekeeper:simplified"/>

                       

                      Let me know if there are any issues with this version.

                       

                      Thanks !

                      • 8. Re: Module problem again.
                        Vladimir Zhuravlevich Newbie

                        Hi,

                         

                        I have started to up your modules and ran into:

                         

                        at org.xnio.nio.WorkerThread.run(WorkerThread.java:567)

                        Caused by: class org.apache.ignite.IgniteCheckedException: Spring XML configuration path is invalid: /config/gatekeeper-token-config.xml. Note that this path should be either absolute or a relative local file system path, relative to META-INF in classpath or valid URL to IGNITE_HOME.

                        at org.apache.ignite.internal.util.IgniteUtils.resolveSpringUrl(IgniteUtils.java:3745)

                        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:781)

                        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:653)

                        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:622)

                        at org.apache.ignite.Ignition.start(Ignition.java:347)

                        ... 19 more

                        Caused by: java.net.MalformedURLException: no protocol: /config/gatekeeper-token-config.xml

                        at java.net.URL.<init>(URL.java:586)

                        at java.net.URL.<init>(URL.java:483)

                        at java.net.URL.<init>(URL.java:432)

                        at org.apache.ignite.internal.util.IgniteUtils.resolveSpringUrl(IgniteUtils.java:3736)

                         

                         

                        Looks like I need /config/gatekeeper-token-config.xml

                         

                        Thanks,

                        Vlad

                        • 9. Re: Module problem again.
                          Thomas Isaksen Newbie

                          My bad. File is attached.

                           

                          It is looking relative to $IGNITE_HOME

                          • 10. Re: Module problem again.
                            Vladimir Zhuravlevich Newbie

                            As a hot fix add:

                            <module name="org.apache.ignite" optional="true"/>

                            into wildfly-10.1.0.Final/modules/system/layers/base/org/wildfly/extension/io/main/module.xml

                             

                            19:52:52,250 INFO  [org.apache.ignite.internal.IgniteKernal] (default I/O-5)

                             

                             

                            >>>    __________  ________________ 

                            >>>   /  _/ ___/ |/ /  _/_  __/ __/ 

                            >>>  _/ // (7 7    // /  / / / _/   

                            >>> /___/\___/_/|_/___/ /_/ /___/  

                            >>>

                            >>> ver. 2.3.0#20171028-sha1:8add7fd5

                            >>> 2017 Copyright(C) Apache Software Foundation

                            >>>

                            >>> Ignite documentation: http://ignite.apache.org

                             

                             

                            19:52:52,251 INFO  [stdout] (default I/O-5) [19:52:52]    __________  ________________

                            19:52:52,251 INFO  [stdout] (default I/O-5) [19:52:52]   /  _/ ___/ |/ /  _/_  __/ __/

                            19:52:52,251 INFO  [stdout] (default I/O-5) [19:52:52]  _/ // (7 7    // /  / / / _/  

                            19:52:52,251 INFO  [stdout] (default I/O-5) [19:52:52] /___/\___/_/|_/___/ /_/ /___/ 

                            19:52:52,251 INFO  [stdout] (default I/O-5) [19:52:52]

                            19:52:52,251 INFO  [stdout] (default I/O-5) [19:52:52] ver. 2.3.0#20171028-sha1:8add7fd5

                            19:52:52,251 INFO  [stdout] (default I/O-5) [19:52:52] 2017 Copyright(C) Apache Software Foundation

                            19:52:52,252 INFO  [stdout] (default I/O-5) [19:52:52]

                            19:52:52,252 INFO  [stdout] (default I/O-5) [19:52:52] Ignite documentation: http://ignite.apache.org

                            19:52:52,252 INFO  [stdout] (default I/O-5) [19:52:52]

                            19:52:52,252 INFO  [stdout] (default I/O-5) [19:52:52] Quiet mode.

                            19:52:52,252 INFO  [stdout] (default I/O-5) [19:52:52]   ^-- To see **FULL** console log here add -DIGNITE_QUIET=false or "-v" to ignite.{sh|bat}

                            19:52:52,253 INFO  [stdout] (default I/O-5) [19:52:52]

                            19:52:52,253 INFO  [org.apache.ignite.internal.IgniteKernal] (default I/O-5) Config URL: file:/config/gatekeeper-token-config.xml

                            19:52:52,253 INFO  [org.apache.ignite.internal.IgniteKernal] (default I/O-5) Daemon mode: off

                            19:52:52,253 INFO  [stdout] (default I/O-5) [19:52:52] OS: Linux 4.13.0-32-generic amd64

                            19:52:52,253 INFO  [org.apache.ignite.internal.IgniteKernal] (default I/O-5) OS: Linux 4.13.0-32-generic amd64

                            19:52:52,253 INFO  [org.apache.ignite.internal.IgniteKernal] (default I/O-5) OS user: zhurlik

                            19:52:52,253 INFO  [org.apache.ignite.internal.IgniteKernal] (default I/O-5) PID: 4742

                            19:52:52,254 INFO  [stdout] (default I/O-5) [19:52:52] VM information: Java(TM) SE Runtime Environment 1.8.0_60-b27 Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 25.60-b23

                            19:52:52,254 INFO  [org.apache.ignite.internal.IgniteKernal] (default I/O-5) Language runtime: Java Platform API Specification ver. 1.8

                            19:52:52,254 INFO  [org.apache.ignite.internal.IgniteKernal] (default I/O-5) VM information: Java(TM) SE Runtime Environment 1.8.0_60-b27 Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 25.60-b23

                            19:52:52,255 INFO  [org.apache.ignite.internal.IgniteKernal] (default I/O-5) VM total memory: 3.5GB

                            19:52:52,255 INFO  [org.apache.ignite.internal.IgniteKernal] (default I/O-5) Remote Management [restart: off, REST: off, JMX (remote: off)]

                            19:52:52,257 INFO  [org.apache.ignite.internal.IgniteKernal] (default I/O-5) IGNITE_HOME=/home/zhurlik/programs/apache-ignite-fabric-2.3.0-bin

                            19:52:52,257 INFO  [org.apache.ignite.internal.IgniteKernal] (default I/O-5) VM arguments: [-D[Standalone], -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:46791,suspend=y,server=n, -javaagent:/opt/idea/lib/rt/debugger-agent.jar=/tmp/capture699.props, -javaagent:/opt/idea/plugins/Groovy/lib/agent/gragent.jar, -Dorg.jboss.boot.log.file=/home/zhurlik/programs/wildfly-10.1.0.Final/standalone/log/server.log, -Dlogging.configuration=file:/home/zhurlik/programs/wildfly-10.1.0.Final/standalone/configuration/logging.properties]

                            19:52:52,257 INFO  [org.apache.ignite.internal.IgniteKernal] (default I/O-5) System cache's DataRegion size is configured to 40 MB. Use DataStorageConfiguration.systemCacheMemorySize property to change the setting.

                            19:52:52,257 INFO  [org.apache.ignite.internal.IgniteKernal] (default I/O-5) Configured caches [in 'sysMemPlc' dataRegion: ['ignite-sys-cache'], in 'default' dataRegion: ['tokenCache*', 'credentialsCache*', 'skipCache*', 'testCache*']]

                             

                             

                            I think it can be potential fixed after creating separate modules for all jars, but it's a little bit longer way

                             

                            Re log4j issue. Wildfly doesn't have:

                            • log4j-api-2.7.jar
                            • log4j-core-2.7.jar

                             

                            I am suggesting to rewrite to use slf4j

                             

                            import org.apache.logging.log4j.LogManager;

                            import org.apache.logging.log4j.Logger;

                             

                            public class IgniteHandler implements HttpHandler {

                            private static final Logger LOG = LogManager.getLogger(IgniteHandler.class);

                             

                            Thanks,

                            Vlad

                            • 11. Re: Module problem again.
                              Thomas Isaksen Newbie

                              Thanks! Do you think it's a bug or is there some other reason why it isn't working ?

                               

                              Anyway, I think I will look for a maven plugin to split everything up into wildfly modules and if it one doesn't exist, I'll write one.

                               

                              I will rewrite logging to use slf4j

                              • 12. Re: Module problem again.
                                Vladimir Zhuravlevich Newbie

                                I don't know is it bug or not, but it looks strange that module org.wildfly.extension.io wants some dependencies from a module that is registered as a filter for undertow.

                                • 13. Re: Module problem again.
                                  jaikiran pai Master

                                  It looks like the libraries you are using in the (constructor) of your filter rely on thread context classloader and I'm guessing that there's a bug (or undefined behaviour) where the context classloader isn't set to the module classloader which loaded your custom handler. As a workaround can you change the code in your no.toyota.gatekeeper.handler.TokenBouncerHandler's constructor to something like:

                                   

                                  public TokenBouncerHandler(...) {
                                   final ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
                                  try {
                                      Thread.currentThread().setContextClassLoader(TokenBouncerHandler.class.getClassLoader());
                                      // rest of your existing code goes here
                                      ....
                                  } finally {
                                      Thread.currentThread().setContextClassLoader(oldCL);
                                  }
                                  
                                  
                                  1 of 1 people found this helpful
                                  • 14. Re: Module problem again.
                                    Thomas Isaksen Newbie

                                    That was it! Thank you so much!

                                    1 2 Previous Next