1

While I successfully upload files to my web application in SpringMVC/Widlfly/Ubuntu stack, I encounter NoClassDefFoundError exception in SpringMVC/Widlfly/CentOs. Both stack has same Wildfly, same JDK, and same configurations.

Environment:

  • SpringMVC
  • Wildfly 8.1 / Wildfly 8.2
  • JDK 1.7.0_51-b13
  • JAR files:
    • my-ear.ear/my-web.war/WEB-INF/lib/commons-io-2.4.jar
    • my-ear.ear/my-web.war/WEB-INF/lib/commons-fileupload-1.3.1.jar
    • wildfly-8.1.0.Final/modules/system/layers/base/org/apache/commons/io/main/commons-io-2.4.jar

I know that this exception is due to conflicting in class-loader.

MK Aftab
  • 39
  • 7

2 Answers2

0

I finally solved my problem. I moved 'commons-io-2.4.jar' and 'commons-fileupload-1.3.1.jar' files from 'my-ear.ear/my-web.war/WEB-INF/lib/' to 'my-ear.ear/lib'.

MK Aftab
  • 39
  • 7
0

In my case, the problem was that I was declaring the dependencies into a war maven project, so maven was copying the jar libs into WEBINF/lib.

I solved this issue by putting the dependencies declaration on another war dependent jar project pom, instead war project as i was doing:

myapp-project-web-api/: <- (war maven project)

pom.xml:

...
    <dependencies>

      <!-- File upload -->
        <!-- deleted commons-fileupload dependency>

        <!-- deleted commons-io dependency -->
...

myapp-project-web-api-components/:

pom.xml:

...
    <dependencies>

    <!-- File upload -->
      <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
      </dependency>

      <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
      </dependency>
...
Sapnesh Naik
  • 11,011
  • 7
  • 63
  • 98
Francisco M
  • 163
  • 2
  • 9