You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Simon Freytag <si...@anondesign.com> on 2000/12/12 16:22:23 UTC

Error loading servlets in Tomcat

Hi,

I'm new to the list so apologies if I miss a point of protocol. I've
consulted the Tomcat docs, faqs and mailing list faq / archives, the jGuru
site and the Zeus support site and now turn to help from the list.

I'm using a Cobalt RAQ4i with Cobalt Linux 6.0 and Zeus 3.3. I confess I
don't know what version of Tomcat I'm using - we installed a release build
in August - probably 3.2.

We followed the principles given in
http://support.zeus.com/products/tomcat.html to install Tomcat and
sucessfully mounted Tomcat's examples under /examples and they worked fine.

I have added a new web application called firstireland by adding dirs
firstireland, firstireland/WEB-INF, firstireland/WEB-INF/classes,
firstireland/WEB-INF/lib under $TOMCAT_HOME/webapps

I added the following line to server.xml inside <ContextManager> without
altering any other line

<Context path="/firstireland" docBase="webapps/firstireland" debug="0"
reloadable="true"/>

I created a web.xml based on the example in the TOmcat docs for my web
application and placed it in $TOMCAT_HOME/webapps/WEB-INF/. The key lines
are:

   <servlet>
   	<servlet-name>
   		HelloWorldExample
   	</servlet-name>
   	<servlet-class>
   		HelloWorldExample
   	</servlet-class>
   	<load-on-startup>
   		1
   	</load-on-startup>
   </servlet>

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

HelloWorldExamlpe is the simple servlet supplied in the Tomcat examples and
I intended to use it to test I had set up the new web application correctly.

When I start Tomcat from the command line in bash it tells me:

cannot load servlet name: HellowWorldExample

Tomcat logs show nothing beyond the fact that Tomcat has started up an
initialised an HTTP and an AJP12 connector

If I then try to request /firstireland/HelloWorldExample I get a JServ 404
error (understandable as the servlet wasn't loaded) and the following
exception error is added to Tomcat.log:

---<exception>---

Context log: path="/firstireland" Exception in init servlet Can't find
resource for base name LocalStrings, locale en_US
 java.util.MissingResourceException: Can't find resource for base name
LocalStrings, locale en_US
        at java.util.ResourceBundle.getBundle(ResourceBundle.java, Compiled
Code)
        at java.util.ResourceBundle.getBundle(ResourceBundle.java, Compiled
Code)
        at HelloWorldExample.<init>(HelloWorldExample.java, Compiled Code)
        at java.lang.Class.newInstance0(Native Method)
        at java.lang.Class.newInstance(Class.java, Compiled Code)
        at
org.apache.tomcat.core.ServletWrapper.initServlet(ServletWrapper.java,
Compiled Code)
        at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java,
Compiled Code)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java, Compiled
Code)
        at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
(Ajp12ConnectionHandler.java, Compiled Code)
        at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java,
Compiled Code)
        at java.lang.Thread.run(Thread.java, Compiled Code)
Context log: path="/firstireland" Can't find servet HelloWorldExample

---</exception>---

My understanding of this is that:

* the servlet isn't loaded at startup due to an undpecified error
* the request for the servlet causes Tomcat to try to reload it
* this time reloading it causes a more detailed error
* I assume these two errors are in fact the same
* I don't see a problem with HelloWorldExample as it worked fine under
/examples
* therefore it is a problem with the way I have set up the new webapp

My questions are:

* has anyone seen this before and can help?
* if not, what is "base name LocalStrings"? If I can find this, perhaps I
can understand the error
* any general thoughts?

THanks,

Simon





RE: Error loading servlets in Tomcat

Posted by Simon Freytag <si...@anondesign.com>.
Hi,

I've fixed my problem and thought I would report back for other people who
wanted to use the demo HelloWorldExample servlet to test that new webapps
had been correctly set up.

HelloWorldExample.java (from $TOMCAT_HOME/webapps/examples/WEB-INF/classes
in the default install) contains this line:

	String title = rb.getString("helloworld.title");

and rb is initialised by

    ResourceBundle rb = ResourceBundle.getBundle("LocalStrings");

and I hadn't copied this text file into my new webapp! So for others trying
the same thing, copy
$TOMCAT_HOME/webapps/examples/WEB-INF/classes/LocalStrings.properties to
[your webapp]/WEB-INF/classes/LocalStrings.properties

Simon