• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Deploying a servlet to tomcat without making war file.

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sean Hetfield
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now after using mapping I get error 500 and classNotFoundException
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic