Spring+quartz giving java.lang.NoClassDefFoundError: weblogic/logging/LogEntryFormatter - java

Im following http://www.mkyong.com/spring/spring-quartz-scheduler-example/ to develop a job for my spring app... Im getting the following exception when im trying to run it.
Can anyone tell whats the resolution for this?
Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/logging/LogEntryFormatter >
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:891)
at java.lang.ClassLoader.loadClass(ClassLoader.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at weblogic.logging.commons.LogImpl.<init>(LogImpl.java:14)
at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:21)
at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:18)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:145)
at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:70)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:45)
at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:59)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:84)
at com.jobs.RunMeJob.main(RunMeJob.java:10)

Seems like you are using the weblogic common logging mechanism in your app...and missing some jars/classes in your WL classpath. Can you post your classpath?
Also, you might want to try SLF4J for logging (http://www.slf4j.org) which I find so much easier to use (as well as versatile, allowing you to use any underlying logging mechanism, such as popular log4j for example)

If you deployed quartz to your Weblogic domain's lib directory you need to ensure that all of quartz dependencies are also deployed to the same directory.
I solved a similar problem by deploying jcl-over-slf4j and slf4j-api.

Related

java.lang.NoSuchMethodError: org/jboss/logging/Logger.debug

While my application is being deployed to websphere 9 i get this error
Caused by: java.lang.NoSuchMethodError:
org/jboss/logging/Logger.debugf(Ljava/lang/String;I)V (loaded from
file:/C:/server/IBM/WebSphere90/AppServer/plugins/com.ibm.ws.cdi.logging.jar
It seems that the above jar is being loaded before jboss-logging-3.3.0.Final.jar used by hibernate.
At the same time i have a different machine on which this issue is not present.
com.ibm.ws.cdi.logging.jar is missing from the path and the error no longer occurs.
How to fix the error and why in one installation the cdi.logging.jar is present and in the not?
You could add jboss-logging-3.3.0.Final.jar as an isolated shared library and associate it with your application. That will cause it to be preferred over anything provided by the application server.
Since you have com.ibm.ws.cdi.logging.jar you must be on Websphere 9.0.0.0, I would suggest upgrading to Websphere 9.0.0.5 or later, your issue should be resolved by PI79787.
Best regards.

JBoss and Quartz

I'm trying to see if Quartz can solve a problem for me. But I can't get it to work. Right now I'm stuck at the following error (relevant part)
Caused by: org.quartz.SchedulerConfigException: Unable to instantiate class load helper class: org.quartz.simpl.CascadingClassLoadHelper cannot be cast to org.quartz.spi.ClassLoadHelper [See nested exception: java.lang.ClassCastException: org.quartz.simpl.CascadingClassLoadHelper cannot be cast to org.quartz.spi.ClassLoadHelper]
at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:706)
at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1484)
at org.jboss.seam.async.QuartzDispatcher.initScheduler(QuartzDispatcher.java:69)
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 org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
... 73 more
Caused by: java.lang.ClassCastException: org.quartz.simpl.CascadingClassLoadHelper cannot be cast to org.quartz.spi.ClassLoadHelper
at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:703)
I have googled and it seems to be a question that is asked a lot but I don't find any answers. I have the quartz-jars in both my webapp and ear.
Is there anything in my configuration that can cause this problem?
JBoss 5.1
Quartz JBoss 2.1.6
This is a class loading issue. JBoss already has the org.quartz.spi.ClassLoadHelper.class in its class path since JBoss uses it for internal timers for different tasks. The JBoss provided quartz.jar is located in /jboss-as/common/lib/quartz.jar . So you are providing another quartz.jar with your application which is causing conflict with the existing quartz classes that is provided with JBoss.
To solve this issue you have two options:
Option 1. Remove the quartz jars from your ear and war. This is the better and easier option in my opinion unless for some reason you need a different version of quartz for your application than the one JBoss provides.
Option 2. Create a META-INF\jboss-classloading.xml file and isolate your ear (and may be your WAR WEB-INF\jboss-classloading.xml if there is a need for the EAR classes to not see WAR classes). This blog is one of the good ones at explaining the jboss5 or jboss6 class loading and this tutorial based blog is also a good resource.

NoClassDefFoundError while deploying an application on WAS

I am trying to deploy an application on WAS 6.1 Server.
However, I am getting the below error:
java.lang.NoClassDefFoundError: org.apache.log4j.Logger
at myPackage.myClass.<clinit>(myClass.java:40)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:194)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1328)
at com.ibm.ejs.container.EJSContainer.loadBeanMetaData(EJSContainer.java:1756)
at com.ibm.ejs.container.HomeOfHomes.loadBeanMetaData(HomeOfHomes.java:1073)
at com.ibm.ejs.container.HomeRecord.getHomeAndInitialize(HomeRecord.java:454)
at com.ibm.ejs.container.EJSContainer.getHomeWrapperCommon(EJSContainer.java:1322)
at com.ibm.ejs.container.EJSContainer.getHomeInstance(EJSContainer.java:1231)
at com.ibm.ejs.container.EJSContainer.startBean(EJSContainer.java:1217)
at com.ibm.ws.runtime.component.EJBContainerImpl.startBean(EJBContainerImpl.java:3385)
at com.ibm.ws.runtime.component.EJBContainerImpl.startModule(EJBContainerImpl.java:2589)
at com.ibm.ws.runtime.component.EJBContainerImpl.start(EJBContainerImpl.java:3719)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1304)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1165)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:587)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:832)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:950)
at com.ibm.ws.runtime.component.ApplicationMgrImpl$AppInitializer.run(ApplicationMgrImpl.java:2131)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:342)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at com.ibm.ws.classloader.CompoundClassLoader.findClass(CompoundClassLoader.java:579)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:414)
at java.lang.ClassLoader.loadClass(ClassLoader.java:597)
... 22 more
In
Admin Console -> Servers -> Application Servers -> myServerName -> Java and Process Management -> Process Definition -> Java Virtual Machine -> ClassPath
I have an entry as below:
${MY_JARS}\log4j-1.2.15.jar
Where in 'Custom Properties' MY_JARS key contains value as the path to the log4j jar
I did server clean and restart, republish, redeploy the application umpteen number of times. But this error is not going.
What am I doing wrong ?
To use ${MY_JARS} that way, you need to define it in Environment > WebSphere Variables, not in Custom Properties.
However I'd caution you about adding log4j in that manner. I seem to recall log4j might not work correctly if a single jar is shared across multiple apps. I think we attempted using log4j as a Shared Library (probably the more recommended way of doing what you're trying to do, BTW), but ended up needing to deploy to each application's WEB-INF/lib instead.
As dbreaux already pointed out you have to create environment variables with the correct scope. A custom property is available at runtime, but not for the server configuration level.
Within the WAS you can check what libraries are loaded. IIRC you have to click on the Application, afterwards on the Web Module and than you should be able to check the classloaders. If you open up the classloaders, you will see what libraries are loaded.
Please make sure log4j.jar is on the CLASSPATH of your application.For example; under WEB-INF\lib

Maven / Spring: AopNamespaceUtils NoSuchMethod Error

Using Maven to build my project under windows works fine, but when I build it under Linux I get a NoSuchMethodError regarding one of the spring libs.
I am guessing it is something to do with class loader differences cross-platform and somewhere in my dependencies and I may have the same class twice but windows is loading one while linux loads the other?
Has anyone come across this problem before, or have any advice on how I can debug this error further?
nested exception is java.lang.NoSuchMethodError:
org.springframework.aop.config.AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(Lorg/springframework/beans/factory/xml/ParserContext;Lorg/w3c/dom/Element;)V:
java.lang.NoSuchMethodError:
org.springframework.aop.config.AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(Lorg/springframework/beans/factory/xml/ParserContext;Lorg/w3c/dom/Element;)V
at org.springframework.transaction.config.AnnotationDrivenBeanDefinitionParser$AopAutoProxyConf
Stack Trace Pastie
POM.xml Pastie
Your spring dependencies have too many different versions:
org.springframework:spring-beans:jar:2.5.6:compile
org.springframework:spring-aop:jar:2.0.8:compile
org.springframework:spring-jms:jar:3.0.5.RELEASE:compile
Make all spring dependencies have the same version (preferably 3.0.5.RELEASE)

NoClassDefFoundError in spring

I wrote a Spring application which runs on Weblogic 10.3. In this application I have some JMS Queue consumers.
Sometimes I got an error when the application is closing or opening (I saw this error in both situation) saying:
java.lang.NoClassDefFoundError: org/springframework/jms/connection/SmartConnectionFactory
at org.springframework.jms.connection.ConnectionFactoryUtils.releaseConnection(ConnectionFactoryUtils.java:72)
at org.springframework.jms.listener.AbstractJmsListeningContainer.refreshSharedConnection(AbstractJmsListeningContainer.java:385)at org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:779)
at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:761)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:892)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: org.springframework.jms.connection.SmartConnectionFactory
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:176)
at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:35)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
... 6 more
Why do I get this error and what should I do to solve it?
The version of the spring.jar is 2.5.5
That Exception means that the class is not getting loaded into the JVM. Make sure that the spring.jar is in the Weblogic server's classpath or library folder.
It's all very well that you have this class in your war, but in Weblogic, the war has its own classloader. Since your stack trace shows a JMS listener, I'd ask: where is the listener? If it's in the war, then you have a mystery. But it sure looks as though it's somewhere else, and it's that somewhere else that would be missing this Spring class.

Categories

Resources