Exception - NoClassDefFoundError: org.apache.xml.security.Init - java

Hi may i know which library files am i missing in order to solve this exception ? Please help, thanks.
included : xmlsec-1.4.3
ERROR ] SRVE0777E: Exception thrown by application class 'org.apache.jasper.runtime.PageContextImpl.handlePageException:701'
com.ibm.websphere.servlet.error.ServletErrorReport: java.lang.NoClassDefFoundError: org.apache.xml.security.Init (initialization failure)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:701)
at [internal classes]
at com.ibm._jsp._newlistener._jspService(_newlistener.java:223)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:101)
at [internal classes]
Caused by: java.lang.NoClassDefFoundError: org.apache.xml.security.Init (initialization failure)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:168)
at com.rexit.easc.SoapSender.sentSOAP(SoapSender.java:93)
at com.rexit.easc.testingXML.checkIsmNcd_value(testingXML.java:2815)
at com.rexit.easc.testingXML.proc_MOTOR(testingXML.java:517)
at com.rexit.easc.testingXML.processInput(testingXML.java:269)
at com.ibm._jsp._newlistener._jspService(_newlistener.java:182)

The problem seems to be that Init class can not be initialized (first loaded in JVM), it says initalization failure. From the code the only thing that happens during class initialization (some static code to be called) is creating Log. According to this article IBM WebShere has built-in Apache commons logging. LogFactory might not be created because of WebSphere configuration.

Related

javax.naming.NameNotFoundException: CDIExtension

I have created two Jersey servlet projects using com.sun.jersey.spi.spring.container.servlet.SpringServlet. I use jersey 1.19.1 jars. Both projects has the dependent jars in lib folder. I deployed both the projects in liberty 9 server.
When I try to access the endpoints, one project works fine but not the other one. I have below exception in console if second project does not work. If I restart that project alone (not the server), it works. I do not know why and I try to find the permanent fix for this.
SRVE0271E: Uncaught init() exception created by servlet [jersey-servlet] in application [secondproject]: java.lang.RuntimeException: javax.naming.NameNotFoundException: CDIExtension
SRVE0315E: An exception occurred: java.lang.Throwable: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
If first project does not work, I see the below exception in console.
SRVE0271E: Uncaught init() exception created by servlet [jersey-servlet] in application [firstproject]: java.lang.ClassCastException: com.sun.jersey.server.impl.cdi.CDIExtension incompatible with com.sun.jersey.server.impl.cdi.CDIExtension
SRVE0276E: Error while initializing Servlet [jersey-servlet]: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
Update with full stack:
java.lang.RuntimeException: javax.naming.NameNotFoundException: CDIExtension
at com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:183)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.<init>(CDIComponentProviderFactory.java:95)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:76)
at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:572)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:332)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:604)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:332)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadOnStartupCheck(ServletWrapper.java:1428)
at com.ibm.ws.webcontainer.webapp.WebApp.doLoadOnStartupActions(WebApp.java:1181)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:1149)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:1055)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6499)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:446)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:248)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:313)
at com.ibm.ws.http.internal.VirtualHostImpl.discriminate(VirtualHostImpl.java:251)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:300)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:471)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:405)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:285)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:256)
at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:174)
at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:83)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:504)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:574)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:929)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1018)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1153)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:785)
Caused by: javax.naming.NameNotFoundException: CDIExtension
at com.ibm.ws.jndi.internal.ContextNode.lookup(ContextNode.java:218)
at com.ibm.ws.jndi.internal.WSContext.lookup(WSContext.java:297)
at com.ibm.ws.jndi.WSContextBase.lookup(WSContextBase.java:62)
at com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:181)
... 33 more
Caused by: java.lang.ClassCastException: com.sun.jersey.server.impl.cdi.CDIExtension incompatible with com.sun.jersey.server.impl.cdi.CDIExtension
at com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:181)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.<init>(CDIComponentProviderFactory.java:95)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:76)
at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:572)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:332)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:604)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:332)
... 1 more
Please check this link, it is helpful to me.
You can solve the problem when setting the system-property
com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true
This can be done from the GlassFish server console.
Select the node ->Configuration->server-config->JVM Settings
change to the tab ‘JVM Options’
add a new entry
-Dcom.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true
restart your server
In the logs you can see:
Caused by: java.lang.ClassCastException: com.sun.jersey.server.impl.cdi.CDIExtension incompatible with com.sun.jersey.server.impl.cdi.CDIExtension
Liberty uses Jersey as JAX-RS provider, so you have conflict. You either have to remove these jars from your application, or make sure that JAX-RS feature is not included explicitly or implicitly in your server.xml
The error,
javax.naming.NameNotFoundException: Unable to resolve 'com.sun.jersey.config.CDIExtension'. Resolved 'com.sun.jersey.config'; remaining name 'CDIExtension'
can be caused due to an class import in EJB3
Example:
import javax.enterprise.context.RequestScoped;
#RequestScoped
public class SampleServices {
#EJB
CalcBeanLocal calcBean;
.....
When importing RequestScope "bean.xml" will be added to WEB-INF.
This ca be resolved by using #stateless annotation instead of #RequestScope and by removing the above created "bean.xml" in WEB-INF.
Example:
#stateless
public class SampleServices {
#EJB
CalcBeanLocal calcBean;
.....

NoClassDefFoundError during Tomcat graceful shutdown

We are getting NoClassDefFoundErrors during Tomcat graceful shutdown process (i.e. using catalina.sh stop command). We are using Tomcat version 6.0.44.
Note that this error can not be reproduced consistently. Another question suggests class loader related problems during execution of JVM shutdown hook. But in this case, the error is raised during the execution of the ServletFilter::destroy(...) method.
Could you please provide any insight?
java.lang.NoClassDefFoundError: com/google/common/cache/RemovalCause
at com.google.common.cache.LocalCache$Segment.remove(LocalCache.java:3147)
at com.google.common.cache.LocalCache.remove(LocalCache.java:4236)
at org.apache.curator.framework.imps.NamespaceWatcherMap.remove(NamespaceWatcherMap.java:71)
at org.apache.curator.framework.imps.CuratorFrameworkImpl.clearWatcherReferences(CuratorFrameworkImpl.java:189)
at org.apache.curator.framework.recipes.cache.PathChildrenCache.close(PathChildrenCache.java:376)
at org.apache.hadoop.security.token.delegation.ZKDelegationTokenSecretManager.stopThreads(ZKDelegationTokenSecretManager.java:456)
at org.apache.hadoop.security.token.delegation.web.DelegationTokenManager.destroy(DelegationTokenManager.java:152)
at org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticationHandler.destroy(DelegationTokenAuthenticationHandler.java:153)
at org.apache.hadoop.security.authentication.server.AuthenticationFilter.destroy(AuthenticationFilter.java:401)
at org.apache.solr.servlet.SolrHadoopAuthenticationFilter.destroy(SolrHadoopAuthenticationFilter.java:177)
at org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:360)
at org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:4111)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4880)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1279)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1385)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:307)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1392)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1656)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1665)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1645)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.google.common.cache.RemovalCause
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)

catalina.out logging same error continuously

I am getting the following error when deploying to Tomcat
org.apache.tomcat.util.net.JIoEndpoint$Acceptor run
INFO: Illegal access: this web application instance has been stopped already.
Could not load org.bouncycastle.crypto.modes.CBCBlockCipher.
The eventual following stack trace is caused by an error thrown for debugging purposes
as well as to attempt to terminate the thread which caused the illegal access,
and has no functional impact.
java.lang.IllegalStateException
and then
SEVERE: Socket accept failed
java.lang.NoClassDefFoundError: org/bouncycastle/crypto/modes/CBCBlockCipher
at org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher.engineSetMode(Unknown Source)
at javax.crypto.Cipher$Transform.setModePadding(Cipher.java:357)
at javax.crypto.Cipher.chooseProvider(Cipher.java:847)
at javax.crypto.Cipher.init(Cipher.java:1348)
at sun.security.ssl.CipherBox.(CipherBox.java:175)
at sun.security.ssl.CipherBox.newCipherBox(CipherBox.java:208)
...
at org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:352)
at java.lang.Thread.run(Thread.java:722)
The NoClassDefFoundError exception is being logged into catalina.out continuously (looping) and catalina.out gets full in short time.
Tomcat version is 6.0.24.
You should obviously remove the class causing the issues, since that is the expected behavior of tomcat if this Thread is frequently being invoked.

Is there a way to log out classes that Java attempts to load, but aren't found on the classpath?

I'm trying to support an old version of a Java web app that I don't have the source to. When I run this program, the log shows the following:
SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'Censored' defined in ServletContext resource [
/WEB-INF/censored.xml]: Class that bean class [com.censored.Censored] depends on not found; nested exception is java.lang.NoClassDefFoundError
java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
...
So I can see what class is throwing the error, but I can't see what dependency it feels is missing. Is there an argument that I can throw into Java somewhere to log out when a class is attempted to be loaded that doesn't really exist?
You could try starting the JVM using the -verbose:class option. That will log all class loading to the console. Maybe that gives you more information.

Initialize Hibernate SessionFactory in a EJB mdb?

I am trying to deploy an MDB in WAS 8.5. The session Factory is being initialized in ejbCreate method. When I try to deploy the application ejb loads successfully and then it shuts down the Queue Activation and gives the following exceptions-
I am not using any framework or MAven for built so all the jars and config files have been added to the classpath as in a Standalone Java Application.
Here are the Hibernate and JAVAEE Jars I am using-
antlr-2.7.7
c3p0-0.9.1
commons-collections-3.2.1
commons-logging-api-1.1.3
dom4j-1.6.1
hibernate-c3p0-4.1.5.Final
hibernate-commons-annotations-4.0.1.Final
hibernate-core-4.1.5.Final
hibernate-entitymanager-4.1.5.Final
hibernate-envers-4.1.5.Final
hibernate-jpa-2.0-api-1.0.1.Final
javassist-3.15.0GA.jar
jboss-logging-3.1.0.GA.jar
jboss-transaction-api_1.1_spec-1.0.0.Final
jms-1.1
log4j-1.2.15
MySQL-connector-java-5.1.22
slf4j-api-1.6.1
javaee.jar
javaee-api-6.0
Here is the exception stacktrace from system logs
EJB threw an unexpected (non-declared) exception during invocation of method "onMessage".Exception data:
javax.ejb.EJBException: MDB PostConstruct failure; nested exception is:
java.lang.Exception: See nested Throwable
at com.ibm.ejs.container.util.ExceptionUtil.EJBException(ExceptionUtil.java:472)
at com.ibm.ejs.container.MessageDrivenBeanO.initialize(MessageDrivenBeanO.java:427)
at com.ibm.ejs.container.BeanOFactory.create(BeanOFactory.java:147)
at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1238)
at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1356)
at com.ibm.ejs.container.activator.UncachedActivationStrategy.atActivate
(UncachedActivationStrategy.java:88)
at com.ibm.ejs.container.activator.Activator.preInvokeActivateBean(Activator.java:615)
at com.ibm.ejs.container.EJSContainer.preInvokeActivate(EJSContainer.java:4205)
at com.ibm.ejs.container.EJSContainer.preInvokeMdbActivate(EJSContainer.java:3709)
at com.ibm.ejs.container.MessageEndpointHandler.beforeDelivery
(MessageEndpointHandler.java:1449)
at com.ibm.ejs.container.MessageEndpointHandler.invokeMessageEndpointMethod
(MessageEndpointHandler.java:866)
at com.ibm.ejs.container.MessageEndpointHandler.invoke(MessageEndpointHandler.java:832)
at $Proxy50.beforeDelivery(Unknown Source)
at com.ibm.mq.connector.inbound.AbstractWorkImpl.run(AbstractWorkImpl.java:188)
at com.ibm.ejs.j2c.work.WorkProxy.run(WorkProxy.java:608)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1783)
Caused by: java.lang.Exception: See nested Throwable
at com.ibm.ejs.container.util.ExceptionUtil.EJBException(ExceptionUtil.java:470)
... 15 more
Caused by: java.lang.NoClassDefFoundError: org.hibernate.HibernateException
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:85)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:162)
at com.hps.superenrollment.ejbmodule.SuperEnrollmentRequestMDB.ejbCreate
(SuperEnrollmentRequestMDB.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor
(InterceptorProxy.java:232)
at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed
(InvocationContextImpl.java:559)
at com.ibm.ejs.container.interceptors.InvocationContextImpl.doLifeCycle
(InvocationContextImpl.java:273)
at com.ibm.ejs.container.MessageDrivenBeanO.initialize(MessageDrivenBeanO.java:411)
Please help me as I am completely lost on what is going wrong here .
The NoClassDefFoundError indicates that some Hibernate class is not in your class-path. Are you sure you have all dependency jars in your classpath (including the jars which are needed at runtime)?
The exception indicating that you should use a PostConstructor method instead of the bean class constructor indicates that you should use the ejbCreate() method. This is the recommended location to initialise and load dependencies of your MDB as it is called by one single thread of the ejb container and ensures that the MDB has been fully constructed before you execute the configuration in the ejbCreate(). It is somewhat similar to the init method in a servlet which is also guaranteed to be called single threaded by the servlet container.

Categories