2013-11-15 78 views
6

我正在將Weblogic服務器從9升級到10.3.6。當我試圖部署我的耳朵應用程序,並得到以下例外。.ClassCastException:org.apache.xerces.jaxp.DocumentBuilderFactoryImpl無法轉換爲javax.xml.parsers.DocumentBuilderFactory

Caused By: java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory 
    at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:123) 
    at org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:89) 
    at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310) 
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) 
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) 
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) 
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212) 
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113) 
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:80) 
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123) 
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353) 
    at org.springframework.context.access.ContextSingletonBeanFactoryLocator.initializeDefinition(ContextSingletonBeanFactoryLocator.java:141) 
    at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:384) 
    at org.springframework.web.context.ContextLoader.loadParentContext(ContextLoader.java:341) 
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:195) 
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) 
    at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481) 
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) 
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) 
    at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181) 
    at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1868) 

我嘗試了各種各樣的東西,包括添加weblogic-application.xml,但它仍然無法正常工作。

<?xml version="1.0" encoding="UTF-8"?> 
    <weblogic-application> 
<xml> 
<parser-factory> 
    <saxparser-factory> 
     org.apache.xerces.jaxp.SAXParserFactoryImpl 
    </saxparser-factory> 
    <document-builder-factory> 
     org.apache.xerces.jaxp.DocumentBuilderFactoryImpl 
    </document-builder-factory> 
    <transformer-factory> 
     org.apache.xalan.processor.TransformerFactoryImpl 
    </transformer-factory> 
    </parser-factory> 
</xml> 

<prefer-application-packages> 
<package-name>org.apache.xerces.parsers.*</package-name> 
</prefer-application-packages> 
</weblogic-application> 

我weblogic.xml中有

<prefer-web-inf-classes>true</prefer-web-inf-classes> 

這是我的pom.xml的一部分:

<dependency> 
<groupId>xerces</groupId> 
<artifactId>xercesImpl</artifactId> 
<version>2.8.1</version> 
<scope>runtime</scope> 
</dependency> 

請幫助。謝謝!

回答

12

我回答我的問題:

下面的鏈接啓發了我解決這個問題的:

Dealing with "Xerces hell" in Java/Maven?

Basiclly我已刪除XML的API,並在pom.xml中xmlParserAPIs的所有依賴。問題已解決。根本原因是我的類路徑不應包含導致與Weblogic應用程序服務器存在庫衝突的任何javax庫。希望能幫助到你。

+0

你能告訴我你做了什麼嗎?我將Spring MDP添加到WL應用程序,現在不會部署相同的錯誤。 –

相關問題