Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Context paths always coming up as "The requested resource is not available"

 
Hans Otjes
Greenhorn
Posts: 9
Eclipse IDE jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recently started using Tomcat 6 for some webapps and now I can't seem to configure context paths.

First I put it in server.xml, but that didn't work, and reading on http://tomcat.apache.org/tomcat-6.0-doc/config/context.html, I saw it was not recommended either

Then I tried to define one in the $CATALINA_BASE/conf/[enginename]/[hostname]/ dir. but no luck either!

Does this ring a bell for anyone?



So my server xml for 6 looks like

<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
<Context path="/test" docBase="C:\apps\docs\test" crossContext="true" />
...
</Host>


and I also tried it with C:\development\servers\apache-tomcat-6.0.30\conf\Catalina\localhost\test.xml
with in it: <Context docBase="C:\apps\docs\test" crossContext="true"></Context>

In Tomcat 5 it still works fine.

Thank you for reading!

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My own (working) context files contain the path="/contextpath" attribute.

For example:
 
Hans Otjes
Greenhorn
Posts: 9
Eclipse IDE jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In server.xml it has that, but it shouldn't have that when you try to use the
$CATALINA_BASE/conf/[enginename]/[hostname]/[pathname].xml

the pathname is derived from the xml name (minus .xml), so in my example it's already got that set as 'test'
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just saying.

I have nothing in my server.xml except the empty <host> declaration.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. The Tomcat Manager app will show you whether the contexts have even been recognized and/or deployed.
 
Hans Otjes
Greenhorn
Posts: 9
Eclipse IDE jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I appreciate the suggestion. I did try that, to add the path attrib in there as well, but still the same.

I don't know the manager app, will have to see how I can get to that. Thanks!
 
Hans Otjes
Greenhorn
Posts: 9
Eclipse IDE jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, weird, the /test context shows as running!!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so that means Tomcat has recognized the context as valid and deployed it. That narrows down the problem quite a bit. The next most likely culprit is the URL you are using to hit the app.
 
Hans Otjes
Greenhorn
Posts: 9
Eclipse IDE jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The manager itself (which runs at http://localhost:8080/manager/html) points to

http://localhost:8080/test/

also tried http://localhost/test/

I've also tried to access files directly that I know are in that directory
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have an index.jsp or index.html at the context root? Or some other welcome file configured? If there's nothing there to serve, you'll get an error (unless you've enabled directory listings).
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hans Otjes wrote:I've also tried to access files directly that I know are in that directory

Give us some details.
 
Hans Otjes
Greenhorn
Posts: 9
Eclipse IDE jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was hoping to see a directory listing.
Where would you enable that?

For your second question. In the test folder, there are files like "icon.png"

so I've put that string in the above mentioned urls as well, to make sure it wasn't just a listing issue
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hans Otjes wrote:I was hoping to see a directory listing. Where would you enable that?

In Tomcat's conf/web.xml file, you'll find the following (in mine it's at line 102):
change the value to true.

For your second question. In the test folder, there are files like "icon.png" so I've put that string in the above mentioned urls as well, to make sure it wasn't just a listing issue

Hmm, so icon.png is in the same folder as WEB-INF, and yet /test/icon.png results in a 404? Anything in the logs?
 
Hans Otjes
Greenhorn
Posts: 9
Eclipse IDE jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This folder is not really a webapp, just a directory in my filesystem to host some loose files (in my case swf files)

So there is no WEB-INF directory.



Does listings - false mean it's disabled? or enabled?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Listings == false == disabled.

And, oh. Yeah. Create a WEB-INF and a WEB-INF/web.xml. Otherwise, nothing is guaranteed to work.
 
Hans Otjes
Greenhorn
Posts: 9
Eclipse IDE jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Didn't work either.
It must be sth else, tomcat 5 didn't require me to do that either....

It's for local testing, so I'll just have my swfs built in the root dir so I can test them there. Not ideal, but I've spent too much time on this.

Thanks for your help & suggestions!
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18162
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hans Otjes wrote:This folder is not really a webapp, just a directory in my filesystem to host some loose files (in my case swf files)

So there is no WEB-INF directory.



Does listings - false mean it's disabled? or enabled?


I'll forgo the screaming large type WEB server is NOT FILE server admonition. I already did that once here this week. Bear's advice is accurate.

However, I have recently discovered to my sorrow that if you place context xml file in TOMCAT_HOME/conf/Catalina/localhost, the context name it will be deployed under will be taken from the NAME of the context file, not the context name supplied in the file.
 
Hans Otjes
Greenhorn
Posts: 9
Eclipse IDE jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried the web inf + web.xml suggestion, based it on the webapps/docs sample, but still no success

On it not being a file server, I know that, I just need to have local access to some swf files, loading them from file system has you run in to security limitations.

And again, this was working fine on tomcat 5.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18162
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just so long as you know! Too many people don't, alas.

I know of no changes between Tomcat5 and Tomcat6 that would make a difference. I suggest looking at catalina,out and the localhost log to see if there are any interesting messages in there. Including what context path the webapp was deployed under.

Just for general info, I also recommend using the Unix-style path format over Windows-style (C:/apps/docs/test). Backslashes can bite in Java.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic