urule知识包的仿真测试导出excel报错java.lang.NoSuchMethodError

在我们配置好的决策引擎项目中打开知识包,进入仿真测试,选择添加新的测试方案。

urule知识包的仿真测试导出excel报错java.lang.NoSuchMethodError_第1张图片

点击下载Excel模板

urule知识包的仿真测试导出excel报错java.lang.NoSuchMethodError_第2张图片

选择要导出的字段

urule知识包的仿真测试导出excel报错java.lang.NoSuchMethodError_第3张图片

然后报错:

"org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(Ljava/lang/String;)Lorg/apache/poi/xssf/streaming/SXSSFSheet;"

"java.lang.NoSuchMethodError: org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(Ljava/lang/String;)Lorg/apache/poi/xssf/streaming/SXSSFSheet;
	at com.bstek.urule.console.servlet.test.TestScenorioServletHandler.buildScenarioSheet(TestScenorioServletHandler.java:297)
	at com.bstek.urule.console.servlet.test.TestScenorioServletHandler.generateExcel(TestScenorioServletHandler.java:276)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at com.bstek.urule.console.servlet.BaseServletHandler.invokeMethod(BaseServletHandler.java:29)
	at com.bstek.urule.console.servlet.test.TestScenorioServletHandler.execute(TestScenorioServletHandler.java:82)
	at com.bstek.urule.console.servlet.URuleServlet.service(URuleServlet.java:85)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at com.rds.szrcb.web.filter.UruleFilter.doFilter(UruleFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
"

原因分析:

根据报错信息:

"java.lang.NoSuchMethodError: org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(Ljava/lang/String;)Lorg/apache/poi/xssf/streaming/SXSSFSheet;

没有这个方法。

问题查找:

检查urule本身的POI版本是否和项目中的POI版本一致

解决方案:

项目中的POI版本为3.10,而pro版的urule的POI版本为3.16。

将项目中的POI版本更新到3.16,就可以解决“下载Excel模板”导出的问题。

 

备注:我使用的urule版本是pro2.1.3版本的。

 

成功下载后的Excel模板:

urule知识包的仿真测试导出excel报错java.lang.NoSuchMethodError_第4张图片

 

另附检测POI版本的代码

import java.net.URL;

public static void main(String[] args) {
		ClassLoader classLoader = org.apache.poi.poifs.filesystem.POIFSFileSystem.class.getClassLoader();
		URL res = classLoader.getResource("org/apache/poi/poifs/filesystem/POIFSFileSystem.class");
		String path = res.getPath();
		System.out.println("POI Core came from : " + path);
		
		classLoader = org.apache.poi.POIXMLDocument.class.getClassLoader();
		res = classLoader.getResource("org/apache/poi/POIXMLDocument.class");
		path = res.getPath();
		System.out.println("POI OOXML came from : " + path);
		
		/*classLoader = org.apache.poi.hslf.HSLFSlideShow.class.getClassLoader();
		res = classLoader.getResource("org/apache/poi/hslf/HSLFSlideShow.class");
		path = res.getPath();
		System.out.println("POI Scratchpad came from : " + path);*/
	}

	
输出结果:

POI Core came from
file:/D:/develop/maven/mavenRepository/mavenJar/org/apache/poi/poi/3.10-FINAL/poi-3.10-FINAL.jar!/org/apache/poi/poifs/filesystem/POIFSFileSystem.class

POI Core came from : 
file:/D:/develop/maven/mavenRepository/mavenJar/org/apache/poi/poi/3.10-FINAL/poi-3.10-FINAL.jar!/org/apache/poi/poifs/filesystem/POIFSFileSystem.class
POI OOXML came from : 
file:/D:/develop/maven/mavenRepository/mavenJar/org/apache/poi/poi-ooxml/3.10-FINAL/poi-ooxml-3.10-FINAL.jar!/org/apache/poi/POIXMLDocument.class
POI Scratchpad came from : 
file:/D:/develop/maven/mavenRepository/mavenJar/org/apache/poi/poi-scratchpad/3.10-FINAL/poi-scratchpad-3.10-FINAL.jar!/org/apache/poi/hslf/HSLFSlideShow.class

 

你可能感兴趣的:(urule)