Random NoClassDefFound error in Web Application

2019-02-23 02:56发布

问题:

Wondering if any guru out there could shed an idea on why the following randomly happens.

We have a web application we deploy in Jetty 6.1.26 running on a Linux installation with JRE 1.7_03

Not every time, but every now and then, when Jetty starts up - what appears to be a random class (from our project) seems to be the source of a NoClassDefFound error. If we restart Jetty they problem disappears.

The only pattern that occurs seems to be the classes at the root of the error are populated via JAXB annotations.

To give more of an idea of the frequency it feels this happens 1/50 times, if that.

I would be interested to know the how and the why for this error.

回答1:

Not sure this can help but we ran into annotations problems with Jetty 8 and java 6. To make a long story short, annotations processing in that version seem to rely on libasm e.g. bytecode inspection. So we have to be careful with

  • what we compile our classes with (e.g; JDK version, etc...)
  • that we do not pull multiple asm/javassist librairies through our dependencies and end up loading the wrong one

I am not familiar with with the way Jetty 6 and Jaxb process annotations but I am actually surprised you can get both running on Java 7. Can you try running you code with Java 6 ?