File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Including external jar in Tomcat ClassPath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Including external jar in Tomcat ClassPath" Watch "Including external jar in Tomcat ClassPath" New topic
Author

Including external jar in Tomcat ClassPath

Sathesh Sivashanmugam
Greenhorn

Joined: May 28, 2011
Posts: 3
Hi

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:\jaa\PatMS.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:\jaa\PatMS.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..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Why can you not just copy it to the app's WEB-INF/lib folder?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sathesh Sivashanmugam
Greenhorn

Joined: May 28, 2011
Posts: 3
Actually the deployment will be done on linux server. The jar file is cron scheduled and it used by another team.

Am not allowed to place it another directory. Also the jar has a class which is synchronized which I will be calling from the web application.


If I took a copy of jar and place it in Tomcat/lib there are chances that the scheduled and the web application threads running parallel which will cause many issues.

Sathesh Sivashanmugam
Greenhorn

Joined: May 28, 2011
Posts: 3
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:\jaa\PatMS.jar

I just checked the catalina.sh in Tomcat/bin and these classpath variable will be set while setting the bootstrap as the classpath.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Including external jar in Tomcat ClassPath
 
Similar Threads
classpath issue while compiling through cmd prompt
error #704....uhg!
Problem using JAVA Mail
Not able to pick up up messages from properties file
java.lang.ClassNotFoundException: oracle:jdbc:driver:OracleDriver