word导出报错:java.lang.NoClassDefFoundError: com/deepoove/poi/NiceXWPFDocument

word导出:java.lang.NoClassDefFoundError: com/deepoove/poi/NiceXWPFDocument

问题的发生:

        在做一个word导出的需求,使用了如下代码以及使用了 poi-tl-1.5.0.jar 这个jar包

XWPFTemplate template = XWPFTemplate.compile(templatePath).render(paramMap);

        刚开始第一次报的错是jdk版本错 这个错就不沾出来了。具体原因是由于我的项目环境用的jdk1.7版本,而这个jar包只支持1.8版本的jdk。

然后我就把jar包换成了 poi-tl-0.0.3.jar 版本。将代码换成1.7之前的版本:

XWPFTemplate template = XWPFTemplate.create(realPath); RenderAPI.render(template,paramMap);

        启动后点击自己做的功能,就开始报这个 java.lang.NoClassDefFoundError: com/deepoove/poi/NiceXWPFDocument 错误。

        后来想会不会是依赖没导完全,于是就在maven上面把poi相关的1.7版本的包都下载了下来

然后项目启动

又报了个不同的错:

java.lang.NoSuchMethodError: org.apache.poi.util.POILogger.log(I[Ljava/lang/Object;)V

at org.apache.poi.util.DocumentHelper.trySetSAXFeature(DocumentHelper.java:66)

at org.apache.poi.util.DocumentHelper.(DocumentHelper.java:56)

at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:377)

at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.(ContentTypeManager.java:103)

at org.apache.poi.openxml4j.opc.internal.ZipContentTypeManager.(ZipContentTypeManager.java:54)

at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:190)

at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:684)

at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:275)

at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)

at org.apache.poi.xwpf.usermodel.XWPFDocument.(XWPFDocument.java:123)

at com.deepoove.poi.NiceXWPFDocument.(NiceXWPFDocument.java:55)

at com.deepoove.poi.XWPFTemplate.create(XWPFTemplate.java:63)

at com.deepoove.poi.XWPFTemplate.create(XWPFTemplate.java:57)

at com.nstc.poms.business.export.WordExportFiveReport.execute(WordExportFiveReport.java:53)

at com.nstc.poms.business.print.BaseAction.perform(BaseAction.java:88)

at com.nstc.waf.controller.web.RequestProcessor.processWebAction(RequestProcessor.java:122)

at com.nstc.waf.controller.web.RequestProcessor.processRequest(RequestProcessor.java:62)

at com.nstc.smartform.waf.SmartRequestProcessor.processRequest(SmartRequestProcessor.java:69)

at com.nstc.waf.controller.web.RequestProcessor.processRequest(RequestProcessor.java:33)

at com.nstc.waf.controller.web.MainServlet.doProcess(MainServlet.java:123)

at com.nstc.smartform.waf.SmartMainServlet.doProcess(SmartMainServlet.java:73)

at com.nstc.waf.controller.web.MainServlet.doGet(MainServlet.java:49)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)

at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)

at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)

at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)

at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)

at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)

at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

at com.nstc.uas.client.UASFilter.doChain(UASFilter.java:83)

at com.nstc.uas.client.UASFilter.doFilter(UASFilter.java:58)

at com.nstc.uas.client.UASFilter.doFilter(UASFilter.java:34)

at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)

at com.nstc.waf.spring.orm.hibernate3.ExtOpenSessionInView.doFilterInternal(ExtOpenSessionInView.java:33)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

at com.nstc.nssafe.filter.XssFilter.doFilter(XssFilter.java:89)

at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

at com.nstc.assem.filter.BaseAssemFilter.doRequest(BaseAssemFilter.java:79)

at com.nstc.assem.filter.BaseAssemFilter.doFilter(BaseAssemFilter.java:96)

at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)

at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3367)

at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3333)

at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)

at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)

at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2220)

at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146)

at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124)

at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564)

at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)

at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)

at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)

查找了一下,应该是poi的版本不一致造成的

然后把除去poi-tl-0.03版本的包 其他poi的版本换成了统一的版本:poi-3.13.jar   poi-ooxml-3.13.jar     poi-ooxml-schemas-3.13.jar

最后问题解决

总结:

1.将各个poi的包换成自己运行环境的jdk版本的包

2.poi的jar包没导完全,有些相互有依赖的包

3.poi-.jar poi-ooxml-.jar poi-ooxml-schemas-.jar 用统一版本

你可能感兴趣的:(java踩坑记录,java,apache,servlet)