一、问题复现
这个问题困扰我一天多,各种百度看论坛,发现有一种解决方案可能对我有帮助(解决方案)
解决方案说的是可能是xerces包冲突所致
Caused by: java.lang.AbstractMethodError: org.apache.xerces.dom.DocumentImpl.getXmlStandalone()Z at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.setDocumentInfo(DOM2TO.java:377) at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:131) at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:98) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:684) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:728) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:343) at org.apache.poi.openxml4j.opc.StreamHelper.saveXmlInStream(StreamHelper.java:84) at org.apache.poi.openxml4j.opc.internal.marshallers.ZipPartMarshaller.marshallRelationshipPart(ZipPartMarshaller.java:180) at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:559) at org.apache.poi.openxml4j.opc.OPCPackage.save(OPCPackage.java:1539) at org.apache.poi.openxml4j.opc.OPCPackage.close(OPCPackage.java:482) at org.apache.poi.POIXMLDocument.close(POIXMLDocument.java:189) at com.util.ExportExcel.exportExcelTemplate(ExportExcel.java:70) at com.controller.tableController$$FastClassBySpringCGLIB$$b3664c7d.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) at com.cplh.gis.controller.datamanagement.GisBusinessTableController$$EnhancerBySpringCGLIB$$c92ce32c.exportBusinessTableTemplate(<generated>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038) ... 97 common frames omitted
二、解决过程
org.apache.xerces.dom.DocumentImpl 冲突问题:
1.首先发现jdk的rt.jar中com.sun.org.apache.xerces.internal.dom.DocumentImpl有这个类。
2.既然是冲突,肯定程序中有某个依赖也有这个类的源码
查看maven依赖发现
pom.xml中引入的依赖
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>2.7.1</version>
</dependency>
既然是冲突了,那么排除掉xerces依赖传递就可以了 或升级最新版本
<dependency> <groupId>org.geotools</groupId> <artifactId>gt-shapefile</artifactId> <version>2.7.1</version> <exclusions> <exclusion> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> </exclusion> </exclusions> </dependency>
总结:
此问题应该是xerces包冲突问题导致,但是至于是哪个包的冲突需要仔细找找看(因为引入的依赖不同,参照的解决方案引入的依赖是jmimemagic而我引入的依赖是gt-shapefile),确定包冲突后,排除掉xerces依赖传递就好了