日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

weblogic部署,常见错误解决二——ClassCastException

發布時間:2025/3/15 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 weblogic部署,常见错误解决二——ClassCastException 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

3. weblogic使用了自己帶的xml解析器造成的ClassCastException

早上接到項目組發來的java程序接口報錯信息。分析其中出錯信息如下:

1. Warning: Caught exception attempting to use SAX to load a SAX XMLReader???

2. Warning: Exception was: java.lang.ClassCastException: weblogic.apache.xerces.parsers.SAXParser??

3. Warning: I will print the stack trace then carry on using the default SAX parser??

4. java.lang.ClassCastException: weblogic.apache.xerces.parsers.SAXParser??

5.???? at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(Ljava.lang.String;)Lorg.xml.sax.XMLReader;(XMLReaderFactory.java:128)??

6.???? at org.xml.sax.helpers.XMLReaderFactory.createXMLReader()Lorg.xml.sax.XMLReader;(XMLReaderFactory.java:96)??

7.???? at org.dom4j.io.SAXHelper.createXMLReader(Z)Lorg.xml.sax.XMLReader;(SAXHelper.java:83)??

8.???? at org.dom4j.io.SAXReader.createXMLReader()Lorg.xml.sax.XMLReader;(SAXReader.java:894)??

9.???? at org.dom4j.io.SAXReader.getXMLReader()Lorg.xml.sax.XMLReader;(SAXReader.java:715)??

10.???? at org.dom4j.io.SAXReader.read(Lorg.xml.sax.InputSource;)Lorg.dom4j.Document;(SAXReader.java:435)??

11.???? at org.dom4j.DocumentHelper.parseText(Ljava.lang.String;)Lorg.dom4j.Document;(DocumentHelper.java:278)

Warning: Caught exception attempting to use SAX to load a SAX XMLReader

Warning: Exception was: java.lang.ClassCastException: weblogic.apache.xerces.parsers.SAXParser

Warning: I will print the stack trace then carry on using the default SAX parser

java.lang.ClassCastException: weblogic.apache.xerces.parsers.SAXParser

at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(Ljava.lang.String;)Lorg.xml.sax.XMLReader;(XMLReaderFactory.java:128)

at org.xml.sax.helpers.XMLReaderFactory.createXMLReader()Lorg.xml.sax.XMLReader;(XMLReaderFactory.java:96)

at org.dom4j.io.SAXHelper.createXMLReader(Z)Lorg.xml.sax.XMLReader;(SAXHelper.java:83)

at org.dom4j.io.SAXReader.createXMLReader()Lorg.xml.sax.XMLReader;(SAXReader.java:894)

at org.dom4j.io.SAXReader.getXMLReader()Lorg.xml.sax.XMLReader;(SAXReader.java:715)

at org.dom4j.io.SAXReader.read(Lorg.xml.sax.InputSource;)Lorg.dom4j.Document;(SAXReader.java:435)

at org.dom4j.DocumentHelper.parseText(Ljava.lang.String;)Lorg.dom4j.Document;(DocumentHelper.java:278)

很明顯是因為weblogic使用了自己帶的xml解析器造成的ClassCastException。這個以前遇到過,以前的解決方法是在web-inf下加一個weblogic.xml使用prefer-web-inf-classes標簽配置weblogic優先使用web程序自帶的類庫。

Xml代碼

1. <?xml version="1.0" encoding="UTF-8"?>

2. <!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN" "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">

3. <weblogic-web-app>

4.???? <container-descriptor>

5.???????? <prefer-web-inf-classes>true</prefer-web-inf-classes>

6.???? </container-descriptor>

7. </weblogic-web-app>

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN" "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">

<weblogic-web-app>

<container-descriptor>

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

</container-descriptor>

</weblogic-web-app>


結果到自己的程序下面一看,已經放了這個文件了!暈死,咋整的啊。怎么在weblogic8.1中不好使?

就在網上一頓亂找,結果是好使。但是為什么在我們的項目上不好使那,自己一直用的是tomcat做的程序,沒有在weblogic上測試過。沒辦法只好安裝一個,一測試還真是有這個問題。但是看看自己以前的程序就是這么配置的weblogic.xml文件啊。怎么就不好使了那,這個生氣啊。

靜下心,使勁分析weblogic的出錯日志文件(其實就是看看),分析weblogic使用了自己的SAXParser類,在想想類的裝載順序,一直以為weblogic.xml沒有起作用,就沒想到即使起作用了,你自己的web應用程序下的類庫中如果沒有這個SAXParser類,weblogic還是會用自己帶的weblogic.apache.xerces.parsers.SAXParser。

馬上查自己的程序類庫,xml.jar、xmlparserv2.jar,以為所有的關于xml的類都在這兩個文件里。但是打開兩個包一看,沒有。白忙活了好幾個小時。

想起來自己以前解決過這個問題,當時是在程序中加了xerces.jar。還在奇怪為什么自己現在才想起來。

一切終于平靜了。

馬上寫個日志,記錄下來。

下次希望自己不會再走彎路了。

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的weblogic部署,常见错误解决二——ClassCastException的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。