Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
240 views
in Technique[技术] by (71.8m points)

java - Including external jar in Tomcat ClassPath

In Tomcat I want to use a jar inside a web application. The jar file will exist outside of the Tomcat directory.

To include the jar file in tomcat classpath, I modified the TomcatHome/conf/catalina.properties to include the absolute path of my jar file like,

shared.loader=D:jaaMyJarFile.jar

as per the suggestion given in link,

http://www.mulesoft.com/tomcat-classpath

But it throws the error,

java.lang.NoClassDefFoundError

I have also tried ,

shared.loader=D:jaa*.jar

shared.loader=file:\D:jaaMyJarFile.jar

None of them seem to work :(

If I try placing the jar inside tomcat/lib it seem to work. But I am not allowed to do that.

Please help me out with this issue as I have implementation the next week..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I figured myself how to add the classpath for tomcat. Instead of editing catalina.properties, just create a "setenv.sh" in the Tomcat Bin directory with the classpath,

Example,

CLASSPATH=D:jaaMyJarFile.jar

I just checked the catalina.sh in Tomcat/bin and these classpath variable will be set while setting the bootstrap as the classpath.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...