Solved

where do we set the classpath for Tomcat?

Posted on 2003-11-15
14
1,910 Views
Last Modified: 2012-05-04
Dear experts,

I recently move my app from stand alone Tomcat to "real" Tomcat. Not sure where to set the classpath for Tomcat? Can't seem to find the right place.... Thanks
0
Comment
Question by:changcy77
  • 6
  • 6
  • 2
14 Comments
 
LVL 15

Expert Comment

by:jimmack
ID: 9755075
What does "real" mean? ;-)

Do you mean that you've integrated it into Apache or that you've changed from localhost to a deployed server :-)
0
 
LVL 14

Assisted Solution

by:kennethxu
kennethxu earned 20 total points
ID: 9756509
usually, you don't need to set classpath for tomcat, all you need is set is JAVA_HOME  and CATALINA_HOME environment vars.

if you mean by where to make your jar file accessible by tomcat apps. you should put in various lib dirs:

common/lib - visible by both tomcat server and all apps. for example, jdbc drivers.
server/lib - will only be accessed by tomcat server itself, not visible by apps.
shared/lib - visible by all apps, not visible to tomcat server. for example, your own util lib for all apps.
WEB-INF/lib - only visible by the app that contains the WEB-INF dir.
0
 

Author Comment

by:changcy77
ID: 9756896
Tomcat gave me error message that it does not recognize my package name...
0
 

Author Comment

by:changcy77
ID: 9756980
Experts,

This is the error I got when I just tried to open the first page to log in the application.


***************************************************



Error: 500
Location: /polym/WEB_INF/login.jsp
Internal Servlet Error:

org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
E:\apps\tomcat\work\localhost_8080%2Fpolym\_0002fWEB_0005fINF_0002flogin_0002ejsplogin_jsp_0.java:15: Package research not found in import.
import research.*;
       ^
1 error, 1 warning

      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:247)
      at org.apache.jasper.runtime.JspServlet.loadJSP(JspServlet.java:413)
      at org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:149)
      at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:161)
      at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
      at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
      at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
      at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
      at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
      at java.lang.Thread.run(Thread.java:536)

0
 
LVL 15

Accepted Solution

by:
jimmack earned 30 total points
ID: 9757015
Presumeably you have built some classes that reside in the "research" package.

If this is the case, follow kennethxu's advice and make sure that these classes appear in the correct lib directory.

In this case, it looks fairly application specific, so create the polym\WEB-INF\lib directory and put your classes in there (this should mean that you end up with a directory polym\WEB-INF\lib\research that contains .class files).

The error that you're getting is quite suspicious.  WEB-INF has a hyphen between the words, not an underscore.  Second, your JSP files shouldn't be in the WEB-INF directory, they should be in the polym directory.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9757614
where did you put your research package?
0
 

Author Comment

by:changcy77
ID: 9758572
thanks to both experts. I am going to raise the points to 50. Yes, I followed jimmack's instruction and it seems to work except one more error I got:

*******************************************************
java.lang.NoSuchMethodError: com.oreilly.servlet.MultipartRequest.(Ljavax/servlet/http/HttpServletRequest;Ljava/lang/String;ILcom/oreilly/servlet/multipart/FileRenamePolicy;)V
      at genbank.Upload.doPost(Upload.java:35)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
      at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
      at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
      at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
      at java.lang.Thread.run(Thread.java:536)

****************************************************

I used a library from oreilly's example to upload file to server. This code works on my testing stand alone Tomcat (4.1), but gave me this error on our production server(3.1). The method does exsit, so I don't know why it can't recognize the method.  I put this "com" package in the WEB-INF/lib/com   directory. Thanks.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 15

Expert Comment

by:jimmack
ID: 9758914
There doesn't seem to be a method name!

What is line 35 of your Upload.java file?  (This line should be inside the doPost method and it should be trying to call a method in a MultipartRequest object).
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9758934
Just a minute.  I think I've found it.  You're trying to call a constructor for a MultipartRequest object, but you are only supplying two parameters, an HttpServletRequest and a FileRenamePolicy.

There are no constructors that only take these two parameters.  If you want to include a FileRenamePolicy, you can only use one of the following constructors:

MultipartRequest(javax.servlet.http.HttpServletRequest request, java.lang.String saveDirectory, int maxPostSize, FileRenamePolicy policy)

or

MultipartRequest(javax.servlet.http.HttpServletRequest request, java.lang.String saveDirectory, int maxPostSize, java.lang.String encoding, FileRenamePolicy policy)

You need to include the saveDirectory and maxPostSize (and possibly the encoding method if you use the second constructor).
0
 

Author Comment

by:changcy77
ID: 9759681
thanks very much. Actually, I did include all those 4 parameters and the codes work on my local machine.

The error came out when I move the code to another machine and change the save file directory on the production server. DO you know if the there is any limitation of the directory you can save the file to?
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9759690
No.  There shouldn't be.  So long as you have write access.
0
 

Author Comment

by:changcy77
ID: 9759924
I found there are another copy of the same library on this server, but it's used for another applicaton and under the web-inf of that application.

So, in that older version, the parameters are differnt from what I have. So, should Tomcat use the library under my web-inf, not use the another one? or it is possible Tomcat is looking at another library? THANKS.
0
 

Author Comment

by:changcy77
ID: 9760057
My guess is correct. The Tomcat is looking at the lib in another directory, instead of under my application's web-inf/lib. So, after I upgraded the lib in another directory, it works. But, why? I thought it should check the web-inf/lib for each application? What is the order of the directory it checks? thanks.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9760108
Have a look in tomcat-docs/class-loader-howto.html.  This (hopefully) explains it all ;-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can I clean log of  running tomcat 7 server ? 3 125
console vs log file 16 77
countXY challenge 28 145
JavaScript parse form with colon separated values 2 73
What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now