Results 1 to 12 of 12
  1. #1
    whatif is offline Member
    Join Date
    Feb 2011
    Posts
    12
    Rep Power
    0

    Default tomcat server not found

    Hello,

    I'm trying to configure a tomcat server to start developing servlet/jsp but I get server not found. Here is what I did so far:

    Added CLASSPATH to .bash_profile and my servlet compiled successfully.

    I typed which java which outputted /usr/bin/java

    I then added export JAVA_HOME=/usr/bin/java to .bash_profile

    Removed the comments around servlet-mapping as well as the Invoker.

    Changed the permission of /usr/share/tomcat6/webapps to world access.

    Logged out as root and then logged into my regular account to create WEB-INF/classes under /usr/share/tomcat6/webapps

    I then moved the .class from the servlet I compiled to /usr/share/tomcat6/webappsWEB-INF/classes

    started a terminal, su to service tomcat6 start then switched user to my normal account and type service tomcat6 status, the output was tomcat 6 running.

    Finally, I started my web browser type localhost:8080/servlet/first
    and I got server not found. Tried localhost:8080, server not found; however, if I type 127.0.0.1:8080/servlet/first or 127.0.0.1:8080, I get a white page with no error message.

    The servlet first will only output Hello World.

    I couldn't find the Context path="" docBase="" reloadable="true" line in server.xml

    I also search in context.xml, web.xml, and tomcat-users.xml and couldn't find it.

    Any suggestions please?

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,038
    Rep Power
    20

    Default Re: tomcat server not found

    First off, don't add CLASSPATH to your profile.
    It's entirely unecessary and, in general, bad practice.

    Next, I would put your servlet into a package. Using the default package is not a good idea. It can cause import problems.
    Then I would ensure it is mapped. Do you have a web.xml for your app in WEB-INF?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    whatif is offline Member
    Join Date
    Feb 2011
    Posts
    12
    Rep Power
    0

    Default Re: tomcat server not found

    I added the CLASSPATH to .bash_profile because the servlet won't compile and this is how it was suggested to be added. Where should I add it if not in the profile?

    I don't have a web.xml for my app in WEB-INF. Many sources states that if I remove the comments around the Invoker that I don't need to write a web.xml, which is helpful during development. I don't know much about xml and was trying to find the easiest way to start learning servlet/jsp and as I learn I will get into other topics such as xml.

  4. #4
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,038
    Rep Power
    20

    Default Re: tomcat server not found

    How do you compile?
    If it's on the command line then:
    javac -cp<your classpath> <your classes>
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,038
    Rep Power
    20

    Default Re: tomcat server not found

    As for the web.xml, it's a fundamental part of a webapp, frankly, and skipping it is a hack that really doesn't help you understand how it all fits together.
    It's not as if it's a complicated file.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    whatif is offline Member
    Join Date
    Feb 2011
    Posts
    12
    Rep Power
    0

    Default Re: tomcat server not found

    If it's the web.xml that I'm missing, I will search online on how to write one. What about the <Context path="" docBase="" reloadable="true"> line in server.xml? Several online sources state I need to change the values of path and docBase but I can't find this line in server.xml

  7. #7
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,038
    Rep Power
    20

    Default Re: tomcat server not found

    I'd have to read the Tomcat docs, since I rarely have to touch those once a server is up.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  8. #8
    whatif is offline Member
    Join Date
    Feb 2011
    Posts
    12
    Rep Power
    0

    Default Re: tomcat server not found

    I created a web.xml file inside /usr/share/tomcat6/webapps/WEB-INF, which contains the following lines:

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

    <web-app>

    <servlet>
    <servlet-name>first</servlet-name>
    <servlet-class>first</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>first</servlet-name>
    <url-pattern>*.html</url-pattern>
    </servlet-mapping>
    </web-app>


    I used the following url:

    http://localhost:8080/servlet/first
    http://localhost:8080/servlet/first.class
    http://localhost:8080/servlet/first.html


    Still I get server not found. Any thing else I should try?
    Last edited by whatif; 12-13-2012 at 10:55 PM.

  9. #9
    whatif is offline Member
    Join Date
    Feb 2011
    Posts
    12
    Rep Power
    0

    Default Re: tomcat server not found

    I also tried a solution that was advice on a different forum, here it is:

    I create app/WEB-INF/classes/app under webapps

    added package app; to my servlet, compiled it and move the .class to webapps/app/WEB-INF/classes/app

    changed the web.xml to

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

    <web-app>

    <servlet>
    <servlet-name>first</servlet-name>
    <servlet-class>app.first</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>first</servlet-name>
    <url-pattern>*.example</url-pattern>
    </servlet-mapping>
    </web-app>

    save it to webapps/app/WEB-INF


    I used the following url:

    http://localhost:8080/app/servlet/first
    http://localhost:8080/app/servlet/first.class
    http://localhost:8080/app/servlet/first.html
    http://localhost:8080/app/servlet/first.example

    http://localhost:8080/app/first
    http://localhost:8080/app/first.class
    http://localhost:8080/app/first.html
    http://localhost:8080/app/first.example


    Still I get server not found!!!

  10. #10
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,038
    Rep Power
    20

    Default Re: tomcat server not found

    The latter one is the correct structure for the app, which is:
    webapps/<your application name>/<standard folder structure>

    Now it looks to me like it's Tomcat itself, which you really need to go through the docs for it step by step.
    That includes checking you have the correct basic values in the tomcat xml files.
    One of them might have the wrong port (for example).

    Was this a fresh download from Apache?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  11. #11
    whatif is offline Member
    Join Date
    Feb 2011
    Posts
    12
    Rep Power
    0

    Default Re: tomcat server not found

    I downloaded tomcat 7 and got it to work. Tomorrow I will test this simple servlet but I have one last question. Does the name of the directory under webapps have to be the same as the package directory? In the above listing it's apps, webapps/app/WEB-INF/classes/app. Could it be webapps/app/WEB-INF/classes/forms?

  12. #12
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,038
    Rep Power
    20

    Default Re: tomcat server not found

    No.
    The name of the directory is your web application name, and does not have to have anything at all to do with your packages.
    The package structure under classes, of course, must match your java class package structure.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. j_security_check was not found on this server
    By J_love in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-04-2011, 09:35 PM
  2. Tomcat Server Error
    By Ms.Ranjan in forum Advanced Java
    Replies: 2
    Last Post: 09-28-2010, 04:59 PM
  3. Replies: 0
    Last Post: 11-29-2008, 08:54 PM
  4. Reg Tomcat in Itaniumn Server
    By ars3181 in forum Advanced Java
    Replies: 0
    Last Post: 11-24-2008, 05:53 AM

Posting Permissions

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