Java servlet issue... Tomcat setup perhaps?

6

6e

Hi thanks for reading.

Im having some difficutly getting a servlet to run on my tomcat server.

I am able to run JSP files, but I am new with servlets.

I compiled a basic hello world file into a war file, and deployed it in
the webapps directory (it installed itself into web_apps\MyApp
directory. I manually moved it to the directory structure outlined in
many many tutorials.

After moving the files, I was able to get the servlet recognized, only
now I am getting an error stating "javax.servlet.ServletException:
Cannot allocate servlet instance for path /servlet/MyApp"

I checked the classpath, it includes the path to my jdk, ".", and
supporting Tomcat files.

I created a web.xml file, and placed it into that directory as well it
is written as follows:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name>MyApp</se­rvlet-name>
<servlet-class>MyApp</s­ervlet-class>
<load-on-startup>1</load-on-st­artup>
</servlet>
<servlet-mapping>
<servlet-name>MyApp</servlet-name>
<url-pattern>/MyApp</ur­l-pattern>
</servlet-mapping>
</web-app>

Any advice on things to check would be appreciated, I am stuck. I am
trying to work on this project for work and as time goes by I know that
this will become a much larger issue.

Thank you!
 
W

Wendy S

6e said:
I compiled a basic hello world file into a war file, and deployed it in
the webapps directory (it installed itself into web_apps\MyApp
directory. I manually moved it to the directory structure outlined in
many many tutorials.

Post the contents (filenames & directory structure) of your .war file. If
you want it to expand into a directory with a particular name under webapps
(not web_apps) then give the .war file that same name.

Since we cannot know what you moved where, the best thing is to start over,
get your .war file correct, and then it should work without moving files
around (which you would not want to do with a production webapp anyway.)

One thing I see is that your <servlet-class>MyApp</s­ervlet-class> is
missing the package name. It needs to have the fully qualified class name,
including the package. From the other error message, perhaps this should be
servlet.MyApp?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top