我們的Web應用程序使用的JasperReports 3.0.0生成PDF,我開始從火星把我們的IDE版本(Eclipse的)氧氣,這是基於JDK 8 一切順利,因爲我們跑我們的JUnit測試來模擬報表創作..UnsupportedClassVersionError與JasperReports的3.0.0
配置的JDK Eclipse內爲我們的項目設置在JDK 7.x的,而OS(Ubuntu的16.04 LTS)設置爲JDK 8 如果我跑我的測試,它返回給我的例外我附上以下:
java.lang.UnsupportedClassVersionError: RicevutaNoPrenotazione_1504035333064_598616 : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClass(JRClassLoader.java:342)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassFromBytes(JRClassLoader.java:243)
at net.sf.jasperreports.engine.design.JRAbstractJavaCompiler.loadEvaluator(JRAbstractJavaCompiler.java:92)
at net.sf.jasperreports.engine.design.JRAbstractCompiler.loadEvaluator(JRAbstractCompiler.java:320)
at net.sf.jasperreports.engine.JasperCompileManager.loadEvaluator(JasperCompileManager.java:244)
at net.sf.jasperreports.engine.fill.JRFillDataset.createCalculator(JRFillDataset.java:411)
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:405)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:77)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:59)
at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:147)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:83)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
at it.loginet.petrol.infrastructure.jasper.PetrolReport.fillTemplateWithParameters(PetrolReport.java:171)
at it.loginet.petrol.infrastructure.jasper.PetrolReport.createJasperPrint(PetrolReport.java:166)
at it.loginet.petrol.infrastructure.jasper.PetrolReport.exportReportToXml(PetrolReport.java:161)
at it.loginet.petrol.application.prenotazione.StampaNoPrenotazione.printAsXml(StampaNoPrenotazione.java:60)
at it.loginet.petrol.application.prenotazione.StampaNoPrenotazioneOnlineTest.verifyGeneratedXml(StampaNoPrenotazioneOnlineTest.java:71)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
看來JasperReports需要g JDK(8)編譯我們的報告,儘管我們將項目設置爲在JDK 7下運行。 實際上,如果我在操作系統上運行設置JDK 7的JasperReports測試,一切都會正常進行。
我在我們的機器上缺少什麼配置?
希望我解釋我們的處境顯然,隨意問任何問題:) 感謝
與應用程序(Java 7的基礎),你可以用這個老圖書館,但看起來像您使用的JasperReports的與Java 8合作編制*碧玉*文件(*不支持major.minor版本52.0 *) –
您是否正在編譯模板或在失敗的測試中使用* jasper *文件? –
[如何解決java.lang.UnsupportedClassVersionError:Unsupported major.minor版本]可能的重複(https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor -versi) – Yannick