PDA

View Full Version : Ubuntu 9.10 / Tomcat6.024 Servlet Deployment Issues



RobynM
March 17th, 2010, 10:34 PM
Hi,
I am new to Ubuntu and to Servlets in general, and I am having difficulties deploying my first Servlet. I believe that I have Tomcat 6 installed properly and running as I get the Tomcat page when I visit the url http://localhost:8080. The problem I have is when I create a simple servlet, MyServlet.java and compile it to get MyServlet.class. I have also created web.xml.
When I navigate to my tomcat/webapps directory I create the folder proj1. Inside this folder I create WEB-INF, in which place the file web.xml and also a newly create folder 'classes' which I place the file MyServlet.class.

According to everything I have read this should be sufficient to allow me to visit the url http://localhost:8080/proj1/servlet.

When I do this however I get the http 404 error "resource() not available"
Has anyone come across this problem and discovered a solution?

R.

myrtle1908
March 18th, 2010, 12:26 AM
Have you referenced you servlet in the web.xml? Here's an example ...


<servlet>
<servlet-name>ImageUpload</servlet-name>
<servlet-class>com.figtree.carica.server.ImageUpload</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ImageUpload</servlet-name>
<url-pattern>/ImageUpload</url-pattern>
</servlet-mapping>

RobynM
March 18th, 2010, 12:41 AM
I sure have.

myrtle1908
March 18th, 2010, 12:46 AM
Well then to access your servlet you must use the correct URL eg.

http://localhost:8080/proj1/MyServlet

assuming your servlet is named MyServlet.

Some Penguin
March 18th, 2010, 06:22 AM
Verify that you're using the Servlet-Name, and not the class name.

Also, check the catalina.out; it's entirely possible that your servlet threw some exceptions.

RobynM
March 21st, 2010, 06:31 AM
no problems in catalina.out
in fact no exceptions that I can see at all.

I am really stumped as to why I can run the servlet examples but cannot deploy any of my own. I have verified my xml syntax and my java class file(s) repeatedly.