Webapp couldn't find jars located in WEB-INF/lib folder - java

On production Tomcat server my webapp couldn't find jars located in WEB-INF/lib folder. In development eviorment all works fine.
Stack Trace
javax.servlet.ServletException: Could not initialize class util.HibernateUtil
web.Engine.service(Engine.java:58)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)
root cause
java.lang.NoClassDefFoundError: Could not initialize class util.HibernateUtil
web.Engine.service(Engine.java:31)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5 logs.
Development Config
Tomcat 5.5
OS X 10.6
Eclipse
Production Config
Tomcat 5.5
Linux Debian
Thanks for your answer!

By default, the Tomcat that ships with Debian distros has a very restrictive Java security manager. My guess is that you're using the packaged version and that it is forbidding something. The "something" is very likely available in the logs as mentioned in the last line of the trace you posted:
note The full stack trace of the root cause is available in the Apache Tomcat/5.5 logs.
You'll have to ease the restrictions (check /etc/tomcat5.5/policy.d) or to turn it off. Talk with your administrator.

I have seen something very similar with a jar requiring a class from another jar and that jar was not on the classpath.
Have a look at the root cause of the stack trace in the Tomcat log. That will most likely reveal what is wrong.

Related

Java NoClassDefFoundError initialization error after Lotus Domino upgrade from Version 6.5.3 to 8.5.2

We have upgraded Lotus Domino upgrade from Version 6.5.3 to 8.5.2, After upgrading we are getting initialization error while calling Java methods.
The classes are kept at a location say d:\javaclasses and an entry is made in notes.ini as shown below
JavaUserClasses=.;d:\javaclasses;d:\javaclasses\lib... etc.
Everything call to java works on Version 6.5.3 however it does not work on 8.5.2.
We have not changed any java files, Just copied from older version to new version server at the same location
Note: d:\javaclasses classes are compiled using JDK1.3, Domino Version 6.5.3 uses JDK1.3 native library,
Domino Version 8.5.2 uses JDK1.6 native library inbuilt
Stack trace for reference.
java.lang.NoClassDefFoundError: com.centtric.td.cprm.AppSource (initialization failure)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:140)
at com.centtric.td.cprm.Coverage.<init>(Coverage.java:87)
at com.centtric.td.cprm.Coverage.find(Coverage.java:572)
at CPRMLib.deleteCoverage(CPRMLib.java:913)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at lotus.domino.JavaConnectInvoker.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at lotus.domino.JavaConnectLoader.invoke(Unknown Source)
Caused by:
java.lang.NullPointerException
at com.centtric.connectors.JDBCConnector.closeStatements(JDBCConnector.java:484)
at com.centtric.connectors.JDBCConnector.closeAll(JDBCConnector.java:431)
at com.centtric.td.cprm.AppSource.init(AppSource.java:70)
at com.centtric.td.cprm.AppSource.get(AppSource.java:79)
at com.centtric.td.cprm.AppSource.<clinit>(AppSource.java:32)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
It's hard to say, but it looks like your new JVM either is missing some native libraries, or don't have the same classpath as your old JVM has. Are you sure the ini-file format hasn't changed?
J9VMInternals is an IBM-specific class that takes care of classloading and stuff.

java newrelic agent throwing classnotfound exception

I am trying to install newrelic on a linux machine with tomcat 7. This installation does not have a catalina.sh so cannot use the newrelic installer.
I tried the manula approach of adding the newrelic.jar to the javaagent like:
CATALINA_OPTS="$CATALINA_OPTS -javaagent:/usr/share/tomcat7/newrelic/newrelic.jar"
But whenever I start the tomcat I get the following classnotfoundexception:
Unable to start New Relic agent: javax.xml.transform.TransformerFactoryConfigurationError: Provider org.apache.xalan.processor.TransformerFactoryImpl not found
javax.xml.transform.TransformerFactoryConfigurationError: Provider org.apache.xalan.processor.TransformerFactoryImpl not found
at javax.xml.transform.TransformerFactory.newInstance(TransformerFactory.java:106)
at com.newrelic.agent.extension.dom.ExtensionDomParser.getTransformerFactory(ExtensionDomParser.java:360)
at com.newrelic.agent.extension.dom.ExtensionDomParser.fixNamespace(ExtensionDomParser.java:337)
at com.newrelic.agent.extension.dom.ExtensionDomParser.parseDocument(ExtensionDomParser.java:167)
at com.newrelic.agent.extension.dom.ExtensionDomParser.readFile(ExtensionDomParser.java:152)
at com.newrelic.agent.extension.ExtensionParsers$3.parse(ExtensionParsers.java:46)
at com.newrelic.agent.extension.JarExtension.<init>(JarExtension.java:59)
at com.newrelic.agent.extension.JarExtension.<init>(JarExtension.java:104)
at com.newrelic.agent.extension.ExtensionService.initializeBuiltInExtensions(ExtensionService.java:388)
at com.newrelic.agent.extension.ExtensionService.doStart(ExtensionService.java:145)
at com.newrelic.agent.service.AbstractService.start(AbstractService.java:54)
at com.newrelic.agent.service.ServiceManagerImpl.doStart(ServiceManagerImpl.java:124)
at com.newrelic.agent.service.AbstractService.start(AbstractService.java:54)
at com.newrelic.agent.Agent.premain(Agent.java:208)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at com.newrelic.bootstrap.BootstrapAgent.premain(BootstrapAgent.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:343)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:358)
Caused by: java.lang.ClassNotFoundException: org/apache/xalan/processor/TransformerFactoryImpl
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at javax.xml.transform.FactoryFinder.getProviderClass(FactoryFinder.java:124)
at javax.xml.transform.FactoryFinder.newInstance(FactoryFinder.java:179)
I have tried everything I could for this, but nothing works. I have even added the xalan jar manually to the tomcat lib but no luck
You need to make sure you have xalan.jar installed. If it is installed, it may be in the wrong place. You probably need it at the container level, here is a blog post that discusses this issue (tomcat5 but most of the advice should still apply).
http://doookstechstuff.blogspot.com/2010/04/how-to-fix-tomcat5-on-rhel5.html
Make sure that the location where you put the xalan.jar is in the classpath and that the user account you're running tomcat under has access to it. If you have dropped it in the tomcat /lib folder make sure the perms for the .jar file match the other objects in the folder.
Let us know if this helps. If you need additional information it might be best to create a ticket with New Relic Support (http://support.newrelic.com).

WebLogic Toplink (its xml parser?) configuration issue

I have a web application (war packaged) with toplink.jar and xmlparserv2.jar files under WEB-INF\lib. The problem is that I get
]] Root cause of ServletException.
java.lang.NoClassDefFoundError: oracle/xml/parser/schema/XSDElement
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at oracle.toplink.internal.security.PrivilegedAccessHelper.newInstanceFromClass(PrivilegedAccessHelper.java:335)
at oracle.toplink.platform.xml.XMLPlatformFactory.getXMLPlatform(XMLPlatformFactory.java:95)
I don't understand it because xmlparserv2.jar contains oracle.xml.parser.schema.XSDElement class - so it should be on classpath.
My WebLogic version is 10.3.2.0, any help would be appreciated.
Add below line in Arguments in Server Start tab in WebLogic admin console
-Dtoplink.xml.platform=oracle.toplink.platform.xml.jaxp.JAXPPlatform
Source: https://community.oracle.com/message/2988932?tstart=44

Throwing exception while trying to send mail in tomcat 6.0.14 server

I have create a application in struts 2 which is sending mail to mail ids.
My problem is that while deploying my application on glassfish 3 server
(on my local system) its sending mail properly.
But when i am deploying my application on my actual server(using tomcat6.0.14)
its showing following exceptions
exception
java.lang.reflect.InvocationTargetException
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)...........
root cause
java.lang.NoClassDefFoundError: javax/mail/Address
action.SendForgetPasswordAction.execute(SendForgetPasswordAction.java:117)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597).............
root cause
java.lang.ClassNotFoundException: javax.mail.Address
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
action.SendForgetPasswordAction.execute(SendForgetPasswordAction.java:117)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
How to resolve this problem i am uploading war file in my tomcat server
please add the mail.jar into the tomcat lib folder.. the issue being reported is for a class not being found (this class is available as part of the installation in GF but not in tomcat)
you could just copy the file from glassfish folder and place it in tomcat lib.
it will solve the issue.

Getting java.lang.NoClassDefFoundError: javax/net/SocketFactory while sending email using mail.jar

My jsf web application using mail.jar and activation.jar to send email both of these and other dependent jars are in CLASSPATH, (the application is running in tomcat)
But I get following Exception
java.lang.NoClassDefFoundError: javax/net/SocketFactory
java.lang.ClassLoader.findBootstrapClass(Native Method)
java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:892)
java.lang.ClassLoader.loadClass(ClassLoader.java:302)
java.lang.ClassLoader.loadClass(ClassLoader.java:300)
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
java.lang.ClassLoader.loadClass(ClassLoader.java:252)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1302)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1900)
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
javax.mail.Service.connect(Service.java:317)
javax.mail.Service.connect(Service.java:176)
javax.mail.Service.connect(Service.java:125)
I added required jsse.jar (which is the Java`s standard jar) to my application libs as well, but still the issue persists. I doubt now that the jsse.jar in jre is corrupt which is causing this issue. I am using jre 1.6.0_13.
Can someone help me solving this error?
That class in particular is a standard class provided by the JVM. Check that the JVM installation isn't corrupted, missing files, etc.

Categories