views:

30

answers:

1

I've created a servlet app using Netbeans and it works on my local machine. Now I need to deploy the app to my college class Tomcat 6 instance. The instance is set up like so: /java/tomcat/webapps/<student_id>, where student_id are the 30 student IDs for my class.

What exactly do I need to deploy to /java/tomcat/webapps/elvin in order to get my servlets to work? I don't have root access to this machine and I can only write to /java/tomcat/webapps/elvin.

Thanks.

A: 

Easiest would be to let Netbeans create/build a WAR file (there should be one in project's /dist folder) and then extract it locally using some ZIP tool and finally copy the extracted contents unchanged into /webapps/elvin.

Several things to check:

  • Servlet classes should go in a package. Packageless servlets will fail in certain configurations. Java classes should go in a package anyway.
  • The Servlet version as declared in web.xml must be supported by Tomcat version in question.
    • Tomcat 7.0 supports max Servlet 3.0
    • Tomcat 6.0 supports max Servlet 2.5
    • Tomcat 5.5 supports max Servlet 2.4
    • Tomcat 5.0 supports max Servlet 2.3.
BalusC
I did exactly that yet the servlet that's called from my index.jsp can't be found.
Elvin
Is the servlet class placed in `WEB-INF/classes/com/example/Servlet.class`? Is the package structure correct? Is the servlet mapped in `web.xml`? Do you have access to Tomcat startup/deploy logs?
BalusC
Yes, the classes are under the proper path under WEB-INF. The servlet is mapped in web.xml. I used the same web.xml that worked on my local machine.
Elvin
How about the logs? Servlets are in a package, right? Which Tomcat version is it? Which Servlet version is declared in `<web-app>` of `web.xml`?
BalusC
OK, I figured out the problem. I was deploying into /webapps/elvin/project1. So the WEB-INF was under project1. Once I moved WEB-INF up one directory to /webapps/elvin/WEB-INF, the servlet was executed correctly. Thanks.
Elvin
You're welcome :)
BalusC