Jump to content

JasperReports Groovy update to 3.x.x?


DanielL

Recommended Posts

Hello Community,

First of all my Setup.

GroovyVersion: 2.5.11
JasperReports: 6.15.0
alexnederlof-plugin (to compile .jrxml with maven)

 

To make it short:
We wanted to update our GroovyVersion to 3.0.7, because we got a Warning
After a bit of search I found out, that this warning was handled since Groovy 3.0.0.

We then got an Error on our alex-plugin, because it couldn't handle anything above Groovy 2.5.14.

Failed to execute goal com.alexnederlof:jasperreports-plugin:2.8:jasper (default) on project server: Error while compiling Jasper reports: java.lang.IncompatibleClassChangeError: class net.sf.jasperreports.compilers.JRGroovyCompiler$ClassCollector has interface org.codehaus.groovy.control.CompilationUnit$ClassgenCallback as super class -> [Help 1][/code]


So I decided to force it to use Version 2.5.14
 

<groupId>com.alexnederlof</groupId><artifactId>jasperreports-plugin</artifactId><version>2.8</version>  <dependencies>    <!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all -->     <dependency>       <groupId>org.codehaus.groovy</groupId>       <artifactId>groovy-all</artifactId>       <version>2.5.14</version>       <type>pom</type>     </dependency>  </dependencies>[/code]

Not a big deal, until a colleague of mine wrote some Testclasses.

In those he compiled the .jrxml-files with java itself an now the big problem comes in place:

Because we declare Groovy in our pom with verison 3.0.7, the JasperReport Dependency updates his initernalt Groovy dependency also to 3.0.7.

But becaus of, Groovy updated an abstract class to an Interface, we now get the same error and maven buildfailure in our java code, because of those tests. Now we are not able to force jasperreports to use a different GroovyVersion and we don't want to use our own ClassLoader to use both Version


Therefore my big question to Jaspersoft:

When can we get an updated Version of Jasperreports which is using a higher GroovyVersion (like 3.0.7)? I've encountered a lot of this problem on other sides and wonder why there isn't a fix to this, since it look like to be an issue for a while now


Looking forward to see a new update coming

Have a nice day :)

Link to comment
Share on other sites

  • 2 months later...
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

  • 1 month later...
  • 2 weeks later...

What I needed:

1. an updated jasperreports-6.16.0.jar, which worked with groovy 3

2. to swap in groovy 3 and swap out groovy 2 in my dependencies

Solution:

I downloaded the jasperreports-6.16.0 project.

Opened it in Eclipse.  (Must have Ant and Ivy installed)

Modify exactly TWO lines of source code.

First, in the ivy.xml file,

Replace:
        <dependency org="org.codehaus.groovy" name="groovy-all" rev="2.4.16"/>
With:
        <dependency org="org.codehaus.groovy" name="groovy" rev="3.0.8"/>

This will cause the JasperReports source code file below to now be a compile time error.

(In the ivy's lib dir, you may need to remove the old:  groovy-all-2.4.16.jar)

Second,


Find file:

    package net.sf.jasperreports.compilers;
    
    public class JRGroovyCompiler


Then find this:

    /**
     *
     */
    private static class ClassCollector extends CompilationUnit.ClassgenCallback
    {

At about line 157, in JasperReports 6.16.0.


Change 'extends' to 'implements'.

 

There is a third change I made so that when I build it, the JAR file will be named jasperreports-6.16.0-custom.jar.

In build.xml

    <target name="jar" depends="compile" description="Builds the JasperReports JAR file.">
        <mkdir dir="./dist"/>
        
Change the next line to have the word CUSTOM:
        <jar jarfile="./dist/jasperreports-${version}-custom.jar" manifest="build/classes/META-INF/MANIFEST.MF">

 

Now build the project.  Refresh so the 'dist' directory appears.  Look inside, find the new jarperreports-6.16.0-custom.jar file.  I then put this JAR ingo my primary project, and upgraded groovy from 2 to 3.  Problems solved.

Hope that helps someone.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...