This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Not Able to Deploy War Files in Tomcat 6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Not Able to Deploy War Files in Tomcat 6" Watch "Not Able to Deploy War Files in Tomcat 6" New topic
Author

Not Able to Deploy War Files in Tomcat 6

Prateek Gupta
Greenhorn

Joined: May 31, 2010
Posts: 17

Hi,

Im Using Tomcat 6 and when I try to deploy a WAR file, Tomcat throws the following error..
I created a META-INF/context.xml file. But the error still persists... Kindly Help me out please

INFO: Server startup in 671 ms
May 31, 2010 5:17:50 AM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/Sample]
May 31, 2010 5:17:50 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive Sample.war
May 31, 2010 5:17:50 AM org.apache.catalina.startup.ContextConfig init
SEVERE: Exception fixing docBase for context [/Sample]
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:395)
at java.io.File.getCanonicalPath(File.java:531)
at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:154)
at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:882)
at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:1017)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardContext.init(StandardContext.java:5439)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4215)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1345)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:595)
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

How did you define the contexts "docBase" attribute ?


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Prateek Gupta
Greenhorn

Joined: May 31, 2010
Posts: 17

I defined the docBase in context.xml file which is as follows

<context docBase="C:\apache-tomcat-6.0.26\webapps\Sample.war">

<WatchedResource>WEB-INF\web.xml</WatchedResource>

</context>
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Are you using the context tag in server.xml? If no, then you don't have to use any attribute with <context../> tag.
Prateek Gupta
Greenhorn

Joined: May 31, 2010
Posts: 17

No. Actually, i havn't created a server.xml file.
I created a context.xml file and stored it under META-INF folder.

Can you please elaborate on what should be included in the context.xml file??
Prateek Gupta
Greenhorn

Joined: May 31, 2010
Posts: 17

I was just going through the error and the first few lines are as follows :

SEVERE: Exception fixing docBase for context [/Sample]
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:395)



Can it be some problem with the Windows File System??? Im using Windows 7 64-bit OS....
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

The allowable elements of a context.xml file are described in the Tomcat documentation.

However, your sample XML is defective. XML is case-sensitive and the proper element specification is "Context", not "context". Also, I recommend using "Unix" syntax for pathnames, not Windows. Sometimes the backslashes get interpreted as escape characters.

Here's a working context xml file:


Customer surveys are for companies who didn't pay proper attention to begin with.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Prateek Gupta wrote:i havn't created a server.xml file.

Well, you never create the server.xml, its a file provided by the Tomcat itself. I just repeat my above statement, if you didn't touch the server.xml, then you can skip the attribute for the <context/> tag, that means the file should be look like this
Prateek Gupta
Greenhorn

Joined: May 31, 2010
Posts: 17

Its still giving the same error...
Actually, the error occurs only when I create the WAR file and try to deploy it on the server....
When I use the exploded form, then it works fine and Im able to access it using the URL localhost:8080/Sample
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

OK, Perform the following steps and find out whether it works for you or not .

1. Stop the server
2. Delete the existing your web app from "webapps" dir
3. Clean the "eork" dir and delete the "conf/localhost" dir.
4. Redeploy the war
Prateek Gupta
Greenhorn

Joined: May 31, 2010
Posts: 17

Finally, my war file got deployed on tomcat.
It seems the war file being created was corrupt...
I was using the following command to create the war file.
jar cvf Sample.war C:\Sample\

Still cant understand why it was creating corrupt WAR files.
Now, I created the WAR file using the deploytool of J2EE Application Server and the file got executed perfectly.

Thanks for all your help.....
Abhijeet Mohanty
Greenhorn

Joined: Jun 02, 2010
Posts: 13
There could nothing be wrong in that. It's the correct command to create a war file from command prompt. Can try once more after following the steps been suggested by Sagar which actually would clear all the server's cached entities. It will surely work out.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not Able to Deploy War Files in Tomcat 6
 
Similar Threads
disappearing .war file on tomcat 6
What can cause a .war file not to show/load?
Not able to start the application in tomcat
Not Able to deploy WAR Files in Tomcat 6
virtual host in tomcat