File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[SOLVED] Tomcat 7 subdirectory mapping over WWW problem

 
Rolf Sperling
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a problem that I hope someone can help me with. When I navigate to the http://mysite.com/me/public_html/tomcat folder I see the default page, indicating that I have installed the server somewhat correctly and it works.
However, when I hover over the links on the page I notice that they are directed to http://mysite.com/docs/setup.html, http://mysite.com/manager/html and so on. Obviously there
is no "docs" or "manager" folder on the root of the web server, so this results in a 404 Not Found error. It does work locally, but that is not enough.

Similarly, if i try to navigate to http://mysite.com/me/public_html/tomcat/ROOT I get a Resource not found error from Tomcat even though the ROOT application is exactly the same application that works at public_html/tomcat/! So I cannot even begin to produce my own web apps because no subdirectory under the webapps dir can be accessed over WWW (I also tried making a simple Hello World servlet of my own under webapps/hello/ but it didn't work).

I am completely stuck. I have tried editing the server.xml, context.xml, web.xml and .htaccess files with all possible variations of the pathname syntax. I have researched this on the net and tried everything that I could think of for probably 2 full days work in total. I would never have thought that getting Tomcat up and running would be so painstakingly difficult.

Any advice? Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat actually is incredibly easier to get up and running. You unpack it, make sure that JAVA_HOME is set the right value, and start it. Instant Tomcat.

But it sounds like you are doing some odd things.

Fir example, public_html? What's that? It's not one of the standard Tomcat folders. If you go in and start moving things around, yeah, things are going to go belly up.

There are lots of config options, but one of the easiest ways to get a web app going on Tomcat is to properly pack it up as a war file and drop it into the webapps folder. Tomcat takes care of the rest.
 
Rolf Sperling
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Um. Maybe i haven't expressed myself clearly. To avoid confusion, first I should probably have mentioned that I do not own or maintain the web server. I have only rented web space + services there.
Tomcat 7.0.8 I have installed in my home directory.

Getting Tomcat up and running was not a problem. Like I said, it works locally on the web server that i can access via SSH.

Public_html is the directory on the web server where you put stuff you want other people to see over the Internet with their web browser. Right?
I also have a redirect domain to the web server, so that navigating to http://www.mysite.com will get you to the public_html directory on the web server.
In public_html I have a "tomcat" subdirectory that contains an .htaccess file. This should redirect requests to that address to the Tomcat server. And it does.
I can go to that address on any computer with an Internet connection and a web browser and see the "Congratulations, you have successfully installed Tomcat!" default page.

My problem is, that 1. the links on the default page are crooked, meaning they point in the wrong place and they don't work 2. That particular page, which is actually
defined in Tomcats webapps/ROOT/ folder does not work if I try to access it via the URL http://www.mysite.com/tomcat/ROOT 3. Any other page or servlet which is in a subdirectory
of the public_html/tomcat directory does not work (Funnily, just like 3,5 years ago when I last used [some previous version of] Tomcat the only error message is "Requested resource not found" which
is kind of not helpful in any way).

Do you mean there is some completely other way of accomplishing this goal of mine (a public Servlet on the WWW)? I think I just have something configured wrong (by default, as it does not work as one would expect out of the box).

Thanks


 
Rolf Sperling
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. I still don't know what I did wrong the first time, but I found a solution.

I went to the webapps directory, made a full copy of the ROOT app and renamed it "copy". I noticed that this "copy" app works like a charm.
I also noticed that after all this screwing around, it also works like I thought it would in the first place! I can just go:


cd TomcatRoot/webapps
mkdir testApp256
cd testApp256
vim index.html


etc. and the page is accessible over WWW. The changes that I did to Tomcat when I took it out of the box include:

* set the Connector and Server ports in conf/server.xml to ports recommended by my web server administration (in my case 38257 and 38255, respectively)
* set the Connector proxyName and proxyPort parameters in conf/server.xml correctly (in my case "http://www.mysite.com/me/tomcat" and 80

and probably something else. In the public_html/tomcat folder I have an .htaccess file containing


RewriteEngine On
RewriteRule ^(.*)$ http://localhost:38257/$1 [P]


After this, the Tomcat default page (but nothing else) was accessible over WWW. I don't remember clearly what else I might have done.

But now that it works, I don't want to touch anything to not break it again
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic