my dog learned polymorphism*
The moose likes Servlets and the fly likes Help! Can't create Web-apps in Tomcat! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Help! Can Watch "Help! Can New topic
Author

Help! Can't create Web-apps in Tomcat!

Alexis Jones
Greenhorn

Joined: Jun 27, 2001
Posts: 4
Hi all,
I am using Tomcat in Windows to get some Servlet/JSP experience. I can run all the sample servlet/jsp files but I cannot run my own web application. I create a directory structure for my web-app like I am supposed to: C:\Tomcat\webapps\HelloWorld
C:\Tomcat\webapps\HelloWorld\web-inf
C:\Tomcat\webapps\HelloWorld\web-inf\classes
C:\Tomcat\webapps\HelloWorld\web-inf\lib
The servlet in the classes folder. All the enviroment variables etc is set up properly. I add a context to the server.xml file, and create a web.xml with servlet name and servlet class in the web-inf. But it doesn't run and I get the following error below. NOTE: If I run my servlet in the \test webapp folder, adding it to the web.xml file it runs fine. I just can't run it creating my own directories.
Any help would be greatly appreciated. It's Tomcat 3.2.1 by the way which should be stable right?
--Alexis
Error: 500
Location: /HelloWorld
Internal Servlet Error:
java.lang.NullPointerException
at org.apache.tomcat.util.FileUtil.isAbsolute(FileUtil.java:289)
at org.apache.tomcat.core.Context.getAbsolutePath(Context.java:257)
at org.apache.tomcat.core.Context.getRealPath(Context.java:791)
at org.apache.tomcat.request.StaticInterceptor.requestMap(StaticInterceptor.java:191)
at org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:820)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:771)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

I add a context to the
server.xml file, and create a web.xml with servlet name and servlet class in the web-inf.

You need to do either of these two things, not both, I guess.
Personally I would get rid of the web.xml file and try.
regds.
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

No that's not right.

The server.xml file is required to give you contexts.

The web.xml is required so that Tomcat can understand how to user your web app.

You need both.

Can you post the relative portion of your server.xml and your web.xml?
The error 500 makes me wonder though... it almost seems like a problem with the servlet you've written, although you say you can get it to run in a different directory.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

The web.xml is required so that Tomcat can understand how to user your web app. You need both.

yikes....
I neither agree nor disagree....
While the web.xml is required for
setting some application specific stuff,
I personally would neglect it in the beginning.
Once I am comfortable with running and deploying
simple applications in Tomcat, then is the time
to dig deeper into these. My two cents worth.
regds.
- satya
Alexis Jones
Greenhorn

Joined: Jun 27, 2001
Posts: 4
I figured it out and I feel really stupid. The problem was the first line with the web.xml file
I had this:
<? xml version="1.0"?>
When I changed it to this, everything is fine:
<?xml version="1.0"?>
I am new to XML and didn't know that one space would screw things up that much. Plus, nothing in the console output or error log file pointed that out to me. Thanks for your help everyone.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
..and I feel really stupid
and thats the bonus everyone gets with using Tomcat...

Sorry, couldn't resist the dig.
- satya

[This message has been edited by Madhav Lakkapragada (edited June 28, 2001).]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help! Can't create Web-apps in Tomcat!
 
Similar Threads
Servlet in Package Issue
Tomcat WebApp Deployment
Struts application with JBoss-2.4.4_Tomcat-3.2.3
HFS: Problem with deploying and testing Beer-v1 App
Tomcat Restarting