You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christoph Kukulies <ku...@gilberto.physik.rwth-aachen.de> on 2000/05/03 20:06:18 UTC
Error 404 - Location:/servlet/MyClass
I added a <Context> entry in server.xml with the purpose to
establish a 'more friendly' path to put my servlet development into
and not to have to move my servlets into places where Tomcat has
it's demos and other stuff.
So I added
<Context path="/servlets" docBase="webapps/servlets" debug="0" reloadable="
true" >
correspondingly to a previous line which was already there
for path="/test".
Then I put all my classes into /usr/local/build/tomcat/webapps/servlets
but trying to invoke
http://192.168.1.119/servlets/MyClass
results in an Error 404 (coming from Tomcat). Tomcat.log
shows:
Context log: path="/admin" Automatic context load docBase="/home/local/build/tom
cat/webapps/admin"
Context log: path="/admin" Adding context path="/admin" docBase="/home/local/bu
ild/tomcat/webapps/admin"
Context log: path="/servlets" File not found /home/local/build/tomcat/webapps/se
rvlets/WEB-INF/web.xml, using only defaults
Starting endpoint port="8080" handler="org.apache.tomcat.service.http.HttpConnec
tionHandler"
Starting endpoint port="8007" handler="org.apache.tomcat.service.connector.Ajp12
ConnectionHandler"
Context log: path="" Class Not Found in init
java.lang.ClassNotFoundException: MyClass
at org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassL
oader.java:450)
at org.apache.tomcat.loader.AdaptiveServletLoader.loadClass(AdaptiveServ
letLoader.java:141)
at org.apache.tomcat.core.ServletWrapper.initServlet(ServletWrapper.java
:294)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.ja
va:445)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.ja
va:597)
at org.apache.tomcat.servlets.InvokerServlet.service(InvokerServlet.java
Could someone explain to me what the generated
tomcat-apache.conf lines mean:
Alias /test /home/local/build/tomcat/webapps/test
<Directory "/home/local/build/tomcat/webapps/test">
Options Indexes FollowSymLinks
</Directory>
ApJServMount /test/servlet /test
<Location /test/WEB-INF/ >
AllowOverride None
deny from all
</Location>
Alias /servlets /home/local/build/tomcat/webapps/servlets
<Directory "/home/local/build/tomcat/webapps/servlets">
Options Indexes FollowSymLinks
</Directory>
ApJServMount /servlets/servlet /servlets
<Location /servlets/WEB-INF/ >
AllowOverride None
deny from all
</Location>
ApJServMount /servlet /ROOT
Why is there a deny from all generated?
--
Chris Christoph P. U. Kukulies kuku@gil.physik.rwth-aachen.de
Re: Error 404 - Location:/servlet/MyClass
Posted by Craig McClanahan <Cr...@eng.sun.com>.
Christoph Kukulies wrote:
> On Wed, May 03, 2000 at 11:34:14AM -0700, Craig R. McClanahan wrote:
> > Christoph Kukulies wrote:
> >
> > > I added a <Context> entry in server.xml with the purpose to
> > > establish a 'more friendly' path to put my servlet development into
> > > and not to have to move my servlets into places where Tomcat has
> > > it's demos and other stuff.
> > >
> > > So I added
> > > <Context path="/servlets" docBase="webapps/servlets" debug="0" reloadable="
> > > true" >
> > >
> >
> > OK, what you've done here is set up a new web application, with "webapps/servlets"
> > as the document root directory.
> >
> > >
> > > correspondingly to a previous line which was already there
> > > for path="/test".
> > >
> > > Then I put all my classes into /usr/local/build/tomcat/webapps/servlets
> > > but trying to invoke
> > > http://192.168.1.119/servlets/MyClass
> > >
> > > results in an Error 404 (coming from Tomcat). Tomcat.log
> > > shows:
> > >
> >
> > This is not going to work, for two different reasons. First, you need to put your
> > servlet classes under the WEB-INF/classes directory inside your webapp -- so they
> > would go into:
> >
> > /usr/local/build/tomcat/webapps/servlets/WEB-INF/classes
> >
> > Second, there is an interesting subtlety: the location of the servlet's class file
> > has absolutely nothing to do with the URL by which you access it from a browser. By
> > default, Tomcat sets up an "invoker" servlet that can access servlets you haven't
> > registered in your web.xml file, so you would be able to do this:
> >
> > http://192.168.1.119/servlets/servlet/MyClass
> >
> > or, you can set up a "web.xml" file that maps a different URL altogether to this
> > servlet. For details on this, and what kinds of things go in the WEB-INF
> > subdirectory of a web application, see the Servlet API Specification (you can
> > download it from <http://java.sun.com/products/servlet>).
> >
> > Craig McClanahan
> >
>
> Thanks! Thanks! And thanks again! This was very enlightening.
> Really. After a hard day I'm finally there. My Web Application - a
> couple of html files and classes are running again! Gotta get me this
> Servlet API. Is it probably servlet2_2-spec.pdf ?
That's the one. Just be sure you've got the one that says "Final Release" on the front
cover, not one of the earlier public drafts.
> Then I have it
> already. Thought all the time this WEB-INF stuff was a Tomcat
> peculiarity.
>
Nope ... that stuff is standard now. The good news is that web applications are much
more portable between servlet containers under 2.2 than was ever possible before.
Craig McClanahan
Re: Error 404 - Location:/servlet/MyClass
Posted by Christoph Kukulies <ku...@gilberto.physik.RWTH-Aachen.DE>.
On Wed, May 03, 2000 at 11:34:14AM -0700, Craig R. McClanahan wrote:
> Christoph Kukulies wrote:
>
> > I added a <Context> entry in server.xml with the purpose to
> > establish a 'more friendly' path to put my servlet development into
> > and not to have to move my servlets into places where Tomcat has
> > it's demos and other stuff.
> >
> > So I added
> > <Context path="/servlets" docBase="webapps/servlets" debug="0" reloadable="
> > true" >
> >
>
> OK, what you've done here is set up a new web application, with "webapps/servlets"
> as the document root directory.
>
> >
> > correspondingly to a previous line which was already there
> > for path="/test".
> >
> > Then I put all my classes into /usr/local/build/tomcat/webapps/servlets
> > but trying to invoke
> > http://192.168.1.119/servlets/MyClass
> >
> > results in an Error 404 (coming from Tomcat). Tomcat.log
> > shows:
> >
>
> This is not going to work, for two different reasons. First, you need to put your
> servlet classes under the WEB-INF/classes directory inside your webapp -- so they
> would go into:
>
> /usr/local/build/tomcat/webapps/servlets/WEB-INF/classes
>
> Second, there is an interesting subtlety: the location of the servlet's class file
> has absolutely nothing to do with the URL by which you access it from a browser. By
> default, Tomcat sets up an "invoker" servlet that can access servlets you haven't
> registered in your web.xml file, so you would be able to do this:
>
> http://192.168.1.119/servlets/servlet/MyClass
>
> or, you can set up a "web.xml" file that maps a different URL altogether to this
> servlet. For details on this, and what kinds of things go in the WEB-INF
> subdirectory of a web application, see the Servlet API Specification (you can
> download it from <http://java.sun.com/products/servlet>).
>
> Craig McClanahan
>
Thanks! Thanks! And thanks again! This was very enlightening.
Really. After a hard day I'm finally there. My Web Application - a
couple of html files and classes are running again! Gotta get me this
Servlet API. Is it probably servlet2_2-spec.pdf ? Then I have it
already. Thought all the time this WEB-INF stuff was a Tomcat
peculiarity.
--
Chris Christoph P. U. Kukulies kuku@gil.physik.rwth-aachen.de
Re: Error 404 - Location:/servlet/MyClass
Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Christoph Kukulies wrote:
> I added a <Context> entry in server.xml with the purpose to
> establish a 'more friendly' path to put my servlet development into
> and not to have to move my servlets into places where Tomcat has
> it's demos and other stuff.
>
> So I added
> <Context path="/servlets" docBase="webapps/servlets" debug="0" reloadable="
> true" >
>
OK, what you've done here is set up a new web application, with "webapps/servlets"
as the document root directory.
>
> correspondingly to a previous line which was already there
> for path="/test".
>
> Then I put all my classes into /usr/local/build/tomcat/webapps/servlets
> but trying to invoke
> http://192.168.1.119/servlets/MyClass
>
> results in an Error 404 (coming from Tomcat). Tomcat.log
> shows:
>
This is not going to work, for two different reasons. First, you need to put your
servlet classes under the WEB-INF/classes directory inside your webapp -- so they
would go into:
/usr/local/build/tomcat/webapps/servlets/WEB-INF/classes
Second, there is an interesting subtlety: the location of the servlet's class file
has absolutely nothing to do with the URL by which you access it from a browser. By
default, Tomcat sets up an "invoker" servlet that can access servlets you haven't
registered in your web.xml file, so you would be able to do this:
http://192.168.1.119/servlets/servlet/MyClass
or, you can set up a "web.xml" file that maps a different URL altogether to this
servlet. For details on this, and what kinds of things go in the WEB-INF
subdirectory of a web application, see the Servlet API Specification (you can
download it from <http://java.sun.com/products/servlet>).
Craig McClanahan