You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Leydhershnayder, Leon A." <la...@louisville.edu> on 2004/03/02 17:44:46 UTC

Deploying a simple servlet

I'm new to tomcat and am trying to run a very simple hello world type of
servlet.  I've configured the web.xml to mimic a similar servlet in tomcat
examples.  Still while all the example servlets from tomcat work mine fails
to run.

I receive the following message:

HTTP Status 404 - /MyApp/servlet/Testing

I would greatly appreciate any advice.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Deploying a simple servlet

Posted by epyonne <ep...@hotmail.com>.
Usually the problem is on your deployment descriptor.  Double-check it or
post it for help.

Thanks.


----- Original Message -----
From: "Leydhershnayder, Leon A." <la...@louisville.edu>
To: <to...@jakarta.apache.org>
Sent: Tuesday, March 02, 2004 10:44 AM
Subject: Deploying a simple servlet


> I'm new to tomcat and am trying to run a very simple hello world type of
> servlet.  I've configured the web.xml to mimic a similar servlet in tomcat
> examples.  Still while all the example servlets from tomcat work mine
fails
> to run.
>
> I receive the following message:
>
> HTTP Status 404 - /MyApp/servlet/Testing
>
> I would greatly appreciate any advice.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Deploying a simple servlet

Posted by Christopher Schultz <ch...@comcast.net>.
Leon,

> I've set up a directory structure for this app exactly like the servlet
> examples structure and after making changes to web.xml I'm recieving the
> following root cause error:
> 
> java.lang.NoClassDefFoundError: TestingServlet (wrong name:
> myApp/TestingServlet)

Is your TestingServlet class in a package? If so, you need to give the 
fully-qualified class name in your web.xml file.

If it's not in a package, I've heard many reports that it simply won't 
work :(

Try putting your servlet class into a package, updating your web.xml 
file and trying again.

-chris

RE: Deploying a simple servlet

Posted by "Leydhershnayder, Leon A." <la...@louisville.edu>.
I've edited the web.xml file to contain the following:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!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>Testing</servlet-name>
		<servlet-class>TestingServlet</servlet-class>
	</servlet>

    <servlet-mapping>
        <servlet-name>Testing</servlet-name>
        <url-pattern>/Testing</url-pattern>
    </servlet-mapping>

</web-app>


I've set up a directory structure for this app exactly like the servlet
examples structure and after making changes to web.xml I'm recieving the
following root cause error:

java.lang.NoClassDefFoundError: TestingServlet (wrong name:
myApp/TestingServlet)

-----Original Message-----
From: Christopher Schultz [mailto:christopher.d.schultz@comcast.net]
Sent: Tuesday, March 02, 2004 11:57 AM
To: Tomcat Users List
Subject: Re: Deploying a simple servlet


Leon,

> I'm new to tomcat and am trying to run a very simple hello world type of
> servlet.  I've configured the web.xml to mimic a similar servlet in tomcat
> examples.  Still while all the example servlets from tomcat work mine
fails
> to run.
>
> I receive the following message:
>
> HTTP Status 404 - /MyApp/servlet/Testing
>
> I would greatly appreciate any advice.

In the newer versions of Tomcat, the 'invoker' servlet is disabled by
default. The best way to get your servlet running it to create a
<servlet-mapping> element in your web.xml and then use your mapped URL
to access the servlet (instead of using a URL like
/context/servlet/ClassName).

-chris


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Where to store log files from packed WAR file apps

Posted by Jacob Kjome <ho...@visi.com>.
You should never log to within the directory structure of your webapp if you
want your app to be portable.  Provide configuration in web.xml as to where you
want the log file to go which an admin can override via proprietary
configuration.  For instance, in Tomcat...

<Context ...>
    <Parameter name="log4j-log-location" value="C:\logs" override="false"
        description="Location for logs to be written"/>
</Context>

Then in your Log4j initialization, use value of the "log4j-log-location"
context-param and set a system property with that value to a name that you
reference in your log4j.xml file such as....

<appender name="File" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="${log.location}" />
..
..
..
</appender>


Or, check out the logging-log4j-sandbox project and grab the alpha_2 (I think
that's the tag name) tag.  Then look into ServletContextLogAppender which will
allow you to specify this in log4j.xml....

<appender name="ServletContext"
class="org.apache.log4j.servlet.ServletContextLogAppender">
        <param name="servletContextPath" value="/mycontext" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="[%-5p][%-8.8t]: %39.39c{3} -
%m"/>
        </layout>
    </appender>

The output will be routed through your server's context.log() mechanism.  In
Tomcat, just set up....
<Context path="/mycontext" docBase="mycontext.war"
         debug="5" reloadable="true">

    <Logger
        className="org.apache.catalina.logger.FileLogger"
        prefix="localhost_mycontext_servlet_log."
        suffix=".txt"
	    timestamp="true" />
</Context>

Now you don't need to configure any file to do the logging.  It will just show
up in your container's log directly which you know for a fact will exist and the
container will create it for you.

Or, use Chainsaw2...
http://logging.apache.org/log4j/docs/chainsaw.html

Jake


Quoting Harry Mantheakis <ha...@mantheakis.freeserve.co.uk>:

> Hello
> 
> Now that I've got my Ant build/deploy scripts working nicely, I'm tempted to
> start running my applications out of packed WAR files.
> 
> I cannot figure out if there is a *portable* way to specify paths for where
> my Log4J log files should be saved.
> 
> I assume I could use the 'catalina.home' property to save the logs under the
> Tomcat installation directory - but that's Tomcat specific.
> 
> Has anyone got around this, somehow, or is it a case of getting Ant to glue
> things with some hard-coded values at build time?
> 
> Many thanks for any contributions.
> 
> Harry Mantheakis
> London, UK
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Where to store log files from packed WAR file apps

Posted by Harry Mantheakis <ha...@mantheakis.freeserve.co.uk>.
Hello

Now that I've got my Ant build/deploy scripts working nicely, I'm tempted to
start running my applications out of packed WAR files.

I cannot figure out if there is a *portable* way to specify paths for where
my Log4J log files should be saved.

I assume I could use the 'catalina.home' property to save the logs under the
Tomcat installation directory - but that's Tomcat specific.

Has anyone got around this, somehow, or is it a case of getting Ant to glue
things with some hard-coded values at build time?

Many thanks for any contributions.

Harry Mantheakis
London, UK


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Deploying a simple servlet

Posted by Christopher Schultz <ch...@comcast.net>.
Leon,

> I'm new to tomcat and am trying to run a very simple hello world type of
> servlet.  I've configured the web.xml to mimic a similar servlet in tomcat
> examples.  Still while all the example servlets from tomcat work mine fails
> to run.
> 
> I receive the following message:
> 
> HTTP Status 404 - /MyApp/servlet/Testing
> 
> I would greatly appreciate any advice.

In the newer versions of Tomcat, the 'invoker' servlet is disabled by 
default. The best way to get your servlet running it to create a 
<servlet-mapping> element in your web.xml and then use your mapped URL 
to access the servlet (instead of using a URL like 
/context/servlet/ClassName).

-chris