我在阅读MyBatis 3.0.2的xml配置文件时遇到问题。
我必须在Axis2 1.5的Web服务中使用它。我有一个类代码:
public static org.apache.ibatis.session.SqlSessionFactory getSqlMapper () {
org.apache.ibatis.session.SqlSessionFactory sqlMapper;
try {
String resource = "MyBatis.xml";
java.io.Reader reader = org.apache.ibatis.io.Resources.getResourceAsReader(resource);
sqlMapper = new org.apache.ibatis.session.SqlSessionFactoryBuilder().build(reader);
} catch (Exception e) {
// Si hay un error en este punto, no importa cual sea. Será un error irrecuperable del cual
// nos interesará solo estar informados.
// Deberás registrar el error y reenviar la excepción de forma que se te notifique el
// problema de forma inmediata.
e.printStackTrace();
throw new RuntimeException ("Error initializing MyAppSqlConfig class. Cause: " + e);
}
return sqlMapper;
}
MyBatis.xml是配置文件。当我致电getSqlMapper
时,在sqlMapper = new org...
行中我得到了这个例外:
loader constraint violation: when resolving field "NODE" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the referring class, javax/xml/xpath/XPathConstants, and the class loader (instance of <bootloader>) for the field's resolved type, javax/xml/namespace/QName, have different Class objects for that type org.apache.axis2.AxisFault: loader constraint violation: when resolving field "NODE" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the referring class, javax/xml/xpath/XPathConstants, and the class loader (instance of <bootloader>) for the field's resolved type, javax/xml/namespace/QName, have different Class objects for that type at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:158) at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40) at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173) at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:167) at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:142) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194) at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:102) ... 27 more Caused by: java.lang.LinkageError: loader constraint violation: when resolving field "NODE" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the referring class, javax/xml/xpath/XPathConstants, and the class loader (instance of <bootloader>) for the field's resolved type, javax/xml/namespace/QName, have different Class objects for that type at org.apache.ibatis.parsing.XPathParser.evalNode(XPathParser.java:169) at org.apache.ibatis.parsing.XPathParser.evalNode(XPathParser.java:165) at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:55) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:29) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:15) at es.adif.sgmm.sc.srv.servicio.util.MyBatisUtils.getSqlMapper(MyBatisUtils.java:30) at es.adif.sgmm.sc.srv.servicio.impl.RecepDAO.crearNotificacion(RecepDAO.java:30) at es.adif.sgmm.sc.srv.servicio.impl.ReceptorNotificacion.notificarReal(ReceptorNotificacion.java:40) ... 33 more
我在网上看过很多关于这样的错误,但它让我无处可去。类javax.xml.namespace.Qname
似乎是一个问题,应该在两个不同的地方定义,但我不知道如何解决它。
任何人都知道解决方案吗?