I would like to re-introduce here for folks that are likely more focused on servlet issues:
I get this error in my browser on one machine (a WinXP laptop), but not on another (a WinXP desktop) with the identical jdk, Orion server and jr.jar files.
500 Internal Server Error
java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
Configuration:
jdk1.6.0_17 and Orion 2.0.7
jr.jar is located here: http://www.javaranch.com/common.jsp My CLASSPATH: .;C:\Java;C:\Java\jr.jar;C:\orion\orion.jar
So now that I replicated the issue that I have on a Windows laptop (WinXP Pro, SP3)
and resolved it on my Windows Desktop (WinXP Home, SP2),
the issue appears to be this, in the form of some questions:
Is there a difference between the CLASSPATH used for javac compilation, and the CLASSPATH used
for servlets during runtime?
Is there a procedure for monitoring or determining what is different under-the-hood between my two machines
as it relates to determining where the servlet is looking for HttpServlet?
Supporting Info: Invoking a class that extends HttpServlet directly from my servlet works.
Invoking a class that extends LogServlet (that extends HttpServlet) from my servlet does not work on my laptop.
This is working on laptop and desktop
This works on desktop, but not on laptop...
One other piece of info:
If I replace this in my code:
it yields this on both machines:
If you can help out, I can supply additional orion configuration information as needed.
Thank in advance for pointers or additional help...
Vince
Bear Bibeault
Author and opinionated walrus
Marshal
Is there a difference between the CLASSPATH used for javac compilation, and the CLASSPATH used
for servlets during runtime?
Absolutely. The having nothing to do with each other. Nothing.
The classpath during run-time consists of standard locations (such as WEB-INF/classes and WEB-INF/lib) and container-specific configuration (such as Tomcat's lib folder).
This message was edited 1 time. Last update was at by Bear Bibeault
[/code]
This works on desktop, but not on laptop...
[code]
import java.io.*;
import javax.servlet.http.*;
import java.util.*;
import com.javaranch.common.*;
[/code]
Did you put a copy of com.javaranch.common where it should go on your laptop?
Vince Mansel
Greenhorn
Joined: Feb 14, 2010
Posts: 18
posted
0
Bear,
Thanks for confirming my suspicion.... now if I can only figure out where the servlet
is looking for HttpServlet during run-time. HttpServlet lives in the orion.jar.
Does the following code print the runtime classpath? It appears so, and if so, something in my laptop configuration
is blocking access to HttpServlet.
Carol,
Thanks. I think so... My jr.jar file sits in C:/Java/jr.jar which is where com.javaranch.common lives.
If not, the servlet would not compile.
Vince Mansel wrote:
Carol,
Thanks. I think so... My jr.jar file sits in C:/Java/jr.jar which is where com.javaranch.common lives.
If not, the servlet would not compile.
Vince, as per the instructions, the jr.jar file is expected to be in the lib folder of orion. So if you have orion installed at C:/orion then jr.jar should be in C:/orion/lib folder.
per the instructions, the jr.jar file is expected to be in the lib folder of orion. So if you have orion installed at C:/orion then jr.jar should be in C:/orion/lib folder.
Thanks Jaikiran.
Yes, jr.jar is also in C:/orion/lib (for runtime as I understand it).
This issue seems to be something else "under the hood" on my laptop.
Just FYI, on my desktop where it works, if I take jr.jar out of C:/orion/lib i get this error:
If I trust this, it implies that, on the laptop, LogServlet is "found" but HttpServlet can not be found from that
version of it.
I did a search on my laptop for all instances of jr.jar, I found the culprit here:
C:\Program Files\Java\jre6\lib\ext
This is where my classpath originally pointed but I decided to change it a few days ago and did not delete the jr.jar file
when I moved my classpath to C:/Java?
Now it is deleted, and my servlet works great on my laptop!
My Bee is buzzin'!!!
Thnaks Carol, Jaikiran and Bear.
Vince
Carol Murphy
village idiot
Bartender
Joined: Mar 15, 2001
Posts: 1170
posted
0
Sweet!
subject: HttpServlet not found on Laptop, but found on Desktop