aspose file tools*
The moose likes Tomcat and the fly likes Deploying a servlet to tomcat without making war file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Deploying a servlet to tomcat without making war file." Watch "Deploying a servlet to tomcat without making war file." New topic
Author

Deploying a servlet to tomcat without making war file.

Sean Hetfield
Ranch Hand

Joined: Dec 01, 2003
Posts: 83
I have made 1 simple servlet and I try to deploy it to tomcat directly, without making war file and as a new entry in webapp called chapter_01.
I am sure that the directory I have made is right and also modified web.xml in my directoy to add a servlet entry and also add a context in server.xml for chapter_01 but still I am getting error trying to call my servlet in this URL http://localhost:2005/chapter_01/servlet/HelloWorldServlet

Any Idea?

Thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

web.xml needs to be in a directory called WEB-INF under your apps webapps dir.
The structure of your app should be as follows:

webapps/YOUR_APP_NAME/JSPS, HTML
webapps/YOUR_APP_NAME/WEB-INF/web.xml
webapps/YOUR_APP_NAME/WEB-INF/classes/YOUR_PACKAGE/YOUR_CLASSES

You'll also need to map your servlets (in web.xml)
The invoker servlet is no longer active by default in Tomcat.
You don't need '/servlet' in your URL once you map the servlet.
You also don't need to (and shouldn't) create a context entry in server.xml anymore. Check with the Tomcat documention for proper deployment procedures in version 5 and up.

If you want an example of a proper web.xml with a servlet mapping and the correct directory structure for a webapp, go to http://simple.souther.us,
download and run SimpleServlet.

Tomcat will unpack the war file for you. You can then examine both the directory structure and the web.xml file to see what's different in your app that's keeping it from working.

-Ben
[ January 22, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Sean Hetfield
Ranch Hand

Joined: Dec 01, 2003
Posts: 83
My structure is the same, but I am using tomcat 4 (and I have to) so I need to know without using war how to deploy a servlet(plus to what I have done).
Additionaly I put the SimpleServlet.war in both tomcat 4 and 5 and even though they unpacked, using the URL I got error to access them.

Sean
Sean Hetfield
Ranch Hand

Joined: Dec 01, 2003
Posts: 83
Now after using mapping I get error 500 and classNotFoundException
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Sean Mohseni:
My structure is the same, but I am using tomcat 4 (and I have to) so I need to know without using war how to deploy a servlet(plus to what I have done).
Additionaly I put the SimpleServlet.war in both tomcat 4 and 5 and even though they unpacked, using the URL I got error to access them.
Sean


Tomcat 4 handles war deployments.

What URL are you using?
SimpleServlet (as the name implies) is about the simplest thing that can be deployed in a container. What error are you seeing?
Sean Hetfield
Ranch Hand

Joined: Dec 01, 2003
Posts: 83
When I redploy SimpleServlet it is working fine, but if I understand right, you mean for tomcat 4, the only way to deploy a servlet is to make a war file? If I am wrong, what is the procedure, additional to what I have done before?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

No, you don't have to have a war file.
The directory structure just needs to be correct.
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/appdev/deployment.html

The reason I suggested running simpleServlet was for you to get something deployed in your server that you could use as a reference.
As long as your app has the same directory structure as than one, it will work.
 
 
subject: Deploying a servlet to tomcat without making war file.