Hi everyone! I have a problem reading the xml config file for Mybatis 3.0.2.
I have to use it in a web service with Axis2 1.5. I have a class whith this code:
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; }
Where MyBatis.xml is the config file. When I call to getSqlMapper, in the line sqlMapper = new org.... I get this exception:
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 ) 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 ) 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
I have read a lot on the internet about errors like this but it don't bring me to no place. It seems to be a problem with the class Qname, that should be defined in two different places but I don't know how to fix it.
Anyone knows a solution?
Thanks for all!