jlolling / talendcomp_tJasperReportExec

Talend Component tJasperReportExec - Run JasperReports within Talend
Apache License 2.0
2 stars 1 forks source link

ClassCastException in JasperReportExecuter.addPathToClasspath #6

Closed davidfevre-gouv-nc closed 3 years ago

davidfevre-gouv-nc commented 3 years ago

Hi,

I used tJasperReportExec in my talend job and had the following error :

Exception in component tJasperReportExec_1
java.lang.Exception: Failed to add dir /data/development/rapports/jrxml to classpath.class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
    at de.jlo.talendcomp.jasperreportexec.JasperReportExecuter.compileReport(JasperReportExecuter.java:402)
    at de.jlo.talendcomp.jasperreportexec.JasperReportExecuter.compileReport(JasperReportExecuter.java:357)
Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
    at de.jlo.talendcomp.jasperreportexec.JasperReportExecuter.addPathToClasspath(JasperReportExecuter.java:1106)
    at de.jlo.talendcomp.jasperreportexec.JasperReportExecuter.compileReport(JasperReportExecuter.java:398)
    ... 6 more

After looking for an explanation on the Internet, it appears that my OpenJdk11 introduces the bug (Source : https://stackoverflow.com/questions/46694600/java-9-compatability-issue-with-classloader-getsystemclassloader). Indeed, I was running my talend job using OpenJDK11 as JVM.

After using Oracle JDK 8 as JVM all was OK.

So this issue is just to inform you that if you want tJasperReportExec be JAVA 11 compatible, maybe a refactor of JasperReportExecuter.addPathToClasspath() is needed.

Excellent component by the way ! ;-)

Have a great day!

:-) David

jlolling commented 3 years ago

Thanks a lot for your suggestion. I will update the component.

jlolling commented 3 years ago

I have just updated the component and tested it under Java 11. It would be great if you could give it a try and provide your feedback. https://exchange.talend.com/#marketplaceproductoverview:marketplace=marketplace%252F1&p=marketplace%252F1%252Fproducts%252F549&pi=marketplace%252F1%252Fproducts%252F549%252Fitems%252F2960

jlolling commented 3 years ago

Is resolved in the current release.