0

I have a Maven war project that is dependent on a number of jars. I have them listed in the dependency section of my pom.xml file and I see those jar files are put in WEB-INF/libs. However, when I got to deploy the war file on Glassfish it says it can't find classes that are in the dependent jars.

What to do?

Rick Eyre
  • 2,355
  • 4
  • 20
  • 26

1 Answers1

1

There's no easy answer to a NoClassDefFoundError, other than you need to understand what it's telling you, and then review what classes are coming from what Jars bundled in your app vs what classes are coming from Jars provided by the app server. Take a look in this post for good explanations of possible causes of the isse: What causes and what are the differences between NoClassDefFoundError and ClassNotFoundException?

Community
  • 1
  • 1
Kevin Hooke
  • 2,583
  • 2
  • 19
  • 33
  • Thanks for this. Was very informative. I get the causes now; just have no idea what is causing it. Hard to track down. – Rick Eyre Jan 13 '16 at 20:51
  • It might help to look at any libraries you're using that are different implementations/versions of EE apis - this is a most likely cause. e.g. you have one version or implementation of api x that is already provided by the app server, and a different version bundled in your Ear/War. Also, common libraries like Apache Commons Lang etc. Depending on what app server you're using, most have a way to customize a 'prefer libraries from war' which can force use of Jars in your app rather than the server. – Kevin Hooke Jan 13 '16 at 21:01