1
votes

I'm trying to deploy the sample application on Weblogic 12c. I can run it just fine in Tomcat, but when I try and deploy it to Weblogic, I get the following error:

SEVERE: Context initialization failed java.lang.NoClassDefFoundError: org/apache/log4j/Logger

I've check the pom.xml and I know that log4j is included in the dependencies. Here's the stacktrace:

SEVERE: Context initialization failed java.lang.NoClassDefFoundError: org/apache/log4j/Logger at org.opensaml.xml.XMLConfigurator.(XMLConfigurator.java:60) at org.opensaml.DefaultBootstrap.initializeXMLTooling(DefaultBootstrap.java:195) at org.opensaml.DefaultBootstrap.bootstrap(DefaultBootstrap.java:91) at org.opensaml.PaosBootstrap.bootstrap(PaosBootstrap.java:27) at org.springframework.security.saml.SAMLBootstrap.postProcessBeanFactory(SAMLBootstrap.java:42) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:676) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:678) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57) at weblogic.servlet.internal.EventsManager.executeContextListener(EventsManager.java:243) at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:200) at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:185) at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1838) at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2876) at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1661) at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:823) at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:360) at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:356) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42) at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:138) at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124) at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216) at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42) at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:73) at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:24) at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:729) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42) at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:258) at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:61) at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165) at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80) at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:226) at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:418) at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51) at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:200) at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30) at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:240) at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169) at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123) at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:210) at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:118) at weblogic.server.AbstractServerService.postConstruct(AbstractServerService.java:78) at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1017) at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:388) at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:430) at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456) at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:225) at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:82) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2488) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98) at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:606) at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:77) at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:231) at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:254) at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:413) at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456) at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:225) at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:82) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2488) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87) at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:1162) at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:1147) at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:548) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311) at weblogic.work.ExecuteThread.run(ExecuteThread.java:263) Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 76 more

(XMLConfigurator.java:60) at org.opensaml.DefaultBootstrap.initializeXMLTooling(DefaultBootstrap.java:195) at org.opensaml.DefaultBootstrap.bootstrap(DefaultBootstrap.java:91) at org.opensaml.PaosBootstrap.bootstrap(PaosBootstrap.java:27) at org.springframework.security.saml.SAMLBootstrap.postProcessBeanFactory(SAMLBootstrap.java:42) Truncated. see log file for complete stacktrace Caused By: java.lang.ClassNotFoundException: org.apache.log4j.Logger at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) Truncated. see log file for complete stacktrace

(XMLConfigurator.java:60) at org.opensaml.DefaultBootstrap.initializeXMLTooling(DefaultBootstrap.java:195) at org.opensaml.DefaultBootstrap.bootstrap(DefaultBootstrap.java:91) at org.opensaml.PaosBootstrap.bootstrap(PaosBootstrap.java:27) at org.springframework.security.saml.SAMLBootstrap.postProcessBeanFactory(SAMLBootstrap.java:42) Truncated. see log file for complete stacktrace Caused By: java.lang.ClassNotFoundException: org.apache.log4j.Logger at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) Truncated. see log file for complete stacktrace (XMLConfigurator.java:60) at org.opensaml.DefaultBootstrap.initializeXMLTooling(DefaultBootstrap.java:195) at org.opensaml.DefaultBootstrap.bootstrap(DefaultBootstrap.java:91) at org.opensaml.PaosBootstrap.bootstrap(PaosBootstrap.java:27) at org.springframework.security.saml.SAMLBootstrap.postProcessBeanFactory(SAMLBootstrap.java:42) Truncated. see log file for complete stacktrace Caused By: java.lang.ClassNotFoundException: org.apache.log4j.Logger at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) Truncated. see log file for complete stacktrace Sep 05, 2014 11:20:17 AM org.springframework.web.servlet.FrameworkServlet initServletBean INFO: FrameworkServlet 'saml': initialization started (XMLConfigurator.java:60) at org.opensaml.DefaultBootstrap.initializeXMLTooling(DefaultBootstrap.java:195) at org.opensaml.DefaultBootstrap.bootstrap(DefaultBootstrap.java:91) at org.opensaml.PaosBootstrap.bootstrap(PaosBootstrap.java:27) at org.springframework.security.saml.SAMLBootstrap.postProcessBeanFactory(SAMLBootstrap.java:42) Truncated. see log file for complete stacktrace Caused By: java.lang.ClassNotFoundException: org.apache.log4j.Logger at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) Truncated. see log file for complete stacktrace

Any ideas why this is bombing out on Weblogic? Thanks in advance!

2

2 Answers

1
votes

Possible reasons:

a) Its included in the dependencies but the Log4j jar is not present in the class path, or has moved. Please check if it is present in the class path.

b) It's often caused by importing in the webapp librairies (WEB-INF/lib), JARs that are already available in the application server.

Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.

See Also:

During Deployment in Weblogic.

nested exception is java.lang.NoClassDefFoundError: org/hibernate/ejb/HibernatePersistence

0
votes

Make sure that log4j.jar is actually inside the war (I'm guessing it's a web application) built by maven.