I'm attempting to get a local Tomcat environment running and am consistently encountering the following error:
Can't load log handler "2localhost.org.apache.juli.FileHandler"
java.lang.ClassNotFoundException: 2localhost.org.apache.juli.FileHandler
java.lang.ClassNotFoundException: 2localhost.org.apache.juli.FileHandler
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
I've confirmed the existence of 'tomcat-juli.jar' in %TOMCAT_HOME%/bin.
Pulling hair out on this one. It's almost gone.. Any help you can offer is greatly appreciated. Thanks! :)
Did you modify your catalina.policy config?
grant codeBase "file:${catalina.home}/bin/tomcat-juli.jar" {
permission java.security.AllPermission;
permission java.lang.RuntimePermission "setContextClassLoader";
};
What good does a JAR do in /bin? Put it in server/lib if you're using Tomcat 5 or lib if you're using Tomcat 6. Those directories are in the CLASSPATH; bin is not.
UPDATE: You're using Tomcat 6, which uses a system class loader that's different from previous versions. This suggests that the juli JAR belongs in /bin, so my previous suggestion might correct the problem but it's not the recommended Tomcat 6 idiom.
Do you have CATALINA_HOME set?
Related
I was asked to configure and use javamail on a RHEL 7 server.
I untar'ed a javamail directory they had here which contains the following files:
activation.jar
cacerts
config.properties
InstallCert.class
InstallCert$SavingTrustManager.class
mail.jar
SimpleSSLMail.class
Also, I have created a /etc/profile.d/java.sh where I have the following:
JAVA_HOME=/usr/java/jre1.6.0_45
export PATH=$JAVA_HOME/bin:/usr/bin:/bin:/usr/sbin:$PATH
export CLASSPATH=$CLASSPATH:/usr/share/javamail/activation.jar:/usr/share/mail.jar:.
cacerts is a keystore which holds gmail's cert to sendmail. When I try to send mail using the following:
java -Djavax.net.ssl.trustStore="cacerts" -Djavax.net.ssl.trustStorePassword="somepassword" SimpleSSLMail "SomeHeader" "Testing..." "some#mail.com"
It fails with message:
Exception in thread "main" java.lang.NoClassDefFoundError:
SimpleSSLMail Caused by: java.lang.ClassNotFoundException:
SimpleSSLMail
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source) Could not find the main class: SimpleSSLMail. Program will exit
I have reviewed many posts saying the problem is java not finding mail and activation jars, but I can't handle correctly the CLASSPATH to work with those files. I also tried using -cp flag like this: java -cp mail.jar -cp activation.jar -Djavax.net.ssl.trustStore="cacerts" .....
It was useless, I get the same error.
What am I missing or how do I get it to work?
I have java jre only; do I need to compile it using javac?
My goal is to make it work in order to create an alias where the user can type only sendmail "Message" "mail.com" or similar
UPDATE
I was having a typo in classpath where instead of using /usr/share/javamail/mail.jar I was using /usr/share/mail.jar.
Now, when creating the alias it works fine in javamail directory but if I try to run it outside the directoy, java complains that it doesn't find config.properties. I believe it is searching for it as ./config_properties.
I don't have the source code, so, is there a way to override the config.properties location with the command line?
I am trying to get Jalview [1] running on my windows 7 system. The standard installation works without error but when starting (the .exe file) it I get "Windows error 2 occured while loading the Java VM". As this error is quite general I tried then
C:\Program Files (x86)\Jalview>java -jar jalview.jar
which leads to:
Java version: 1.8.0_121
x86 Windows 7 6.1
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Layo
ut
at jalview.bin.Jalview.doMain(Jalview.java:210)
at jalview.bin.Jalview.main(Jalview.java:180)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Layout
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
any ideas what is going wrong?
Thx
Morpheus
[1] http://www.jalview.org/Download
This error "java.lang.NoClassDefFoundError" occurs when there is a class missing in your respective packages.
I suggest please check if the class "Layout" is present at path : org/apache/log4j
If not then its correct that you have some missing files/libraries of log4j in the classpath.
Please vote and mark the solution if useful.
Thanks!
First check that in C:\Program Files (x86)\Jalview\lib the library min-jabaws-client-*.jar exists.
To run it from command line
cd C:\Program Files (x86)\Jalview
java -cp jalview.jar;lib/* jalview.bin.Jalview
We have a webstart swing application running on our multiple remote desktop servers for a lot of customers. Suddenly, on one of our servers the customers started getting a java.lang.NoClassDefFoundError. Not on startup, the applications starts up fine, but when doing specific tasks, eg sending a mail through our software, it popups up in the console like this:
java.lang.NoClassDefFoundError: pos/MailSenderInterface
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
......
Caused by: java.lang.ClassNotFoundException: pos.MailSenderInterface
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 56 more
The problem is, this only happens on ONE of our servers. On all the other servers the webstart application runs just fine! But on this single terminal server, I get the error, even though the java version is the same, and the link to the jnlp-file is the same.
I have of course tried deleting temporary internet files in the java control panel, to no avail.
I then started toying around a bit, and found out something very strange.
Our customers start the application from an icon pointing to a batch-file in c:\drift
This batchfile only contains the following:
#start javaws http://ourserver/ourapplication.jnlp
Typing the link outside the batch-file gives the same error. Then I typed cd .. so that my current path was c:\ instead of c:\drift and started javaws from there. And surprise, no errors! I then tried cd drift again and the error occured again. I have tried this many times now, with the same result. So somehow the path from WHERE I start javaws have something to say for if I get the NoClassDefFoundError or not. But neither c:\ or c:\drift contains any .jar-files (although subdirectories may). I am very perplexed by this. What on earth is wrong? Our java version is 1.7.0_67
Aha! The path c:\drift\ actually had a directory "pos" from a couple of years back, with an old version of MailSender.class but with no MailSenderInterface.class Deleting this directory solved the problem. :-)
(Remember that the error was about a missing pos/MailSenderInterface)
Apparently the newest javaws in java 1.7.0_67 tries to load classes from a subdirectory of the place where you started javaws if such a directory is found, instead of loading the files from the correctly downloaded jar-files.
So, I am afraid that I have to join the crowds flocking here and asking: "What's wrong with my code?"
I've recently started coding in Java and I've had none of this error until I tried using lwjgl in a project. So, the question is: What is wrong with my JAR when I get the following:
java -cp \lib\win32\lwjgl.jar -jar Valor.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/opengl/Display
at bin.Disp.createWindow(Disp.java:18)
at bin.Thread.gameLoop(Thread.java:13)
at Main.main(Main.java:4)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.opengl.Display
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
As is, I am extremely confused about this. I've gone through seven or eight posts here about this very problem, and another five or six on other web sites, yet none of the methods those people used seem to work for me.
Currently, my file structure is:
Valor
-Valor.jar
lib
win32
-lwjgl.jar
-lwjgl.dll
Manifest:
Manifest-Version: 1.0
Main-Class: Main
I did try defining a classpath here... Didn't work. So, I'm pretty much as confused as I can possibly get. Thank you for your help.
Edit: This error doesn't occur while running in Eclipse, only when I export and try to run it myself.
Try to run it like this:
java -cp lib\win32\lwjgl.jar;Valor.jar Main
The problem is that the -cp option is ignored when -jar is used.
Alternativelly you could extend the class path by adding a Class-Path: entry in your manifest and puting lib\win32\lwjgl.jar in it.
Class-Path: lib\win32\lwjgl.jar
use this link to install ljgl and define your classPath : http://www.lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_Eclipse
By running java -cp \lib\win32\lwjgl.jar -jar Valor.jar you're telling Java to look for LWJGL classpath near the root of your filesystem. Seeing your directory structure, use:
java -cp .\lib\win32\lwjgl.jar -jar Valor.jar
Notice the . at the beginning.
I've run in to a strange error with the javamail 1.4.2 api and jdk/jre 1.6.0u16. I've placed the unzipped javamail-1.4.2 folder (along with the MySQL Connector-J 5.1.7 also needed) in both the jdk and jre folders as in the %classpath% below.
.;"C:\Program
Files\Java\jdk1.6.0-16\jre\lib\ext\mysql-connector-java-5.1.7-bin";"C:\Program Files\Java\jdk1.6.0-16\jre\lib\ext\javamail-1.4.2\mail.jar";"C:\Program
Files\Java\jdk1.6.0_16\bin";"C:\Program
Files\GameLabInventory\GameLabInventory-7.0.jar";"C:\Program
Files\Java\jre6\lib\ext\mysql-connector-java-5.1.7-bin";"C:\Program Files\Java\jre6\lib\ext\javamail-1.4.2\mail.jar";
But when I run my compiled jar with the command
C:\Program Files\Java\jre6\bin>java -cp %classpath% -jar "C:\Program Files\GameLabInventory\GameLabInventory_7.0.jar"
I get the following error message:
Exception in thread "main"
java.lang.NoClassDefFoundError:
javax/mail/MessagingException
at gamelab.inventory.GameLabInventory.main(GameLabInventory.java:62)
Caused by:
java.lang.ClassNotFoundException:
javax.mail.MessagingException
at java.net.URLClassLoader$1.run(Unknown
Source)
at java.security.AccessController.doPrivileged(Native
Method)
at java.net.URLClassLoader.findClass(Unknown
Source)
at java.lang.ClassLoader.loadClass(Unknown
Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown
Source)
at java.lang.ClassLoader.loadClass(Unknown
Source)
at java.lang.ClassLoader.loadClassInternal(Unknown
Source)
... 1 more
I can't find anything wrong with my setup here, hopefully you guys can help me out. Thanks!
Here is the manifest file:
Manifest-Version: 1.0
Main-Class: gamelab.inventory.GameLabInventory
Here is the jar -tvf (link)
According to the documentation for the java tool:
When you use [the -jar] option, the
JAR file is the source of all user
classes, and other user class path
settings are ignored.
You can specify a Class-Path attribute in yourJAR file that "specifies the relative URLs of the extensions or libraries that [your] application or extension needs."
When using -jar, java overrides the classpath setting (-cp). In this configuration, however, classpath jars can be specified in the manifest file of your jar.
I've experienced a similar issue (not identical to yours, since mine is spring-related) and found this link was helpful:
http://forum.springsource.org/showthread.php?t=65840&page=3
It seems that implementation changes in the JDK might be causing this behaviour. Quoting from the link:
"I managed to reproduce the problem on my Mac development box using Java 6 (1.6.0_07). I then tried it on my Mac using Java 5, and could not reproduce the problem. Crucially, in the Java 5 case, the JVM would be using the javax.activation API and implementation from the 1.1.1 javax activation bundle, whereas on Java 6, it would be using them from the JRE (anything that's part of the JRE takes precedence over what's in dm Server's lib directory). I then tried the app on an Ubuntu box, this time using Java 6 1.6.0_10. I could not reproduce the problem."
and/but:-
"I've just had this same problem "No object DCH for MIME type" but on Ubuntu java version "1.6.0_13". So I don't know how you guys solved it by upgrading to 1.6.0_11.
What I did is copy the mailcab.default to my own bundle and it worked. Seems to be a classloading problem which I don't fully understand yet."