Compile JasperReports with Gradle gets unsupported version error
Recently i implemented a new builder with gradle runs on jenkins. Our project contains jasper reports so i added below task to compile jasper reports with an ant task which is supplied by jasper reports api.
task compileJasper {
println "############# Compiling JasperReports in Projet $project.name ###################"
def jasperSourceDir =sourceSets.main.java.srcDirs[0]
def jasperTargetDir = sourceSets.main.output.classesDir
def classPath = ant.path {
fileset(dir: "JarLib/", includes: '**.jar')
}
ant {
taskdef(name: 'jrc', classname: 'net.sf.jasperreports.ant.JRAntCompileTask',
classpath: classPath)
jasperTargetDir.mkdirs()
jrc(srcdir: jasperSourceDir, destdir: jasperTargetDir) {
classpath(path: classPath)
include(name: '**/*.jrxml')
}
}
}
Everything is fine with compiling and works as expected but after deploying project to server, at runtime getting the following error.
[8/3/17 14:38:53:340 EET] 000000f5 SystemOut O ERROR [14:38:53,333 - WebContainer : 0] (RunReportBean.java:100) - ****Throwable java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=kybgeneldurum_1501049070032_205074, offset=6 at java.lang.ClassLoader.defineClassImpl(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:275) at net.sf.jasperreports.engine.util.JRClassLoader.loadClass(JRClassLoader.java:337) at net.sf.jasperreports.engine.util.JRClassLoader.loadClassFromBytes(JRClassLoader.java:238) at net.sf.jasperreports.engine.design.JRAbstractJavaCompiler.loadEvaluator(JRAbstractJavaCompiler.java:104) at net.sf.jasperreports.engine.design.JRAbstractCompiler.loadEvaluator(JRAbstractCompiler.java:358) at net.sf.jasperreports.engine.JasperCompileManager.getEvaluator(JasperCompileManager.java:381) at net.sf.jasperreports.engine.fill.JRFillDataset.createCalculator(JRFillDataset.java:467) at net.sf.jasperreports.engine.fill.BaseReportFiller.(BaseReportFiller.java:152) at net.sf.jasperreports.engine.fill.JRBaseFiller.(JRBaseFiller.java:239) at net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:69) at net.sf.jasperreports.engi ne.fill.JRVerticalFiller.(JRVerticalFiller.java:57) at net.sf.jasperreports.engine.fill.JRFiller.createBandReportFiller(JRFiller.java:201) at net.sf.jasperreports.engine.fill.JRFiller.createReportFiller(JRFiller.java:216) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:85) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:456) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:863) at tr.gov.uyap.fonk.report.engine.impl.jasper.JasperReportEngine.runReport(JasperReportEngine.java:95)
We use websphere 8.5 for runtime with java 1.6 . This is java -version output
/opt/IBM/WebSphere/AppServer/java/bin/java -version java version "1.6.0" Java(TM) SE Runtime Environment (build pxa6460_26sr8fp2ifix-20141114_01(SR8 FP2+IV66608+IV66375+IX90155+IV66944)) IBM J9 VM (build 2.6, JRE 1.6.0 Linux amd64-64 Compressed References 20141114_222464 (JIT enabled, AOT enabled) J9VM - R26_Java626_SR8_20141114_1023_B222464 JIT - r11.b07_20141003_74578.01 GC - R26_Java626_SR8_20141114_1023_B222464_CMPRSS J9CL - 20141114_222464) JCL - 20141005_01
At first time i got the error gradle configured to run with java 1.7.0_51 so i changed gradle java to "java 1.6.03" but nothing changed. Any idea ?
I printed all ant properties with the following code in the ant block.
ant {
for (o in properties)
println o
...
..
.
}
I see that gradle somehow use system default java as java.endoresed.dir property although i set the org.gradle.java.home
value to 1.6 in the gradle.properties
file.
java.endorsed.dirs=/usr/java/jdk1.7.0_51/jre/lib/endorsed
I ended up the issue with changing the system java version to 1.6. This maybe a gradle bug.
链接地址: http://www.djcxy.com/p/85054.html上一篇: C#3.5协变问题?