tomcat5 fails to start on CentOS 5 with NoClassDefFoundError exception - java

Tomcat fails to start even if i remove all my applications from the WEBAPPS directory leaving everything just like after the OS installation.
The log (catalina.out) says:
Using CATALINA_BASE: /usr/share/tomcat5
Using CATALINA_HOME: /usr/share/tomcat5
Using CATALINA_TMPDIR: /usr/share/tomcat5/temp
Using JRE_HOME:
Created MBeanServer with ID: -dpv07y:fl4s82vl.0:hydrogenium.timberlinecolorado.com:1
java.lang.NoClassDefFoundError: org.apache.catalina.core.StandardService
at java.lang.Class.initializeClass(libgcj.so.7rh)
at java.lang.Class.initializeClass(libgcj.so.7rh)
at java.lang.Class.initializeClass(libgcj.so.7rh)
at java.lang.Class.newInstance(libgcj.so.7rh)
at org.apache.catalina.startup.Bootstrap.init(bootstrap.jar.so)
at org.apache.catalina.startup.Bootstrap.main(bootstrap.jar.so)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.modeler.Registry not found in org.apache.catalina.loader.StandardClassLoader{urls=[file:/var/lib/tomcat5/server/classes/,file:/usr/share/java/tomcat5/catalina-cluster-5.5.23.jar,file:/usr/share/java/tomcat5/catalina-storeconfig-5.5.23.jar,file:/usr/share/java/tomcat5/catalina-optional-5.5.23.jar,file:/usr/share/java/tomcat5/tomcat-coyote-5.5.23.jar,file:/usr/share/java/tomcat5/tomcat-jkstatus-ant-5.5.23.jar,file:/usr/share/java/tomcat5/tomcat-ajp-5.5.23.jar,file:/usr/share/java/tomcat5/servlets-default-5.5.23.jar,file:/usr/share/java/tomcat5/servlets-invoker-5.5.23.jar,file:/usr/share/java/tomcat5/catalina-ant-jmx-5.5.23.jar,file:/usr/share/java/tomcat5/tomcat-http-5.5.23.jar,file:/usr/share/java/tomcat5/tomcat-util-5.5.23.jar,file:/usr/share/java/tomcat5/tomcat-apr-5.5.23.jar,file:/usr/share/eclipse/plugins/org.eclipse.jdt.core_3.2.1.v_677_R32x.jar,file:/usr/share/java/tomcat5/servlets-webdav-5.5.23.jar,file:/usr/share/java/tomcat5/catalina-5.5.23.jar], parent=org.apache.catalina.loader.StandardClassLoader{urls=[file:/var/lib/tomcat5/common/classes/,file:/var/lib/tomcat5/common/i18n/tomcat-i18n-ja.jar,file:/var/lib/tomcat5/common/i18n/tomcat-i18n-fr.jar,file:/var/lib/tomcat5/common/i18n/tomcat-i18n-en.jar,file:/var/lib/tomcat5/common/i18n/tomcat-i18n-es.jar,file:/usr/share/java/tomcat5/naming-resources-5.5.23.jar,file:/usr/share/eclipse/plugins/org.eclipse.jdt.core_3.2.1.v_677_R32x.jar,file:/usr/share/java/tomcat5/naming-factory-5.5.23.jar], parent=gnu.gcj.runtime.SystemClassLoader{urls=[file:/usr/lib/jvm/java/lib/tools.jar,file:/usr/share/tomcat5/bin/bootstrap.jar,file:/usr/share/tomcat5/bin/commons-logging-api.jar,file:/usr/share/java/mx4j/mx4j-impl.jar,file:/usr/share/java/mx4j/mx4j-jmx.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}}}
at java.net.URLClassLoader.findClass(libgcj.so.7rh)
at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
at java.lang.Class.initializeClass(libgcj.so.7rh)
...5 more

Seems like you've implemented a JMX service and tried to install it on your server.xml file but forgot to add the apache commons modeler jar to the server/lib directory (therefore the ClassNotFoundException for org.apache.commons.modeler.Registry). Check your server.xml file for anything you might have added, and try to add the proper jar file to your server classpath.

This screams class path issue, to me. Where exactly is your tomcat installed? (Give us command line printouts of where the home directory is.) Also, how are you starting it?

Seems like you need to have the jar for commons-modeler into $CATALINA_HOME/common/lib. You get the same kind of error when trying to setup JDBC datasources if you didn't put the driver's jar file into tomcat's server classpath.

Check your JAVA_HOME/JRE_HOME setting. You might want to use a different JVM rather than the one that is installed with the OS

Related

How to share database access between multiple Java wars? [duplicate]

I have 2 java web apps that need to connect to SQL Server Database using Windows Integrated Authentication.
The first one that is loaded works fine but the second one throws the exception:
Native Library sqljdbc_auth.dll already loaded in another classloader
The error above occurs when I place the sqljdbc_auth.dll in one of the folders:
C:\WINDOWS\system32\
C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin\
If I place the sqljdbc_auth.dll in one of the folders below:
/WEB-INF/lib directory of each web application
C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\
Both apps throw the exception:
Failed to load the sqljdbc_auth.dll cause :- no sqljdbc_auth in java.library.path
I am using this code to load the driver:
Class.forName("jdbc:sqlserver://<HOST>;databaseName=<DBNAME>;integratedSecurity=true;");
How can I solve it?
Each web application has its own Classloader (isolating them). When you call the Class.forName() method, there is a static block which is trying to load the shared library (dll file) - so both your web apps are trying to load the shared lib, hence the error message when the second one attempts to load.
The JDBC jar you have for sqlserver should be moved from being bundled with your wars, to the tomcat 7.0/lib folder and copy the sqljdbc_auth.dll to tomcat/bin folder - this way it will be in the tomcat parent classloader, and the class will only be loaded once.
|----------------------------------|
| sqljdbc*.jar --> tomcat*/lib |
|----------------------------------|
| sqljdbc_auth.dll --> tomcat*/bin |
|----------------------------------|
I think you are on the right track.
For command line startup you can easily solve the no sqljdbc_auth in java.library.path issue by setting the environment variable
CATALINA_OPTS=-Djava.library.path=/path/to/dll
If you are running tomcat as a service, change the Options parameter under
HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\Tomcat7\Parameters\Java
to include:
-Djava.library.path=/path/to/dll
The same error occurs in Jasper Studio.
Probably not the best solution but place the sqljdbc4.jar in C:\Program Files (x86)\TIBCO\Jaspersoft Studio-6.1.0.final\features\jre.win32.win32.x86.feature_1.7.0.u80\jre\lib\ext and the sqljdbc_auth.dll in C:\Program Files (x86)\TIBCO\Jaspersoft Studio-6.1.0.final\features\jre.win32.win32.x86.feature_1.7.0.u80\jre\bin
And it will work.

How to pass configuration argument on jboss

I added db2 driver, edited module.xml in JBOSS_HOME/modules/com/ibm/main.
In this folder, I have
db2jcc4.jar
db2jcc_lecense_cu.jar
db2jcc_license_cisuz.jar
module.xml
After having these, I tried to launch JBoss console on Powershell
.\standalone.bat --server-config=standalone-full-ha.xml -Dcom.sun.CORBA.ORBDynamicStubFactoryFactoryClass=com.sun.corba.se.impl.presentation.rmi.StubFactoryFactoryStaticImpl
which I tried to handle ORB exception(related to this https://bugs.openjdk.java.net/browse/JDK-6497156)
But my jboss container is not launched. I checked the log file,
2019-09-17 296 FATAL [org.jboss.as.server] (main) WFLYSRV0239: Aborting with exit code
and error display on Powershell
WFLYSRV0073: Invalid option '.sun.CORBA.ORBDynamicStubFactoryFactoryClass=com.sun.corba.se.impl.presentation.rmi.StubFactoryFactoryStaticImpl'
It works on command prompts though. I am wondering it is correct way to pass argument like this. Thanks in advance!
Edit
I am using Java8, JBoss7.1
Powershell has issues with -D. Try this instead, notice the " around -D
.\standalone.bat --server-config=standalone-full-ha.xml "-Dcom.sun.CORBA.ORBDynamicStubFactoryFactoryClass=com.sun.corba.se.impl.presentation.rmi.StubFactoryFactoryStaticImpl"

Newrelic startup exception

We are getting the following error in catalina.out file when we restart our application with newrelic java agent configured.
We have followed the steps specified in newrelic installation guide and following is the entry created in catalina.sh by newrelic installer:
# ---- New Relic switch automatically added to start command on 2013 Dec 09, 20:24:35
NR_JAR=/usr/share/fk-ops-tomcat6-base/newrelic/newrelic.jar; export NR_JAR
JAVA_OPTS="$JAVA_OPTS -javaagent:$NR_JAR"; export JAVA_OPTS
Exception on app restart in catalina.out:
Error bootstrapping New Relic agent: java.lang.RuntimeException: java.io.IOException: No such file or directory
java.lang.RuntimeException: java.io.IOException: No such file or directory
at com.newrelic.bootstrap.BootstrapLoader.load(BootstrapLoader.java:95)
at com.newrelic.bootstrap.BootstrapAgent.premain(BootstrapAgent.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:338)
Caused by: java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.checkAndCreate(File.java:1704)
at java.io.File.createTempFile(File.java:1792)
at java.io.File.createTempFile(File.java:1828)
at com.newrelic.bootstrap.BootstrapLoader.getJarFileInAgent(BootstrapLoader.java:81)
at com.newrelic.bootstrap.BootstrapLoader.addBridgeJarToClassPath(BootstrapLoader.java:47)
at com.newrelic.bootstrap.BootstrapLoader.load(BootstrapLoader.java:92)
... 7 more
I just encountered the same problem. The not very helpful error message alluded to the fact that the newrelic agent (or rather the user under which my server is running) wasn't able to write into /tmp. Maybe that helps!
I hit that exception with that stack trace recently, and in my case it was caused by the temporary directory not existing at all.
In particular: by default tomcat uses $CATALINA_BASE/temp as value for the java.io.tmpdir property, and seems to create that when needed. At the time the newrelic agent boots up however it may not yet exist, and so newrelic agent fails with that exception.
After restarting things are fine (now the directory exists!), but I solved in my startup scripts:
1. set the value of CATALINA_TMPDIR explicitly to something I control
2. ensure that directory exists before starting tomcat.
Make sure the newrelic.yml placed and marked readable in the same directory as the .jar
I work for New Relic.
As you've seen from the answers above, there can be multiple causes for this kind of message - some of which are pretty unexpected. Since this forum is not intended for back-and-forth messaging about incidents, in case neither of the previous two answers solved the problem for you, your best bet will be to open a ticket for support at http://support.newrelic.com where we can ask to look at your logfile and gather debug logs as necessary.
I had the same problem using apache version 6.0.33. Once I upgraded to 7.0.53 everything worked.
save problem.
But I found this:
Sep 09, 2015 11:19:48 AM org.apache.catalina.startup.Catalina initDirs
SEVERE: Cannot find specified temporary folder at /mnt/apache-tomcat-7.0.56/temp
then doing this:
mkdir /mnt/apache-tomcat-7.0.56/temp
cp /mnt/apache-tomcat-7.0.56/newrelic/* /mnt/apache-tomcat-7.0.56/temp
Everything works.
You may not need cp.
If you look at very early of Tomcat log (catalina.out) after NewRelic exception, you can see what folder is required that are missing. Here is mine:
May 29, 2017 5:04:31 PM org.apache.catalina.startup.Catalina initDirs
SEVERE: Cannot find specified temporary folder at /var/log/tomcat/tomcat7/temp
May 29, 2017 5:04:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/7.0.59
Hope this help

Unable to connect Oracle 11g via thin

I am trying to connect to Oracle 11g DB through my below java code, in an web application using Tomcat 4 server. ojdbc6.jar in Eclipse build path, but getting this below Error.
BUT when I tried this piece of same Java code in a Java file (public static void main()) and having ojdbc6.jar in Eclipse build path, it was able to connect to d DB, Very Strange!!
Then why this same code is not working in my web application??
Server: Tomacat 4
JDK Version: JDK 1.6
Java Code:
Class.forName("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:#hostName:portNum:SID","user", "pass");
Getting this below Error:
java.lang.ArrayIndexOutOfBoundsException: 7
at oracle.security.o3logon.C0.r(C0)
at oracle.security.o3logon.C0.l(C0)
at oracle.security.o3logon.C1.c(C1)
at oracle.security.o3logon.O3LoginClientHelper.getEPasswd(O3LoginClientHelper)
at oracle.jdbc.ttc7.O3log.<init>(O3log.java:289)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:251)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:246)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
Since your standalone program is running correctly, it means your program runtime classpath is fine. However for Tomcat 4 its failing which raises a suspicion on the tomcat classpath. My guess is that since your tomcat is pretty old, it might be containing old driver class (may be classes12.jar or older ojdbc jar file in libraries of your tomcat (especially look into the $CATALINA_HOME/common/lib). If that is the case remove all other jars except ojbdc6 from your classpath. Also make sure your web application libraries do not contain the classes12.jar or older ojdbc jars.
Also you can try to use -verbose:class in your tomcat jvm startup to print the information from where the classes are loaded. This will however output lots of information in the log files.Search for the driver class and it will show you where this was loaded from.
Loaded oracle.jdbc.driver.OracleDriver from file: xxx.jar

ClassNotFoundException: oracle.jdbc.driver.OracleDriver

I wrote a java servlet program but when i run it, It was showing the Exception java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
My code
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection(url, "username", "pass");
I am using Oracle 10.2.0. I added also ojdbc14.jar and ojdbc14_g.jar.
When I give the below command to command line. I get Error: Main method not found in class oracle.jdbc.driver.OracleDriver
I added also ojdbc14.jar and ojdbc14_g.jar
When adding third party libraries to your application, you must be sure they are in the Build Path of your application. In case of web applications, every third party library must be inside the WEB-INF/lib of the application so when deployed to the server (Tomcat, JBoss, etc.) they can be recognized and loaded when running your application.
Steps to rectify (if running from command prompt)
Step 1- Copy the ojdbc6 jar file from
C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib (Note- this path may differ as per the installation).
Step 2- Paste the ojdbc6 jar file in the Location
C:\Program Files\Java\jre1.8.0_45\lib\ext (Note- this path may differ as per the installation).
Step 3- Now run the programme java -cp . . It should successfully run without any error.

Categories