• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Tomcat + Windows Server 2008 Can't Find Context?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have been developing with Tomcat 5.5 on XP/2003 machines for quite a while now with no problems. I am now trying to set up Tomcat on a new pc with Windows Server 2008 (32 bit edition) and cannot seem to get my apps working. Basically, when I startup Tomcat, it doesn't attempt to load any apps configured in the <context> nodes in the server.xml. There are no errors, it just seems to ignore them completely. I tried installing Tomcat 6 but have the same issue.

Any ideas?

Thanks,
Nick
 
Saloon Keeper
Posts: 28325
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You really shouldn't be defining Context nodes in server.xml. That's been discouraged since Tomcat4. The better procedure would be to make each Context be a separate xml file in TOMCAT_HOME/conf/Catalina/localhost or in the meta-information in the WAR. Check the Tomcat docs for details.

Despite that, you should still be able to define contexts in server.xml, you just shouldn't. The Tomcat logs should be giving you some kind of indication as to what Tomcat is doing when it finds a context and attempts to start it up.

You are capitalizing the element name properly, I hope. It's "Context" with a capital C. Like all XML, upper/lower case usage is critical.
 
Nick Reeve
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,

Thanks for your reply. I have tried moving my context out of the server.xml and into it's own file in the localhost folder and have the same results. I checked it on my old pc and it works fine there. Here is the output from Tomcat:



Thanks,
Nick
 
Tim Holloway
Saloon Keeper
Posts: 28325
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmmm. It's obviously not seeing your context definitions. Make sure you're doing the following:

1. Place the context definition file in %CATALINA_BASE%\conf\Catalina\localhost\ and make sure it's readable by whatever account Tomcat's running under.

2. Make sure that the filename extension is ".xml". Example: "mywebapp.xml". And be sure that you make that ""xml" in lower case. Although Microsoft Windows is pretty casual about upper/lower case in filenames and directories, Java is not.

3. The format for a deployment descriptor file should be as follows:



I've included a DBCP connection pool definition in this example - it's fairly typical for me. Note that I'm not dropping my WAR file in CATALINA_BASE/webapps, I'm using an external location.

You might want to clean up the Tomcat directories just to ensure that old garbage isn't mucking up the deploy process:

1. Delete all subdirectories under CATALINA_BASE/work/Catalina/localhost/
2. Delete everything under CATALINA_BASE/temp/
3. Delete any WARS or application directories that belong to you in CATALINA_BASE/webapps/

And you might want to clean out the CATALINA_BASE/logs directory just for completeness.

Keep a spare copy of your Context file. If Tomcat decides the deployment is defective, it will delete the copy that's in CATALINA_BASE/conf/Catalina/localhost
 
Nick Reeve
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I have figured it out and it's a weird one. For anyone that comes across this problem, here is what's going on:

Turns out that when I was editing both the server.xml and then creating the context files under localhost, Windows was actually creating files elsewhere in a 'virtual location'.

I found that browsing in windows explorer showed that the new context file didn't exist even though I had created it there and could see it in my text editor. There is a button on the toolbar in explorer called 'Compatibility Files' and clicking that shows the file. It's not actually saved there though which explains why Tomcat can't see it. Here is some info on it:
http://www.hanselman.com/blog/VistasShowCompatibilityFilesAndTheScrumptiousWonderThatIsFileVirtualization.aspx

Basically ensure that you have explicit adminstrator rights to that folder and it will work.

Thanks very much for your help Tim.
 
Those who dance are thought mad by those who hear not the music. This tiny ad plays the bagpipes:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic