Results 1 to 12 of 12
Thread: tomcat server not found
- 12-13-2012, 02:50 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 8
- Rep Power
- 0
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?
- 12-13-2012, 09:39 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
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.
- 12-13-2012, 02:58 PM #3
Member
- Join Date
- Feb 2011
- Posts
- 8
- Rep Power
- 0
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.
- 12-13-2012, 03:12 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
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.
- 12-13-2012, 03:13 PM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
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.
- 12-13-2012, 03:18 PM #6
Member
- Join Date
- Feb 2011
- Posts
- 8
- Rep Power
- 0
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
- 12-13-2012, 03:51 PM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
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.
- 12-13-2012, 08:10 PM #8
Member
- Join Date
- Feb 2011
- Posts
- 8
- Rep Power
- 0
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.
- 12-13-2012, 11:00 PM #9
Member
- Join Date
- Feb 2011
- Posts
- 8
- Rep Power
- 0
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!!!
- 12-14-2012, 09:21 AM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
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.
- 12-15-2012, 03:39 AM #11
Member
- Join Date
- Feb 2011
- Posts
- 8
- Rep Power
- 0
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-17-2012, 10:33 AM #12
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
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.
Similar Threads
-
j_security_check was not found on this server
By J_love in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 03-04-2011, 09:35 PM -
Tomcat Server Error
By Ms.Ranjan in forum Advanced JavaReplies: 2Last Post: 09-28-2010, 04:59 PM -
JAR library is found on local computer, but not from server
By AZMichael in forum NetBeansReplies: 0Last Post: 11-29-2008, 08:54 PM -
Reg Tomcat in Itaniumn Server
By ars3181 in forum Advanced JavaReplies: 0Last Post: 11-24-2008, 05:53 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks