2 Replies Latest reply on Oct 27, 2015 8:35 PM by armahdi

    Wildfly not loading the right library

    armahdi

      Hello All,

       

      I am running into a situation where I have added the library but it is not being picked up

       

      at java.lang.Thread.run(Thread.java:722)

      Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletInputStream

              at org.springframework.web.multipart.commons.CommonsMultipartResolver.isMultipart(CommonsMultipartResolver.java:110)

              at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:937)

              at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:797)

              ... 34 more

      Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletInputStream from [Module "org.apache.commons-fileupload:main" from local module loader @6861d517 (finder: local module finder @6eed0e8

      a (roots: C:\JAVA\WF9\wildfly-9.0.0.Final\modules,C:\JAVA\WF9\wildfly-9.0.0.Final\modules\system\layers\base))]

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

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

              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)

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

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

              ... 37 more

       

       

      My jboss-deployment structure:

      <?xml version="1.0" encoding="UTF-8"?>

      <jboss-deployment-structure>

          <deployment>

              <dependencies>

                  <!--

                  we want to use the saaj module provided by JBoss

                  it looks like we can't use the implementation provided by the JDK - JBoss somehow does not seem to allow it

                  -->

                  <module name="com.sun.xml.messaging.saaj" />

                  <module name="javax.servlet.api"/>

                  <module name="com.gbst.directregistry.configuration" />

                  <module name="com.gbst.directregistry.hypersonic" />

                  <module name="org.apache.commons-fileupload"/>

              </dependencies>

          </deployment>

      </jboss-deployment-structure>

      javax.servlet.api in the service/layers/... is where it is located and I have seen that the class is located there.


      org.apache.commons-fileupload is something I made myself to contain a class to solve an issue when i had this:


      <bean id="multipartResolver"

           class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>

       

       

      seems like this CommonsMultipartResolver uses : org.apache.commons.fileupload.FileUpload which is not found in the system/layer/.. libs so i added my own lib in module\org\apache\commons-fileupload . Every time i try to invoke my url it throws the error above. Why is WF trying to find ServletInputStream in org.apache.commons-fileupload even though it is already there in the WF System/layers/ libs even though it is located in javax.servlet.api

        • 1. Re: Wildflyno loading the right library
          jaysensharma

          The error which you are getting is as following:

           

          ClassNotFoundException: javax.servlet.ServletInputStream from [Module "org.apache.commons-fileupload:main" 
          


          Above indicates that your custom module "org.apache.commons-fileupload" module's   module.xml you should add a dependency to the <module name="javax.servlet.api"/>


          So try editing your   $JBOSS_HOME/modules/system/layers/base/org/apache/commons-fileupload/main/module.xml and  add the dependency <module name="javax.servlet.api"/>  then restart Wildfly and retest.

          • 2. Re: Wildfly not loading the right library
            armahdi

            Thanks Jay,

             

            That worked. Awesome.