changcy77
asked on
where do we set the classpath for Tomcat?
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
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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tomcat gave me error message that it does not recognize my package name...
ASKER
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.JasperEx ception: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
E:\apps\tomcat\work\localh ost_8080%2 Fpolym\_00 02fWEB_000 5fINF_0002 flogin_000 2ejsplogin _jsp_0.jav a:15: Package research not found in import.
import research.*;
^
1 error, 1 warning
at org.apache.jasper.compiler .Compiler. compile(Co mpiler.jav a:247)
at org.apache.jasper.runtime. JspServlet .loadJSP(J spServlet. java:413)
at org.apache.jasper.runtime. JspServlet $JspServle tWrapper.l oadIfNeces sary(JspSe rvlet.java :149)
at org.apache.jasper.runtime. JspServlet $JspServle tWrapper.s ervice(Jsp Servlet.ja va:161)
at org.apache.jasper.runtime. JspServlet .serviceJs pFile(JspS ervlet.jav a:261)
at org.apache.jasper.runtime. JspServlet .service(J spServlet. java:369)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 853)
at org.apache.tomcat.core.Ser vletWrappe r.handleRe quest(Serv letWrapper .java:503)
at org.apache.tomcat.core.Con textManage r.service( ContextMan ager.java: 559)
at org.apache.tomcat.service. http.HttpC onnectionH andler.pro cessConnec tion(HttpC onnectionH andler.jav a:160)
at org.apache.tomcat.service. TcpConnect ionThread. run(Simple TcpEndpoin t.java:338 )
at java.lang.Thread.run(Threa d.java:536 )
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.JasperEx
E:\apps\tomcat\work\localh
import research.*;
^
1 error, 1 warning
at org.apache.jasper.compiler
at org.apache.jasper.runtime.
at org.apache.jasper.runtime.
at org.apache.jasper.runtime.
at org.apache.jasper.runtime.
at org.apache.jasper.runtime.
at javax.servlet.http.HttpSer
at org.apache.tomcat.core.Ser
at org.apache.tomcat.core.Con
at org.apache.tomcat.service.
at org.apache.tomcat.service.
at java.lang.Thread.run(Threa
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
where did you put your research package?
ASKER
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.NoSuchMethodErro r: com.oreilly.servlet.Multip artRequest .(Ljavax/s ervlet/htt p/HttpServ letRequest ;Ljava/lan g/String;I Lcom/oreil ly/servlet /multipart /FileRenam ePolicy;)V
at genbank.Upload.doPost(Uplo ad.java:35 )
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 760)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 853)
at org.apache.tomcat.core.Ser vletWrappe r.handleRe quest(Serv letWrapper .java:503)
at org.apache.tomcat.core.Con textManage r.service( ContextMan ager.java: 559)
at org.apache.tomcat.service. http.HttpC onnectionH andler.pro cessConnec tion(HttpC onnectionH andler.jav a:160)
at org.apache.tomcat.service. TcpConnect ionThread. run(Simple TcpEndpoin t.java:338 )
at java.lang.Thread.run(Threa d.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.
**************************
java.lang.NoSuchMethodErro
at genbank.Upload.doPost(Uplo
at javax.servlet.http.HttpSer
at javax.servlet.http.HttpSer
at org.apache.tomcat.core.Ser
at org.apache.tomcat.core.Con
at org.apache.tomcat.service.
at org.apache.tomcat.service.
at java.lang.Thread.run(Threa
**************************
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.
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).
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).
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.ser vlet.http. HttpServle tRequest request, java.lang.String saveDirectory, int maxPostSize, FileRenamePolicy policy)
or
MultipartRequest(javax.ser vlet.http. HttpServle tRequest 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).
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.ser
or
MultipartRequest(javax.ser
You need to include the saveDirectory and maxPostSize (and possibly the encoding method if you use the second constructor).
ASKER
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?
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?
No. There shouldn't be. So long as you have write access.
ASKER
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.
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.
ASKER
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.
Have a look in tomcat-docs/class-loader-h owto.html. This (hopefully) explains it all ;-)
Do you mean that you've integrated it into Apache or that you've changed from localhost to a deployed server :-)