Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not Able to Deploy War Files in Tomcat 6

 
Prateek Gupta
Greenhorn
Posts: 17
Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you define the contexts "docBase" attribute ?
 
Prateek Gupta
Greenhorn
Posts: 17
Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18002
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic