You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by mdunford <ma...@gmail.com> on 2009/04/02 17:43:21 UTC

Tomcat 6.0.18 examples recompile ok but dont work!!

I installed Tomcat 6.0.18 on Mac OS X 10.5.6 (brand new iMac) 

Examples all worked fine. E.g the HelloWorldExample displays 
"Hello World" in my browser window. 

So I then recompile it just to check that this works using: 

javac HelloWorldExample.java  

It compiles fine. (My javac version is at 1.6.0_07) 

But when I reload in my browser I get 

HTTP Status 404. The requested resource is not available. 

I restarted Tomcat. No joy either... 

Anyone know what the heck is going on here...??? 
-- 
View this message in context: http://www.nabble.com/Tomcat-6.0.18-examples-recompile-ok-but-dont-work%21%21-tp22850460p22850460.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat 6.0.18 examples recompile ok but dont work!!

Posted by mdunford <ma...@gmail.com>.

The recompiled class is in the examples/WEB_INF/classes dir, same as before,
I cd there 
before recompiling ....


Caldarale, Charles R wrote:
> 
>> From: mdunford [mailto:martin.dunford@gmail.com]
>> Subject: Tomcat 6.0.18 examples recompile ok but dont work!!
>> 
>> But when I reload in my browser I get
>> 
>> HTTP Status 404. The requested resource is not available.
>> 
>> I restarted Tomcat. No joy either...
> 
> Are you running Tomcat with a 1.6 JRE?  If not, your recompiled class
> won't be loadable.
> 
> Where did you put the recompiled class file?
> 
> What's in the logs?  Uncomment the AccessLogValve in conf/server.xml for
> more information about what requests are coming in.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tomcat-6.0.18-examples-recompile-ok-but-dont-work%21%21-tp22850460p22855831.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat 6.0.18 examples recompile ok but dont work!!

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: mdunford [mailto:martin.dunford@gmail.com]
> Subject: RE: Tomcat 6.0.18 examples recompile ok but dont work!!
> 
> > javac -cp ../../../../lib/servlet-api.jar HelloWorldExample.java
> 
> I tried this. No luck.

Do you get any errors on the javac?  Did you get any errors from javac when you used it without the -cp arguments?  (If you didn't, then something is seriously broken in javac, since it wouldn't know how to resolve references to the javax.servlet package.)

Does javac actually produce anything useful on your Mac?

> > Do you have a JAVA_HOME or JRE_HOME environment
> > variable set?

> No, how should I set these?

You must have one or the other in order to run Tomcat from the scripts - unless your installation has modified the standard scripts.  The value of JAVA_HOME should be the path of the directory in which a JDK is installed, and JRE_HOME is the path to the JRE, if you're not using a JDK.

How are you starting Tomcat?  If it's from within an IDE, that may be masking a multitude of sins.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat 6.0.18 examples recompile ok but dont work!!

Posted by mdunford <ma...@gmail.com>.


>> I go and recompile HelloWorldExample 
>> javac HelloWorldExample.java

> javac -cp ../../../../lib/servlet-api.jar HelloWorldExample.java

I tried this. No luck. 

>I've done the same thing on my 6.0.18 installation, and it works fine.  Do
you have a JAVA_HOME or >JRE_HOME environment variable set?  If so, what's
the value?

No, how should I set these?

One last thing. I installed latest Java and Tomcat on my Asus PC (Xandros
Linux),
and did exactly what I'm trying to do here without a problem i,e I
recompiled 
HelloWorldExampe.java and it worked perfectly. Since my JRE/JDK appears to 
be same on Mac and Linux box and Tomcat is the same I am baffled...



-- 
View this message in context: http://www.nabble.com/Tomcat-6.0.18-examples-recompile-ok-but-dont-work%21%21-tp22850460p22872497.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat 6.0.18 examples recompile ok but dont work!!

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: mdunford [mailto:martin.dunford@gmail.com]
> Subject: RE: Tomcat 6.0.18 examples recompile ok but dont work!!

> I go and recompile HelloWorldExample 
> javac HelloWorldExample.java

That's not sufficient to compile a servlet.  You will also need a -cp argument to inform the compiler where servlet-api.jar is located.  If you attempt to do this via the CLASSPATH environment variable - don't.  Using the CLASSPATH variable is a major cause of classloading confusion and difficult to diagnose problems.  If you have CLASSPATH defined, get rid of it before doing anything else, and smack yourself if you ever feel tempted to use it again.

When your current directory is ${catalina.base}/webapps/examples/WEB-INF/classes, your javac line should look like this:

javac -cp ../../../../lib/servlet-api.jar HelloWorldExample.java

>     Sure enough log shows
>     0:0:0:0:0:0:0:1%0 - - [02/Apr/2009:15:48:58 -0400] "GET
> /examples/servlets/servlet/HelloWorldExample HTTP/1.1" 404 952

I've done the same thing on my 6.0.18 installation, and it works fine.  Do you have a JAVA_HOME or JRE_HOME environment variable set?  If so, what's the value?

You should also be able to find additional information in the logs, including a possible stack trace of the underlying problem.

> There has never been an examples/servlets/servlet directory...

Don't confuse URL paths with file system paths - they're independent.  If you look in webapps/examples/WEB-INF/web.xml, you'll see a servlet mapping for /servlets/servlet/HelloWorldExample that targets the servlet named HelloWorldExample, which is configured to use the HelloWorldExample.class.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat 6.0.18 examples recompile ok but dont work!!

Posted by mdunford <ma...@gmail.com>.

Thanks for your help. I haven't been doing Java in a while so bear with me. 
Tomcat is entirely new to me. 

java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)

Output from log really puzzles me. (I uncommedted AccessValve like you said)

Here is the sequence of events:

(1) I install Tomcat and try out the HelloWorldExample. All is well and 
     log shows

   0:0:0:0:0:0:0:1%0 - - [02/Apr/2009:15:40:11 -0400] "GET          
     /examples/servlets/servlet/HelloWorldExample HTTP/1.1" 200 359

(2) Next I go and recompile HelloWorldExample (saving a copy of original
class file) 

   javac HelloWorldExample.java

   OK but whoops (class file has changed!) 

   ls -l HelloWorld*class*
   -rw-r--r--  1 martindunford  staff  1723 Apr  2 15:46
HelloWorldExample.class
   -rw-r--r--  1 martindunford  staff  2058 Apr  2 15:46
HelloWorldExample.class.orginal

(3) I restart (stop/start) Tomcat

   HelloWorldExample fails. 

    Sure enough log shows
 
    0:0:0:0:0:0:0:1%0 - - [02/Apr/2009:15:48:58 -0400] "GET
/examples/servlets/servlet/HelloWorldExample HTTP/1.1" 404 952


(4) Notes

   - There has never been an examples/servlets/servlet directory...
puzzling..

Thanks again
Martin 

     


Caldarale, Charles R wrote:
> 
>> From: mdunford [mailto:martin.dunford@gmail.com]
>> Subject: Tomcat 6.0.18 examples recompile ok but dont work!!
>> 
>> But when I reload in my browser I get
>> 
>> HTTP Status 404. The requested resource is not available.
>> 
>> I restarted Tomcat. No joy either...
> 
> Are you running Tomcat with a 1.6 JRE?  If not, your recompiled class
> won't be loadable.
> 
> Where did you put the recompiled class file?
> 
> What's in the logs?  Uncomment the AccessLogValve in conf/server.xml for
> more information about what requests are coming in.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tomcat-6.0.18-examples-recompile-ok-but-dont-work%21%21-tp22850460p22855764.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat 6.0.18 examples recompile ok but dont work!!

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: mdunford [mailto:martin.dunford@gmail.com]
> Subject: Tomcat 6.0.18 examples recompile ok but dont work!!
> 
> But when I reload in my browser I get
> 
> HTTP Status 404. The requested resource is not available.
> 
> I restarted Tomcat. No joy either...

Are you running Tomcat with a 1.6 JRE?  If not, your recompiled class won't be loadable.

Where did you put the recompiled class file?

What's in the logs?  Uncomment the AccessLogValve in conf/server.xml for more information about what requests are coming in.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org