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 WEB-INF is breaking my Context root Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "WEB-INF is breaking my Context root" Watch "WEB-INF is breaking my Context root" New topic
Author

WEB-INF is breaking my Context root

Billy Hause
Greenhorn

Joined: Jan 16, 2002
Posts: 25
Using Tomcat 4.0-
I setup a new root by using a Context in my SERVER.XML and my '.JSP' works fine.
Next I added the WEB-INF subdir to my root. Now I get a 503 error when I try to view my '.jsp'.
If I take out the WEB-INF subdir it works again.
What is the problem? (I need the WEB-INF\lib for my jars)
Does tomcat4 act differently when your root has a WEB-INF subdir
Thanks for any help!
P.S. My context setting in my SERVER.XML is as follows:
<Context path="/qsets" docBase="C:/_dev/qsets/site" debug="0" reloadable="true"/>
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
Did you put the jsp in the web-inf?
structure is:
root
--some.jsp (or better --/jsp/some.jsp
--WEB-INF
----web.xml (you have that?)
----classes/MyClass.class
----lib/myLib.jar
(to clarify:
root/myJsp.jsp
root/WEB-INF/lib/myLib.jar)
Axel
Billy Hause
Greenhorn

Joined: Jan 16, 2002
Posts: 25
Hi Axel,
I did not put the jsp in web-inf. I tried it there and it didn't work so I moved it back under root.
Here is my structure:
My root is: C:\_dev\qsets\site
(See the context in my first message)
I believe my structure matches the one you gave:
My structure is:
site (Set as root by my context path in SERVER.XML)
-test.jsp
-WEB_INF
--web.xml
--classes
--lib
If I remove the web.xml I get error 505.
If I keep web.xml I get error 404
Do I need to set something in web.xml?
Maybe my context isn't set right in my SERVER.XML?
The URL I'm trying is http://localhost:8080/qsets/test.jsp
My only clue so far is that it finds test.jsp if I remove my WEB-INF subdir.
Thanks,
Bill
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

You posted 505 in your last post, but 503 in the previous one. I think you meant 503 for both?

web.xml should contain the bare minimum allowed, which you can find by looking here:
<CATALINA_HOME>/webapps/ROOT/WEB-INF/web.xml

Also ensure you have a web.xml file under <CATALINA_HOME>/conf/web.xml. The file should be about 30k and contain about 830 lines.

As always, make sure on Windows that your WEB-INF is indeed in all capitals (sometimes windows will flip it to lower case).

JSPs don't need to be anywhere special, under the 'root' of your webapp is fine. They also don't need entries in your web.xml for that application (as long as the 30k web.xml under the 'conf' directory is there).
Billy Hause
Greenhorn

Joined: Jan 16, 2002
Posts: 25
Hi Mike,
I did what you said.
Now I get the 503 error only.
I now have the bare minimum web.xml file under
site\WEB-INF\web.xml
Ironically, if I remove WEB-INF (rename it to xWEB-INF) then Tomcat finds my JSP!
Under WEB-INF I have an empty classes directory and a lib directory with some '.jar's in it.
I think we're getting closer but I'm not sure what to try next.
Billy
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 566
Check your log files in catalina-home/logs directory - one of the files with today's date may register some sort of exception when you try to access the page, which could provide a bit of info.
Unless you configured it in server.xml as a context, the log file to look in should be localhost-log.2002-05-xx.txt
Adam


I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
Billy Hause
Greenhorn

Joined: Jan 16, 2002
Posts: 25
Adam,
You were right. There was an exception.
Perhaps I need to reinstall Tomcat?
Anyone know what this exception means?
Here is an excerpt from the log file:
2002-05-29 21:16:33 StandardWrapper[/qsets:jsp]: Using Jasper classloader for servlet jsp
2002-05-29 21:16:34 StandardWrapper[/qsets:jsp]: Marking servlet jsp as unavailable
2002-05-29 21:16:34 StandardContext[/qsets]:
Servlet /qsets threw load() exception
javax.servlet.ServletException: Class org.apache.jasper.servlet.JspServlet is not a Servlet
Followed by
----- Root Cause -----
java.lang.ClassCastException: org.apache.jasper.servlet.JspServlet
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:832)

Perhaps I need to reinstall Tomcat?
Anyone know what these exceptions mean?
Billy Hause
Greenhorn

Joined: Jan 16, 2002
Posts: 25
PROBLEM SOLVED!!!
Thanks for all your suggestions. I learned a lot!
I had j2ee.jar in my WEB-INF/lib directory and that was screwing things up. I don't know why.
I think I may need j2ee.jar for tab libraries but that is an issue for a different post.
Thanks,
-Billy
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 566
J2EE.jar will contain all the stuff that tomcat normally gets from servlet.jar, so perhaps your J2EE.jar was an older version which tomcat didn't like.
Billy Hause
Greenhorn

Joined: Jan 16, 2002
Posts: 25
I replaced J2EE.jar with a servlet.jar that I got from tomcat 4.0\common\lib.
This seems to have the same problem as j2ee.jar had.
I can use servlet.jar to compile, but if it gets copied into my WEB-INF\lib then things break.
Perhaps I need servlet.jar when compiling, but should not copy it to WEB-INF\lib when I deploy?
Here are excerpts from my localhost_log files.
First the log when things work (without servlet.jar) then the log when things break.
-- without servlet.jar (it works) --
2002-05-31 05:59:05 invoker: init
2002-05-31 05:59:05 StandardWrapper[/survey:jsp]: Using Jasper classloader for servlet jsp
2002-05-31 05:59:05 jsp: init
2002-05-31 05:59:06 WebappLoader[/qsets]: Deploying class repositories to work directory C:\Program Files\Apache Tomcat 4.0\work\localhost\qsets
2002-05-31 05:59:06 WebappLoader[/qsets]: Deploy JAR /WEB-INF/lib/ant-1.3.jar to C:\_dev\qsets\site\WEB-INF\lib\ant-1.3.jar
2002-05-31 05:59:06 WebappLoader[/qsets]: Deploy JAR /WEB-INF/lib/qsets_app-0.1.jar to C:\_dev\qsets\site\WEB-INF\lib\qsets_app-0.1.jar

-- with servlet.jar (it breaks) --
2002-05-31 05:53:35 invoker: init
2002-05-31 05:53:35 StandardWrapper[/qsets:jsp]: Using Jasper classloader for servlet jsp
2002-05-31 05:53:35 StandardWrapper[/qsets:jsp]: Marking servlet jsp as unavailable
2002-05-31 05:53:35 StandardContext[/qsets]: Servlet /qsets threw load() exception
javax.servlet.ServletException: Error instantiating servlet class org.apache.jasper.servlet.JspServlet
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:841)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3292)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3402)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 566
Tomcat 4 is bundled with servlet.jar when you install it - it is in tomcat/common/lib and normally you wouldn't copy it into your war when you deploy, at least for tomcat deploys.
Adam
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: WEB-INF is breaking my Context root