You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Douglas Phillips <do...@sbscomp.com> on 2008/09/16 10:05:53 UTC

tomcat servlet problem

Hi all.  I'm hitting a brick wall here, and not sure where to look now.

First the basics:
Tomcat 5.5.26 in /usr/local/tomcat-5.5.26
Java 1.5.0_16 in /usr/local/java-1.5

Tomcat starts fine, and I can run the examples with no difficulty at all.

I'm migrating a web app from a previous shared hosting environment to a 
new dedicated server.  The web app is located like so (for reasons of an 
NDA, I can't specify any identifying information):
/home/user/domain.tld/html
	/jsp
	/WEB-INF
		/classes

The JSP files can be accessed fine.  When I attempt to post to 
/servlet/loginController, I get a 404 error back from tomcat.

Here's the configuration files:

server.xml
==========

<Host name="www.domain.tld" appBase="/home/user/domain.tld/html"
        unpackWARs="true" autoDeploy="true">
         <Context path="" docBase="jsp" debug="0" reloadable="true" />
         <Valve className="org.apache.catalina.valves.AccessLogValve"
                directory="logs"  prefix="web1_access_log." 		
                suffix=".txt" pattern="common" resolveHosts="false"/>
</Host>

web.xml in web app's WEB-INF directory
======================================
(Note: I simplified things to reduce clutter)

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
     <servlet>
         <servlet-name>loginController</servlet-name>
         <servlet-class>LoginController</servlet-class>
     </servlet>

     <servlet-mapping>
         <servlet-name>loginController</servlet-name>
         <url-pattern>/loginController</url-pattern>
     </servlet-mapping>
</web-app>


Here's something else that may or may not be applicable:
If I symlink the context root into the tomcat webapps directory and 
attempt to access in the same way (using /testapp), I get the same error.

The web app was working fine under the previous hosting environment.

Any help would be vastly appreciated.
Thanks.

-Doug


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: tomcat servlet problem

Posted by Douglas Phillips <do...@sbscomp.com>.
Mark Thomas wrote:

> That is going to give you multiple deployment issues. The correct way to
> configure this (ignoring the valve) is:
> 
> mv /home/user/domain.tld/html/jsp /home/user/domain.tld/html/ROOT
> 
> <Host name="www.domain.tld" appBase="/home/user/domain.tld/html"
>        unpackWARs="true" autoDeploy="true">
> </Host>

hmm. ok.

> You should not use packageless classes. See
> http://wiki.apache.org/tomcat/FAQ/Class_Not_Found?highlight=(packageless)

I agree.  Unfortunately, I'm not the developer, so I have no control 
over this.  (Personally, I would have preferred that the developer 
packaged the whole thing in a WAR as well, but I digress.)

>>     <servlet-mapping>
>>         <servlet-name>loginController</servlet-name>
>>         <url-pattern>/loginController</url-pattern>
>>     </servlet-mapping>
> This does not agree with the URL you are using to request this servlet
> (/servlet/loginController). You either need to change the URL you use or
> (probably quicker) change the mapping to
> <servlet-mapping>
>   <servlet-name>loginController</servlet-name>
>   <url-pattern>/servlet/loginController</url-pattern>
> </servlet-mapping>

I will try changing the mapping and the config and see if that resolves 
the problem.

Thanks.
-Doug


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: tomcat servlet problem

Posted by Mark Thomas <ma...@apache.org>.
Douglas Phillips wrote:
> Hi all.  I'm hitting a brick wall here, and not sure where to look now.
> 
> First the basics:
> Tomcat 5.5.26 in /usr/local/tomcat-5.5.26
You should upgrade to 5.5.27. There are some important security
vulnerabilities in earlier versions.

> Java 1.5.0_16 in /usr/local/java-1.5
> 
> Tomcat starts fine, and I can run the examples with no difficulty at all.
> 
> I'm migrating a web app from a previous shared hosting environment to a
> new dedicated server.  The web app is located like so (for reasons of an
> NDA, I can't specify any identifying information):
> /home/user/domain.tld/html
>     /jsp
>     /WEB-INF
>         /classes
The spacing is a little messed up for me. I assume this is
/home/user/domain.tld/html
/home/user/domain.tld/html/jsp
/home/user/domain.tld/html/jsp/WEB-INF
/home/user/domain.tld/html/jsp/WEB-INF/classes

> The JSP files can be accessed fine.  When I attempt to post to
> /servlet/loginController, I get a 404 error back from tomcat.
> 
> Here's the configuration files:
> 
> server.xml
> ==========
> 
> <Host name="www.domain.tld" appBase="/home/user/domain.tld/html"
>        unpackWARs="true" autoDeploy="true">
>         <Context path="" docBase="jsp" debug="0" reloadable="true" />
>         <Valve className="org.apache.catalina.valves.AccessLogValve"
>                directory="logs"  prefix="web1_access_log."        
>                suffix=".txt" pattern="common" resolveHosts="false"/>
> </Host>

That is going to give you multiple deployment issues. The correct way to
configure this (ignoring the valve) is:

mv /home/user/domain.tld/html/jsp /home/user/domain.tld/html/ROOT

<Host name="www.domain.tld" appBase="/home/user/domain.tld/html"
       unpackWARs="true" autoDeploy="true">
</Host>

Note that the context element becomes unnecessary. See
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

> web.xml in web app's WEB-INF directory
> ======================================
> (Note: I simplified things to reduce clutter)
> 
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
> 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
> <web-app>
>     <servlet>
>         <servlet-name>loginController</servlet-name>
>         <servlet-class>LoginController</servlet-class>
>     </servlet>

You should not use packageless classes. See
http://wiki.apache.org/tomcat/FAQ/Class_Not_Found?highlight=(packageless)

>     <servlet-mapping>
>         <servlet-name>loginController</servlet-name>
>         <url-pattern>/loginController</url-pattern>
>     </servlet-mapping>
This does not agree with the URL you are using to request this servlet
(/servlet/loginController). You either need to change the URL you use or
(probably quicker) change the mapping to
<servlet-mapping>
  <servlet-name>loginController</servlet-name>
  <url-pattern>/servlet/loginController</url-pattern>
</servlet-mapping>

> Here's something else that may or may not be applicable:
> If I symlink the context root into the tomcat webapps directory and
> attempt to access in the same way (using /testapp), I get the same error.
> 
> The web app was working fine under the previous hosting environment.
> 
> Any help would be vastly appreciated.
> Thanks.
> 
> -Doug
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: tomcat servlet problem

Posted by Markus Schönhaber <to...@list-post.mks-mail.de>.
Douglas Phillips:

> The JSP files can be accessed fine.  When I attempt to post to 
> /servlet/loginController, I get a 404 error back from tomcat.
[...]
>      <servlet-mapping>
>          <servlet-name>loginController</servlet-name>
>          <url-pattern>/loginController</url-pattern>

Your servlet is mapped to /loginController, not /servlet/loginController.

> The web app was working fine under the previous hosting environment.

Maybe the invoker servlet was activated there (a bad idea).

Regards
   mks

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org