NoClassDefFoundError en una clase de dependencia en una aplicación web

I have a web application A, which depends on library B, which, in turn, uses library C. A, B and C are all Maven projects (A is a war, B and C are jars).

When I deploy A to the application container, some method of a class in B is invoked, which refers to class D in library C.

At that point, I get a NoClassDefFoundError for D. D uses (imports) packages java.sql y org.slf4j.

I explored following hypotheses and none of them was true:

  1. Different versions of C are used. In order to exclude this hypothesis, I ran mvn dependency:tree in the directory of A and I found only one reference to C.
  2. C is not included in the war file of A. Abrí el archivo target\A.war\WEB-INF\lib\C.jar\ and the class file of D was present at the correct location (i. e. this hypothesis is incorrect).

¿Cómo puedo solucionar este error?

preguntado el 05 de mayo de 13 a las 09:05

If the Class D is in the jar C but not packaged into the war file you have a problem with the dependencies in your war project. Simply show all pom file so it's possible to help. -

@khmarbaise D is packaged into the war file. -

Please show the pom files! -

And show the full stack trace of the exception, after a fresh deploy. -

1 Respuestas

The problem was caused by the fact that library B was obfuscated with ProGuard. After I disabled its obfuscation, everything started to work.

contestado el 05 de mayo de 13 a las 10:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.