Tomcat versions aren't starting - java

Just downloaded Tomcat 7.0.26, unzipped it, ran the startup.bat file and it failed with the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:54)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
... 1 more
A co-worker recommended I try using an older/more stable version of Tomcat. He's running 6.0.35, so I decided to try that.
I did the same exact thing with 6.0.35...and the same thing is happening to me...
What is going on here?!?! I see in bin/tomcat-juli.jar that the LogFactory is there (both versions)...
Edit:
Here are the values for several environment variables:
CLASSPATH: .;C:\Users\<myUser>\Desktop\jars\;C:\Program Files\Java\jre6\lib\ext\QTJava.zip
JAVA_HOME: C:\Program Files\Java\jdk1.6.0_25
These don't seem to add up!?! If I'm reading this correctly, doesn't it say that the CLASSPATH thinks I'm using jre6, but that Java Home is set to jdk1.6.0_25?

It's possible that some environment variable is set in your system which is preventing Tomcat from running.
Check:
CATALINA_HOME
CATALINA_BASE
CATALINA_OPTS (for classpath additions)
JAVA_OPTS (for classpath additions)
and less likely:
LOGGING_CONFIG
LOGGING_MANAGER
If any of these environment variables are set, correct or unset them. My guess is that CATALINA_HOME is set to point to a different version of Tomcat on your system.

I have downloaded Tomcat 7.0.26 2 hours ago and its working fine. It looks like you have an old version of commons-logging.jar anywhere in your classpath (path variable, jre versions/lib, etc...).

I had same problem.
All I did was to copy all the jar files in [apache-tomcat]/lib directory and all the jar files in [apache-tomcat]/bin to [jdk directory]/jre/lib/ext directory.
This should solved the problem.

Related

Unable to run Grails 2.1 with path set to Java 6

I have an application that's built in grails 2.1
My environment variables are set to point to JAVA 8 and Grails 3.8 along with the path.
I am aware of the fact that grails 2.1 has support upto Java 6. But I donot want to make changes to my environment variables in order to make it point to Java 6. So I tried to set home and path for java 6 and grails 2.1 via command line. I was successful in doing so and echoe %JAVA_HOME%, %GRAILS_HOME% and %PATH% did show that values were set correctly. Trying to run the app with grails run-app command from under the project's root directory throws below error :
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/grails/cli/GrailsCli : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.grails.cli.GrailsCli. Program will exit.
I tried to write a batch script that would set the %JAVA_HOME%, %GRAILS_HOME% and %PATH% to Java 6 and Grails 2.1 specific locations and then execute "grails run-app" from under the project's root directory, but while executing the script I got the same above error.
Below is how my batch script looks like:
set JAVA_HOME=C:\Softwares\Java\Java-6\jdk1.6.0_41
set PATH=%PATH%;%JAVA_HOME%\bin
set GRAILS_HOME=C:\Softwares\Grails\Grails_2.1.0
set PATH=%PATH%;%GRAILS_HOME%\bin
cd /D C:\MyWorkspace\MyApplication
grails run-app
REM pause
I have never written a batch script before.So, please correct me where possible.
Also, as for some restrictions in place I do not have the freedom of installing SDKMan.
Any guidance in this regard is greatly appreciated.
It seems you have to set environment variable in front of the existing PATH setting:
set PATH=%JAVA_HOME%\bin;%PATH%;
This will lookup at the first match (the wanted version)}
Also, make sure you are using the exact same version of compile

Apache Qpid:Error while running qpid-server.bat

When I am running qpid-server.bat, I am getting following error:
C:\qpid\qpid-0.24\java\broker\bin>qpid-server.bat
Warning: Qpid classpath not set. CLASSPATH set to C:\qpid\qpid-0.24\java\broker\lib\qpid-all.jar;C:\qpid\qpid-0.24\java\broker\lib\plugins\*;C:\qpid\qpid-0.24\java\broker\lib\opt\*
Info: QPID_JAVA_GC not set. Defaulting to JAVA_GC -XX:+UseConcMarkSweepGC -XX:+HeapDumpOnOutOfMemoryError
Info: QPID_JAVA_MEM not set. Defaulting to JAVA_MEM -Xmx1024m
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/qpid/server/Main
Caused by: java.lang.ClassNotFoundException: org.apache.qpid.server.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.apache.qpid.server.Main. Program will exit.
I am not running any code. I am just starting qpid-server.bat and getting above error.
I would be really thankful if anyone would suggest me the solution.
After downloading the code from Apache "qpid-java-6.1.0", I also had errors running the broker. I found that the broker folder I was using was incorrect. I was able to run the broker by setting the system variable QPID_HOME to "C:\qpid\qpid-java-6.1.0\systests\target\qpid-broker\6.1.0" and running the "qpid-server.bat" in that location. You can then log into the broker at "http://localhost:8080" with user = admin and password = admin. I am not sure what the "systests" folder is or why the bin and lib files are here, but it works. Navigate to that folder and look at the files there. Let me know if there is a better folder I am supposed to be in. I then create a connection factory with the URL "amqp://admin:admin#clientid/?brokerlist='tcp://localhost:5672" and it works.
I have seen this problem caused by an incorrect setting of the QPID_HOME environment variable.
With a normal installation QPID_HOME needs to refer to the immediate parent of the lib directory. The batch file tries to determine QPID_HOME if it is not set, but will use its current value otherwise. Check you have not set it erroneously.

Tomcat fails to start from Eclipse with JVM Launcher exception

I setup a tomcat 6 server in Eclipse pointing to a local tomcat folder:
C:\Program Files (x86)\Apache\Tomcat
I setup a debug configuration to point to that tomcat server with the following settings:
Program arguments:
start
VM arguments:
-Dcatalina.base="C:\Program Files (x86)\Apache\Tomcat" -Dcatalina.home="C:\Program Files (x86)\Apache\Tomcat"
Classpath Bootstrap Entries:
JRE System Library [jdk]
Classpath User Entries:
bootstrap - C:\Program Files (x86)\Apache\Tomcat\bin\
tools.jar - C:\Program Files (x86)\Java\jdk\lib\
When attempting to start the debug configuration (and subsequently Tomcat), I instantly get this error in the Console:
java.lang.NoClassDefFoundError: Files
Caused by: java.lang.ClassNotFoundException: Files
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
And this error as a Windows Popup:
Java Virtual Machine Launcher - Could not find the main class Files. Program will now exit.
I think somewhere the JVM is trying to parse a "Program Files" related path, failing on the space, and thinks that "Files" is a parameter. But I don't even know where to look to find whatever path it's referencing! Is there an argument I can pass that will be verbose about what it's doing?
Install Tomcat into a directory that does not have spaces in its full path.
Such as C:\Apache\Tomcat

"Exception in thread 'main'" error with Apache Ant on CentOS 6.4

I'm attempting to run Apache Ant for the purpose of compiling OpenGTS. While attempting to run any "ant" command I'm getting the following output:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.launch.Launcher
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: org.apache.tools.ant.launch.Launcher. Program will exit.
Previously I was getting a message stating "JAVA_HOME is not defined correctly" and after reading several forum threads, was able to solve that by updating the path:
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk
Another thread stated a "CLASS PATH" issue but if I'm able to run "ant" anywhere in the terminal, wouldn't the path be correct? Thanks in advance.
Make sure to set ANT_HOME to the directory where you installed ant. Refer to Installling Apache Ant.
You need to export ANT_HOME too, just make sure it is installed first on your system
export ANT_HOME="/usr/local/ant";
In my case it was a wrong permission on /opt/ant/lib folder.

JavaMail ClassNotFound

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."

Categories