Results 1 to 6 of 6
  1. #1
    wombatvvv is offline Member
    Join Date
    Sep 2010
    Posts
    2
    Rep Power
    0

    Default Please help setting up Tomcat. Very frustrating.

    Hello,

    I've decided to give JSP a shot. I have some experience with Java, but usually do web development with PHP.

    Unfortunatley I'm having nightmares getting Tomcat setup. It's extremely frustrating. :mad:

    I'm using Tomcat 6 on Ubuntu 10.

    I've gone through about four tutorials I found on the web, none of which seem to work properly, or contain stuff in all different directories. In the end, I basically just installed it all from the package manager.

    I got to the point where I can get the manager thingy running using http://127.0.0.1:8080/manager/html, and I can login using a username and password I set in some users.xml file.

    I then tried to edit the server.xml file to get tomcat to use port 80 and to load pages from a specific directory by default. (Like DocumentRoot in PHP). But I just can't get this to work. In fact, I managed to break everything and have to re-install the whole thing from scratch.

    So, going from the various tutorials floating around the web, the two things I changed were:

    Java Code:
        <Connector port="8080" protocol="HTTP/1.1" 
                   connectionTimeout="20000" 
                   URIEncoding="UTF-8"
                   redirectPort="8443" />
    So that port = "80" instead of "8080"

    ... and ...

    Java Code:
    <Host name="localhost"  appBase="webapps"
                unpackWARs="true" autoDeploy="true"
                xmlValidation="false" xmlNamespaceAware="false">
    so that appBase = "/media/Shared/websites/MySite/web"

    BTW, web is just a directory that NetBeans put there. I assume that's where it should be pointing to, as NetBeans also made a Hello World jsp file in that directory.

    If I then go to 127.0.0.1, I just get a page not found error. If I just change the appBase attribute and not the port, and go to 127.0.0.1:8080, I get blank page with no source code in it - and I get that page no matter what path I put, eg. 127.0.0.1:8080/blahblah/ even if blahblah does not exist.

    ... setting up NetBeans was another nightmare. God knows why they can't just make it easy. You'd think it would work smoothly with Tomcat, but apparently not. The trouble was that it was looking for the server.xml file in some place where it didn't exist by default. I had to make a symollic link to server.xml in the /usr/shared/tomcat6 directory to get it to work! (original file was found in /etc/tomcat6)...

    Anyway, NetBeans beside the point as I got that working in the end. Now I just want to get my site to work.

    Please someone help. I'm losing my hair over this. Past midnight now so I'm going to hit the sack and hopefully some nice person will have sorted this out for me in the morning. Tell me to do a search and I'll come over an open a can of whoop ass.

    Thanks in advance!

  2. #2
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    195
    Rep Power
    5

    Default

    Um,

    Not sure what you're doing.

    but this is the steps I take and it works fine to me.

    1. Place the tomcat folder /usr/shared/
    2. Place website folder into /usr/shared/tomcat6/webapps.
    3. Run the startup file in bin.

    http://localhost:8080/WEBSITENAME/
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

  3. #3
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    I haven't worked with netbeans, but the general idea of a web application inside tomcat's docroot (where ever you have configured that appBase to point to). the folder inside this is the web app context.. so /mywebapp/ is the path following the http://localhost/mywebapp/

    It used to be in earlier tomcats, that tomcat would not boot up the web application unless you had a web application deployment descriptor (WEB-INF/web.xml)

    so, if you get "unavailable" messages when trying to access your web application, try
    - create the web.xml inside a WEB-INF folder inside your webapplication folder. An empty file is sufficient.:

    Java Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app>
    </web-app>
    Then restart tomcat process, and navigate to a JSP inside your app.

  4. #4
    wombatvvv is offline Member
    Join Date
    Sep 2010
    Posts
    2
    Rep Power
    0

    Default

    Hmmm ... thanks very much guys, although none of that is really what I want to get done.

    I want to get it so when I got to 127.0.0.1 (or localhost), then it loads my web pages as default, just like the DefaultRoot setting in the httpd.conf file for PHP.

    This morning I half figured out to do it myself.

    I went into: /etc/tomcat6/Catalina/localhost/ and discovered some XML files that point to various directories for the examples pages etc. I just copied one of those with my own name, "MySite.xml", and edited the one line within to point to my site directory:

    Java Code:
    <Context path="/MySite" docBase="/media/Shared/websites/MySite/web/" />

    ... and now it works if I go to 127:0.0.1:8080/MySite/

    Which is half way there.

    On a side note, my examples pages, etc. were not in the webapps directory. There is nothing in there except another directory called default_root and a Hello World! jsp page in that. The examples/manager pages, etc. were all references with XML files as described above and put in other directories (e.g. /usr/share/tomcat-6-examples/).

    If I edit the /etc/tomcat6/server.xml file and change the line (in my first post) to read port="80" instead of 8080, then nothing works. I don't get any error messages, I just get blank pages when I try and access localhost.

    Also, I'd prefer to just be able to use 127.0.0.1, instead of having to append some directory on the end. But that's not a huge issue.

    Can anyone help get me the final steps?
    Last edited by wombatvvv; 09-11-2010 at 02:26 AM.

  5. #5
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    well, tomcat understands a default web application (the "/" path to get into it), by looking for a folder named "ROOT" within the webapps directory.

    so for example, if you create a ROOT/index.jsp in your webapps folder, (possibly restart tomcat after creating ROOT folder the first time), it should then be accessible from localhost/index.jsp

  6. #6
    s2sgateway is offline Member
    Join Date
    Sep 2010
    Posts
    17
    Rep Power
    0

    Default

    Each folder must have a index file to make this work so create a index file otherwise lisiting may not be supported
    And in server.xml if you change the port, then change like 8086 or 8084 or different port, because default localhost holding 80 and 8080,127.0.0.1
    Last edited by s2sgateway; 09-12-2010 at 06:57 AM. Reason: additional info

Similar Threads

  1. Setting Up Tomcat 7.0 in Netbeans IDE 6.9
    By contributor in forum NetBeans
    Replies: 0
    Last Post: 08-27-2010, 07:19 AM
  2. Setting the DSN
    By tim in forum JDBC
    Replies: 1
    Last Post: 02-14-2008, 10:55 PM
  3. Tomcat In Eclipse - Sysdeo Tomcat Plug-in
    By JavaForums in forum Eclipse
    Replies: 1
    Last Post: 02-13-2008, 11:33 AM
  4. Help with setting up please
    By BlitzA in forum New To Java
    Replies: 6
    Last Post: 12-29-2007, 01:54 PM
  5. Help with setting number as even or odd
    By fegiflu in forum New To Java
    Replies: 8
    Last Post: 07-24-2007, 07:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •