开发者

Can a servlet truly access jars in Tomcat's lib dir?

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
jav开发者_C百科a.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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜