alexnederlof / Jasper-report-maven-plugin

A fast jasper report maven plugin
Apache License 2.0
134 stars 84 forks source link

Cannot compile on Java 8 #12

Closed alexnederlof closed 8 years ago

alexnederlof commented 10 years ago

Cannot compile on Java 8 because of ClassFormatException

[ERROR] [ERROR] Could not compile NoPageBreakReport.jrxml because Errors were encountered when compiling report expressions class file:
1. The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
                value = "  " + String.valueOf(((java.lang.Integer)variable_ShipCountryNumber.getValue())) + ". " + String.valueOf(((java.lang.String)field_ShipCountry.getValue())); //$JR_EXPR_ID=19$
                                                                                                                   <-------------------------------------------------------------->
1 errors

Could not compile CsvDataSourceReport.jrxml because Errors were encountered when compiling report expressions class file:
1. The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
                value = "  " + String.valueOf(((java.lang.Integer)variable_CityNumber.getValue())) + ". " + String.valueOf(((java.lang.String)field_city.getValue())); //$JR_EXPR_ID=12$
                                                                                                            <------------------------------------------------------->
1 errors

net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
                value = "  " + String.valueOf(((java.lang.Integer)variable_ShipCountryNumber.getValue())) + ". " + String.valueOf(((java.lang.String)field_ShipCountry.getValue())); //$JR_EXPR_ID=19$
                                                                                                                   <-------------------------------------------------------------->
bjornarl commented 10 years ago

This workaround that involves changing the JDT version seems to solve this problem: http://community.jaspersoft.com/jasperreports-server/issues/3498 (comments 7 & 8).

guihatano commented 9 years ago

This workaround didn't work for me

mkielar commented 9 years ago

I worked this around by adding this dependency to the plugin execution:

<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>6.1.0</version>
</dependency>

and thus replacing the 5.2.0 version specified in plugin's pom.xml.

So now my plugin configuration looks like this:

<plugin>

    <groupId>com.alexnederlof</groupId>
    <artifactId>jasperreports-plugin</artifactId>
    <version>1.6</version>

    <executions>
        <execution>
            <phase>process-sources</phase>
            <goals>
                <goal>jasper</goal>
            </goals>
        </execution>
    </executions>

    <configuration>
        <compiler>net.sf.jasperreports.engine.design.JRJdtCompiler</compiler>
        <sourceDirectory>src/main/resources/reports</sourceDirectory>
        <outputDirectory>${project.build.directory}/classes/reports</outputDirectory>
        <outputFileExt>.jasper</outputFileExt>
        <xmlValidation>true</xmlValidation>
        <verbose>true</verbose>
        <numberOfThreads>2</numberOfThreads>
    </configuration>

    <dependencies>

        <!-- 
          - Workaround for Java 8 incompatibility bug:
          - https://github.com/alexnederlof/Jasper-report-maven-plugin/issues/12
        -->
        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>6.1.0</version>
        </dependency>

        <!-- other project dependencies ->

    </dependencies>

</plugin>

I guess the solution would be then to upgrade net.sf.jasperreports:jasperreports dependency to something from the 6.x.x tree.

driv commented 8 years ago

Works for me too with the workaround by mkielar

arthurnl commented 8 years ago

2.0 works for me to in java-8

ardeshirayati commented 5 years ago

Hi I solved that by this config : jasper

<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>5.5.1</version>
    <exclusions>
        <exclusion>
            <groupId>eclipse</groupId>
            <artifactId>jdtcore</artifactId>
        </exclusion>
    </exclusions>
</dependency>