zoukankan      html  css  js  c++  java
  • 一个很让我郁闷的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) 实现如下:

    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

    内容如下:

    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>
  • 相关阅读:
    大数加法、乘法实现的简单版本
    hdu 4027 Can you answer these queries?
    zoj 1610 Count the Colors
    2018 徐州赛区网赛 G. Trace
    1495 中国好区间 尺取法
    LA 3938 动态最大连续区间 线段树
    51nod 1275 连续子段的差异
    caioj 1172 poj 2823 单调队列过渡题
    数据结构和算法题
    一个通用分页类
  • 原文地址:https://www.cnblogs.com/likehua/p/2299926.html
Copyright © 2011-2022 走看看