ClassCastException running Spring app on Weblogic 9.2

Question!

I'm trying to deploy a Spring 3 application to Weblogic 9.2. The JDK is JRockit 1.5. I'm using jaxb 2.1 and am including those jars in the war.

I've tried adding this to weblogic.xml thinking I've got a conflict between what I'm including and the environment I'm running it in.

<wls:container-descriptor>
  <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>

Still no luck. Am I doing something verboten, or just missing a crucial piece of configuration?

If I've left out something relevant, please ask. Thanks in advance.

Here's the error:

 [wldeploy] java.lang.ClassCastException: weblogic.xml.jaxp.RegistryDocumentBuilderFactory
 [wldeploy]   at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
 [wldeploy]   at org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:87)
 [wldeploy]   at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:68)
 [wldeploy]   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:361)
 [wldeploy]   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:313)
 [wldeploy]   at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:290)
 [wldeploy]   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
 [wldeploy]   at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
 [wldeploy]   at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
 [wldeploy]   at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
 [wldeploy]   at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101)
 [wldeploy]   at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:394)
 [wldeploy]   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:324)
 [wldeploy]   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
 [wldeploy]   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
 [wldeploy]   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
 [wldeploy]   at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:376)
 [wldeploy]   at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
 [wldeploy]   at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
 [wldeploy]   at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:82)
 [wldeploy]   at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1608)
 [wldeploy]   at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2750)
 [wldeploy]   at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:889)
 [wldeploy]   at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:333)
 [wldeploy]   at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
 [wldeploy]   at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
 [wldeploy]   at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
 [wldeploy]   at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
 [wldeploy]   at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:117)
 [wldeploy]   at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
 [wldeploy]   at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
 [wldeploy]   at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
 [wldeploy]   at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:26)
 [wldeploy]   at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635)
 [wldeploy]   at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
 [wldeploy]   at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
 [wldeploy]   at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:154)
 [wldeploy]   at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
 [wldeploy]   at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:566)
 [wldeploy]   at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:136)
 [wldeploy]   at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:104)
 [wldeploy]   at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:320)
 [wldeploy]   at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:815)
 [wldeploy]   at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1222)
 [wldeploy]   at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:433)
 [wldeploy]   at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:161)
 [wldeploy]   at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:181)
 [wldeploy]   at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:12)
 [wldeploy]   at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:67)
 [wldeploy]   at weblogic.work.ExecuteRequestAdapter.execute(ExecuteRequestAdapter.java:21)
 [wldeploy]   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:145)
 [wldeploy]   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:117)


Answers

Seems like this ClassCastException is a result of a classloading conflict.

You said that you're bundling some JAR files with your Web application (I presume in the WEB-INF/lib); I suspect that what happens is that weblogic.xml.jaxp.RegistryDocumentBuilderFactory, which is WebLogic's DocumentBuilderFactory implementation, is loaded by a different classloader than the one that loaded one of its interfaces (or its superclass, which is JAXP's DocumentBuilderFactory).

Let us know which JAR files you're packaging inside WEB-INF/lib; I'm pretty sure the culprit is there.

By : Isaac


This video can help you solving your question :)
By: admin