3 Replies Latest reply on Jul 1, 2017 3:33 PM by James Perkins

    ClassNotFoundException in Module - How to reference javax.json module?

    Thomas Isaksen Newbie

      I have written a HttpHandler which is defined as a module. Everything works fine but when I try to use JSON I get a ClassNotFoundException (stacktrace below)

      I'm new to WildFly so I don't fully understand the module system yet so please bear with me.

       

      Along with module.xml I have log4j-api-2.7.jar, log4j-core-2.7.jar, log4j-web-2.7.jar and my handler classes in gatekeeper-1.0-SNAPSHOT-wildfly.jar

      My module.xml is as follows:

       

      <module xmlns="urn:jboss:module:1.3" name="no.company.gatekeeper">

          <resources>

              <resource-root path="gatekeeper-1.0-SNAPSHOT-wildfly.jar"/>

              <!-- hack to make things work with log4j  since the module org.apache.logging.log4j.core below is not working -->

              <resource-root path="log4j-api-2.7.jar"/>

              <resource-root path="log4j-core-2.7.jar"/>

          </resources>

          <dependencies>

              <module name="javax.api"/>

              <module name="io.undertow.core"/>

              <module name="org.slf4j"/>

              <!-- not really working -->

              <!--<module name="org.apache.logging.log4j.core"/>-->

          </dependencies>

      </module>

       

      Is there a javax.json module in WildFly and how do I reference it ?

       

       

      The StackTrace:

       

      [Server:server-one]     at no.company.gatekeeper.handler.BouncerHandler.handleRequest(BouncerHandler.java:95)

      [Server:server-one]     at io.undertow.server.handlers.SetHeaderHandler.handleRequest(SetHeaderHandler.java:90)

      [Server:server-one]     at io.undertow.server.handlers.SetHeaderHandler.handleRequest(SetHeaderHandler.java:90)

      [Server:server-one]     at org.wildfly.extension.undertow.Host$HostRootHandler.handleRequest(Host.java:303)

      [Server:server-one]     at io.undertow.server.handlers.NameVirtualHostHandler.handleRequest(NameVirtualHostHandler.java:54)

      [Server:server-one]     at io.undertow.server.handlers.error.SimpleErrorPageHandler.handleRequest(SimpleErrorPageHandler.java:78)

      [Server:server-one]     at io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)

      [Server:server-one]     at io.undertow.server.handlers.ChannelUpgradeHandler.handleRequest(ChannelUpgradeHandler.java:158)

      [Server:server-one]     at io.undertow.server.protocol.http2.Http2UpgradeHandler.handleRequest(Http2UpgradeHandler.java:95)

      [Server:server-one]     at io.undertow.server.handlers.DisallowedMethodsHandler.handleRequest(DisallowedMethodsHandler.java:61)

      [Server:server-one]     at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)

      [Server:server-one]     at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:243)

      [Server:server-one]     at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:134)

      [Server:server-one]     at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:58)

      [Server:server-one]     at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)

      [Server:server-one]     at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)

      [Server:server-one]     at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)

      [Server:server-one]     at org.xnio.nio.WorkerThread.run(WorkerThread.java:567)

      [Server:server-one] Caused by: java.lang.ClassNotFoundException: javax.json.Json from [Module "no.company.gatekeeper:main" from local module loader @629f0666 (finder: local module finder @1bc6a36e (roots: /app/wildfly/wildfly-10.1.0.Final/modules,/app/wildfly/wildfly-10.1.0.Final/modules/system/layers/base))]

      [Server:server-one]     at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)

      [Server:server-one]     at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)

      [Server:server-one]     at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)

      [Server:server-one]     at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)

      [Server:server-one]     ... 18 more

      [Server:server-one]