3

Sorry, but I tried searching for this subject, but I didn't find related to my problem. Recently, I bought a domain and web hosting for it. I bought it especially for using it for my Java projects. I have Tomcat available as server on the hosting.
My question is: how do I work with a hosted Tomcat, which, in my opinion, it is quite different from localhost (where you could have unlimited access)?


For example, if I create a Spring project that looks like this:

project-name

src
war

index.jsp
WEB-INF

web.xml

The index.jsp outputs a simple This is a test
web.xml

<welcome-file-list>
   <welcome-file>
      index.jsp
   </welcome-file>
</welcome-file-list>

I created an Ant build.xml that will build the project, but when I access from http://domain.com/project-name it will not work, and I only cand access the file from http://domain.com/project-name/war

If I had done this on localhost, I'd deploy it in tomcat-path/webapps, but how does this work online?

Andrei Sfat
  • 8,440
  • 5
  • 49
  • 69
  • What did you do to deploy the war? Just copy it to the webapps directory? Or used the tomcat manager (in case its installed)? – Dirk May 07 '11 at 21:09
  • Is the request being forwarded from Apache? If you are just running Tomcat, it runs by default on port 8080, and your browser will assume you are asking for port 80. Try http ://domain .com:8080/project-name – nicholas.hauschild May 07 '11 at 21:34
  • @Dirk Well, at first I just tried to copy it, but didn't work. (regarding tomcat manager, I need to have full access to it? Maybe I can convince my hosting admin to install it -- will I be able to deploy easier my applications?) @nicholas.hauschild I assume that Tomcat is configured to work on port 80, because on 8080 does not work at all – Andrei Sfat May 07 '11 at 21:42
  • If you have access to the tomcat (as you were able to copy it there), you probably can install it yourself. Not entirely sure about it. You can check if its installed already by trying context /manager where it usually lives. Furthermore, consider what nicholas.hauschild said above. Did your provider give any instructions what is the preferable way of deploying webapps in your domain? – Dirk May 07 '11 at 21:48
  • @Dirk - My bad, because I didn't understand at first what did you ask me about the fact that I can copy in to the webapps directory. Well, I don't have access to the /webapps, I'm just able to copy my jsp files into public_html and they work, but .war are not working. Any tutorials regarding configuring the way Tomcat deploys apps? Maybe I can tell my hosting admin what to configure to help me out. – Andrei Sfat May 07 '11 at 21:56
  • Oh ... I start to understand I guess. I really think its best to contact your hoster and ask how to access and deploy webapplications there. Being able to copy JSP into some place is not really helpful at all since the servlet logic and potential additional libraries come with the war. Dropping something into a public_html directory might work with something like php, but not tomcat. These wars need to be deployed and thats what the tomcat manager can be used for. – Dirk May 07 '11 at 23:41

1 Answers1

4

The solution is to install Tomcat Manager Webapp in order to deploy applications on a shared hosting that uses Tomcat as server.

EDIT:
If the hosting doesn't offer you Tomcat Manager (as was in my case), you can still make it through by asking the administrator of your hosting to configure your jk_mod file to deploy your war files.

Append these lines

jkMount /*.war ajp3
jkMount /* ajp3 ## I'm still not sure if this made it work, because it makes tomcat listen on the entire public_html

But be aware, if your version of Tomcat is brought to you by cPanel's EasyApache, you will have to deal with some issues there too - the latest installed Tomcat will be 5.5.33 (a bit old, right?), but again you can try tweaking the old version and install, let's say 6.x.x
A tutorial about this upgrade:

http://www.bestdesigns.co.in/blog/install-tomcat-6

The thing that help me a lot to understand the concepts that were envolved in solving this problem:

http://www.scribd.com/doc/6085698/Tomcat -- a training course about Tomcat and cPanel

An another thing to add: Install a local version of Tomcat on your machine, first deploy it on localhost. If there it works, it should be working online as well.

Those of you who work with Spring Roo, on Tomcat 5.5.33, if you already know, you cannot deploy your projects, becase of the too old Tomcat, so you have to upgrade your Tomcat immediately.

I hope this will help all of those who had difficulties like myself.

Andrei Sfat
  • 8,440
  • 5
  • 49
  • 69