1

Background first:

  • Tomcat 6.0 on WindowsXP & OpenSUSE SLED 11.0 (same results on both platforms)
  • Oracle JDK v6
  • Spring 3.0
  • Javolution 5.5.1

I've got a strange problem with a jar (javolution-5.5.1.jar) that my app is using. I've had this jar in WEB-INF/lib for some time now without any problems. We determined that this jar really needs to be in Tomcat's lib dir instead of our app's lib dir because it is shared across several apps, so we moved it.

However, doing so has caused a new RuntimeException trying to access a class (Scinv) that extends a Struct from javolution.jar. Is there some reason an app wouldn't be able to access a class in a JAR from Tomcat's lib dir in this way?

My class is (irrelevant details removed):

import javolution.io.Struct;
public class Scinv extends Struct {
    public static methodA() {...}
    public static methodB() {...}
    public static class ProdRecs extends Struct {...}
    public static class ProdRec extends Struct {...}
}

When I try to access the static methods of Scinv, which make use of the static nested classes, I'm getting this:

Apr 5, 2011 3:40:50 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet inventory threw exception
java.lang.RuntimeException: Struct class: general.dao.externalfiles.Scinv$ProdRec not found
at javolution.io.Struct.array(Struct.java:557)
at general.dao.externalfiles.Scinv$ProdRecs.<init>(Scinv.java:447)

Apr 5, 2011 3:40:50 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.RuntimeException: Struct class: general.dao.externalfiles.Scinv$ProdRec not found
at javolution.io.Struct.array(Struct.java:557)
at general.dao.externalfiles.Scinv$ProdRecs.<init>(Scinv.java:447)

All I have to do is move the javolution-5.5.1.jar from Tomcat/lib to my WEB-INF/lib dir, and the app works fine again, no RuntimeExceptions.

Any ideas on why this is failing? We also have postgres-9.0.jar file in Tomcat/lib dir, and it seems to work fine.

I'd be happy to provide more details if you need them, and any suggestions would be appreciated as I'm kind of stumped on this one!

Gordon
  • 1,210
  • 5
  • 16
  • 23
  • Ok, if you restart tomcat, does it startup correctly without throwing exceptions? What does the log say? – Buhake Sindi Apr 05 '11 at 21:26
  • I've restarted Tomcat several times to no avail. I've added all the log messages I see above. By the way, it always starts up fine, it's only when I try to access Scinv that it throws the RuntimeException. – Gordon Apr 05 '11 at 21:32

1 Answers1

1

I don't think it's the problem of putting javolution-5.5.1.jar in TOMCAT_HOME/lib folder, the JVM would have worried about the Struct object already (javolution.io.Struct.array(Struct.java:557)). The real cause of the problem is: What is happening on your constructor in general.dao.externalfiles.Scinv$ProdRecs class (Scinv.java:447)? Something is causing the object not to initialize and thus, the runtime exception.

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228
  • I think you are headed down the right track. The Javolution library is doing some caching of classes and managing classloaders internally, and now I'm thinking my issue is more with the library itself. I'm going to continue to look into this and will post my results. – Gordon Apr 06 '11 at 16:05
  • Status update: It turns out that this issue is caused by the library itself. As I stated, it is trying to do class loading internally, and the algorithm it uses is invalid. So, my constructor in Scinv$ProdRecs fails with the RuntimeException. Thanks *SO* much for leading me that direction! – Gordon Apr 07 '11 at 15:42