I'm trying to compile a JasperDesign to create a report programmatically. Since I need to include a Conditional Style in Javascript, I set the JasperDesign language accordingly:
val jasperDesign = new JasperDesign
jasperDesign.setLanguage("javascript")
Note that I'm using Scala 2.11 on Java 8, running on Play for Scala 2.5
Since JasperReports 6.4.3 (the version I'm using) has a dependency on rhino 1.7.6, I added it to the classpath:
libraryDependencies += "org.mozilla" % "rhino" % "1.7.6"
The problem is that whenever I compile the JasperDesign I get an exception. This happens even when I don't include a Javascript Conditional Style:
java.lang.NoSuchMethodError: org.mozilla.javascript.ContextFactory.enterContext()Lorg/mozilla/javascript/Context; at net.sf.jasperreports.compilers.JavaScriptClassCompiler.compileUnits(JavaScriptClassCompiler.java:124) at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:203) at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:357) at net.sf.jasperreports.engine.JasperCompileManager.compileToStream(JasperCompileManager.java:326) at net.sf.jasperreports.engine.JasperCompileManager.compileReportToStream(JasperCompileManager.java:599)
If I remove jasperDesign.setLanguage("javascript")
I have no compilation errors. What is missing here? Is there a conflict between Nashorn and Rhino?
ContextFactory.enterContext()
was added with 1.7R1. – ShinleafdependencyOverrides ++= Set("org.mozilla" % "rhino" % "1.7.6")
and the problem persists. – Education