一个很让我郁闷的java异常

今天下午遇到一个很让我恼火的异常,整了N久也没有搞出来!虽然知道是包冲突,可是也找不出来原因。

]] Root cause of ServletException.
java.lang.LinkageError: loader constraint violation: when resolving method "javax.xml.validation.SchemaFactory.newSchema(Ljavax/xml/transform/Source;)Ljavax/xml/validation/Schema;" the class loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader) of the current class, com/geostar/csw/util/JaxbUtil, and the class loader (instance of <bootloader>) for resolved class, javax/xml/validation/SchemaFactory, have different Class objects for the type javax/xml/transform/Source used in the signature
 at com.geostar.csw.util.JaxbUtil.Xml2Object(JaxbUtil.java:122)
 at com.geostar.csw.servlet.CSWServlet.doPost(CSWServlet.java:85)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
 at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
 Truncated. see log file for complete stacktrace
>

其中关键的代码: at com.geostar.csw.util.JaxbUtil.Xml2Object(JaxbUtil.java:122) 实现如下:

一个很让我郁闷的java异常 View Code
 1  public  static  Object Xml2Object(Class<?> clazz,InputStream is,InputStream  schema)throws SAXException,JAXBException{
2 Object obj = null ;
3 try{
4 ValidationEventCollector vec = new ValidationEventCollector();
5 SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
6 InputSource inSource=new InputSource(schema);
7 SAXSource sax=new SAXSource(inSource);
8 Schema sch = sf.newSchema(sax); //出错的地方
9 JAXBContext jc = JAXBContext.newInstance(clazz.getPackage().getName());
10 Unmarshaller u = jc.createUnmarshaller();
11 u.setSchema(sch);
12 u.setEventHandler(vec);
13 obj = u.unmarshal(is);
14 }
15 catch(SAXException e){
16 throw new SAXException(e.getMessage());
17 }catch(JAXBException e){
18 throw new JAXBException(e.getMessage());
19 }
20 return obj;
21 };

其中:Schema类型为:javax.xml.validation.Schema;SchemaFactory为javax.xml.validation.SchemaFactory,JDK为1.6的。不知道怎么解决这个问题!

汗~~~~~~~~~~~~~~~~。

在网上看了一下,别人说可能和weblogic的包冲突,于是我又配置了一个weblogic.xml

内容如下:

 

一个很让我郁闷的java异常 View Code
<?xml version="1.0" encoding="UTF-8"?>

<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
<jsp-descriptor>
<keepgenerated>true</keepgenerated>
<page-check-seconds>60</page-check-seconds>
<precompile>true</precompile>
<precompile-continue>true</precompile-continue>
</jsp-descriptor>
<container-descriptor>
<optimistic-serialization>true</optimistic-serialization>
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>

 

你可能感兴趣的:(JAVA异常)