I am sorry, my question is stupid, but I am not able to answer it, as a java illiterate. I run a tomcat (5) on CentOS5 (for a CAS server), and when I try to open this URL http://192.168.1.17:8080/cas-server-webapp-3.3.1/login I get this error :
first error: java.lang.NoClassDefFoundError: Could not initialize class org.springframework.webflow.util.RandomGuid
and root error: org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.springframework.webflow.util.RandomGuid
$CLASSPATH is empty, and it seems to be a problem, but I don't know what to put in it.
EDIT: Jared is right, my hosts files defined 127.0.0.1 as localhost, and now it work very well!
It is important to keep two or three different exceptions strait in our head in this case:
java.lang.ClassNotFoundException
This exception indicates that the class was not found on the classpath. This indicates that we were trying to load the class definition, and the class did not exist on the classpath.
java.lang.NoClassDefFoundError
This exception indicates that the JVM looked in its internal class definition data structure for the definition of a class and did not find it. This is different than saying that it could not be loaded from the classpath. Usually this indicates that we previously attempted to load a class from the classpath, but it failed for some reason - now we're trying again, but we're not even going to try to load it, because we failed loading it earlier. The earlier failure could be a ClassNotFoundException or an ExceptionInInitializerError (indicating a failure in the static initialization block) or any number of other problems. The point is, a NoClassDefFoundError is not necessarily a classpath problem.
That being said, another answer poster indicates that the RandomGUID requires a call to InetAddress.getLocalHost(). On many operating systems, this would trigger a host lookup that would use the hosts file (/etc/hosts
on *NIX systems, %WINDOWS%/system32/drivers/etc/HOSTS
on a Windows system.)
I have seen similar errors quite frequently when that file incorrectly defines the localhost address. 127.0.0.1
should point to 'localhost' (and probably also localhost.localdomain
.) It should NOT point to the actual host name of the machine (although for some reason, many older RedHat Linux installers liked to set it incorrectly.)
Nowadays, the environment variable $CLASSPATH should not be used; instead, the java application should have the classpath set on the command line.
However, in the case of tomcat and libraries used in the webapps, you simply put the JARs (for Spring) into the shared/lib/ folder of the tomcat installation.
NoClassDef: The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found. As you're missing a spring class I'd guess that you're missing one of the spring jar files.
There are 2 places to put jars in tomcat, there's a global area (which in 5 is something like common/lib and is a bit different in tomcat6) and the area only for your webapp, which is webapps/mywebapp/WEB-INF/lib. The jars for your app should really go here, but if you're really perplexed and can't figure out any other way to make it work they'll work in the global (if you have only some of them in the global it might also break, as they might need a class in another jar and if one piece is in the local it won't work. This is especially true for spring libraries because there's a number of separate jars, not just one).
your CLASSPATH is a list of everywhere the jvm looks for classes. This could include directories of class files, or jar or zip files of classes, which are listed like directories. Tomcat should load that for you by using the above mentioned directories correctly.
The reason is failure to load class RandomGUID.
From looking at RandomGUID source, most of the chances that its static initializer failed at InetAddress.getLocalHost().
Do you have some strange networking config on the host? For example, no or weird localhost definition in /etc/hosts ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With