Manual Deploy 1st servlet tomcat6 fail, try login t6 manager, admin
Have been googling and reading many web sites but my HelloWorldS servlet never works.
I am trying to keep it simple, for now, no JSP, no HTML, no WAR, no packages.
In the browser, I am using the locallhost:8080, with various strings after that,
but always get 404 error, from tomcat6-formatted page.
I got frustrated with that, so read that manager and admin commands
may be of some use to my problem; I forgot exactly how, but, that is another (re-) investigation.
At first I got mini-windows with user/pw fields to fill in which kept coming back (try again).
Later, changed the admin and manager xml so it reflected the example in the file and tried again.
Now I get the 404 error here also.
Details to follow in next post.
Also, internal search function here, found nothing.
============= I tried a reply post did not work, I put detaild info here. ==================
Ubuntu 10.04, tomcat6, open java, Firefox browser
Trying to compile and unit test a java servlet on the same computer.
Try compile a servlet: works.
Intall of tomcat6 : works (I can get "welcome" html page.)
(I also get various tomcat6 error messages to the browser-firefox.)
Deploy servlet in tomcat6: does not work.
Deploy (configure & login) manager & admin to see what's wrong: no workie.
Put shell variable defs here. Take effect at shell startup.
Here are shell variables.
Start and Stop tomcat6 on command line, for Ubuntu.
(tomcat6 does seem to be answering without a cl startup)
sudo /etc/init.d/tomcat6 start
sudo /etc/init.d/tomcat6 stop
To find the tomcat process & pid on a command line.
ps -ef | grep tomcat
To find info about a process.
Put manager and admin defs and passwords here.(done)
:/var/lib/tomcat6/conf$ sudo more tomcat-users.xml
<?xml version='1.0' encoding='utf-8'?>
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
<user username="manager" password="secretpw" roles="manager"/>
<user username="bothma" password="secretpw" roles="manager,admin"/>
<user username="admin" password="secretpw" roles="admin"/>
Put servlet defs here. (done)
The packagename approach, seems a further complication that I have not used.
/WEB-INF/classes/ - This directory contains any Java class files (and associated resources) required for your application, including both servlet and non-servlet classes, that are not combined into JAR files. If your classes are organized into Java packages, you must reflect this in the directory hierarchy under /WEB-INF/classes/. For example, a Java class named com.mycompany.mypackage.MyServlet would need to be stored in a file named /WEB-INF/classes/com/mycompany/mypackage/MyServlet.class.
Web Application Deployment Descriptor
"basic web.xml file"
(a link to tomcat.apache.org/tomcat-6.0-doc/appdev/web.xml.txt )
I do not yet understand what this means and where it fits.
NOTE - The Servlet Specification includes a Document Type Descriptor (DTD) for the web application deployment descriptor, and Tomcat 6 enforces the rules defined here when processing your application's /WEB-INF/web.xml file. In particular, you must enter your descriptor elements (such as <filter>, <servlet>, and <servlet-mapping> in the order defined by the DTD (see Section 13.3).
(no link provided) Where is Section 13.3? I must google this.
Reading this now. Not immediately usefull or understandable.
Servlet definition, and so on.
:~$ cd $CATALINA_HOME
drwxr-xr-x 6 root root 4096 2012-07-20 22:00 ./
drwxr-xr-x 323 root root 12288 2012-07-20 21:58 ../
drwxr-xr-x 2 root root 4096 2012-07-18 02:16 bin/
drwxr-xr-x 2 root root 4096 2012-07-18 02:16 lib/
drwxr-xr-x 4 root root 4096 2012-07-20 22:00 skel/
drwxr-xr-x 4 curly root 4096 2012-07-23 00:44 webapps/
:/usr/share/tomcat6$ cd webapps
drwxr-xr-x 4 curly root 4096 2012-07-23 00:44 ./
drwxr-xr-x 6 root root 4096 2012-07-20 22:00 ../
drwxr-xr-x 3 root root 4096 2012-07-18 02:16 default_root/
drwxr-xr-x 3 curly root 4096 2012-07-23 00:12 dir-j1/
:/usr/share/tomcat6/webapps$ cd dir-j1
:/usr/share/tomcat6/webapps/dir-j1$ cd W*
drwxr-xr-x 3 root root 4096 2012-07-23 00:37 ./
drwxr-xr-x 3 curly root 4096 2012-07-23 00:12 ../
drwxr-xr-x 2 root root 4096 2012-07-20 16:51 classes/
-rw-r--r-- 1 root root 231 2012-07-23 00:37 web.xml
:/usr/share/tomcat6/webapps/dir-j1/WEB-INF$ more web.xml
:/usr/share/tomcat6/webapps/dir-j1/WEB-INF$ dir classes
:/usr/share/tomcat6/webapps/dir-j1/WEB-INF$ ll classes
drwxr-xr-x 2 root root 4096 2012-07-20 16:51 ./
drwxr-xr-x 3 root root 4096 2012-07-23 00:37 ../
-rw-r--r-- 1 root root 820 2012-07-20 16:51 HelloWorldS.class
they describe how to depoy a packageless servlet. Not so clear on paths.
Where is does this path start?
Test 1: A Servlet That Does Not Use Packages
The first servlet to try is a basic one: no packages or utility (helper) classes. Rather than writing your own test servlet, you can just download HelloServlet.java into your development directory, compile it, and copy the .class file to install_dir/webapps/ROOT/WEB-INF/classes. Right-click on the link to download the file to your system. Note: in all versions of Apache Tomcat, the location for servlets in the default Web application is install_dir/webapps/ROOT/WEB-INF/classes. However, in some versions of Tomcat (including Tomcat 6.0.10), the system doesn't create the classes directory for you automatically. No problem: just create it yourself. (Remember that case matters: WEB-INF is upper case, classes is lower case.) Note that my preconfigured Apache Tomcat version already contains the classes directory and already has the sample servlets.
Had to edit the above because forum computer did not want me to post urls until I had 15 posts.