Jump to content
  • Custom Function Extension cannot be used (Compile error)


    Michael Schmid
    CategoryBug report
    PriorityHigh
    ReproducibilityAlways
    ResolutionOpen
    SeverityMajor
    StatusAssigned
    Versionv6.17.0

    Hi there,

     

    I made a fresh install (i.e. gunzip) of Jaspersoft Studio 6.17.0 on Linux.

     

    When I create a blank A4 report and use a function in a Text Field from the built-in Function Extension, like UPPER("gugu"), the report compiles and runs fine.

     

    When I add a User Library to the project and this Library contains a custom Function Extension and I use one of the function from this Extension, like SysDate() to get the current timestamp as java.util.Date, then I get the following compile error:

     

    net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:

    1. net.sf.jasperreports.printserver.functions.JRPrintServerFunctions cannot be resolved to a type

    return getFunctionSupport(net.sf.jasperreports.printserver.functions.JRPrintServerFunctions.class).SysDate();

    <--------------------------------------------------------------->

    1 errors

    .

    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:229)

    at net.sf.jasperreports.eclipse.builder.JasperReportCompiler.compileReport(JasperReportCompiler.java:289)

    at net.sf.jasperreports.eclipse.builder.JasperReportCompiler.compileReport(JasperReportCompiler.java:141)

    at net.sf.jasperreports.eclipse.builder.JasperReportsBuilder.compileJRXML(JasperReportsBuilder.java:212)

    at com.jaspersoft.studio.editor.action.CompileAction.actionCompile(CompileAction.java:154)

    at com.jaspersoft.studio.editor.action.CompileAction$1.run(CompileAction.java:98)

    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

     

    Interestingly, in the Expression Editor the Function Extension and its function show up completely fine.

    I can only speculate, but it looks like the Function Extension is somehow not "visible" to the compiler.

     

    This test report is extremely simple:

     

    <?xml version="1.0" encoding="UTF-8"?>

    /DOCUMENT/REGION/ROWSET2/ROWSET2_ROW

    sysDate( )

    uPPER("gugu")

     

     

    Ok, so I the the property to keep the Java files. Here the Java file - that looks quite fine - for the report above:

     

    /*

    * Generated by JasperReports - 23.05.21, 14:33

    */

    import net.sf.jasperreports.engine.*;

    import net.sf.jasperreports.engine.fill.*;

     

    import java.util.*;

    import java.math.*;

    import java.text.*;

    import java.io.*;

    import java.net.*;

     

     

     

    /**

    *

    */

    public class Blank_A4_1621773188825_317900 extends JREvaluator

    {

     

     

    /**

    *

    */

     

     

    /**

    *

    */

    public void customizedInit(

    Map pm,

    Map fm,

    Map vm

    )

    {

    initParams(pm);

    initFields(fm);

    initVars(vm);

    }

     

     

    /**

    *

    */

    private void initParams(Map pm)

    {

    }

     

     

    /**

    *

    */

    private void initFields(Map fm)

    {

    }

     

     

    /**

    *

    */

    private void initVars(Map vm)

    {

    }

     

     

    /**

    *

    */

    public Object evaluate(int id) throws Throwable

    {

    Object value = null;

     

    switch (id)

    {

    case 8 :

    {

    value = SysDate( ); //$JR_EXPR_ID=8$

    break;

    }

    case 9 :

    {

    value = UPPER("gugu"); //$JR_EXPR_ID=9$

    break;

    }

    default :

    {

    }

    }

     

    return value;

    }

     

     

    /**

    *

    */

    public Object evaluateOld(int id) throws Throwable

    {

    Object value = null;

     

    switch (id)

    {

    case 8 :

    {

    value = SysDate( ); //$JR_EXPR_ID=8$

    break;

    }

    case 9 :

    {

    value = UPPER("gugu"); //$JR_EXPR_ID=9$

    break;

    }

    default :

    {

    }

    }

     

    return value;

    }

     

     

    /**

    *

    */

    public Object evaluateEstimated(int id) throws Throwable

    {

    Object value = null;

     

    switch (id)

    {

    case 8 :

    {

    value = SysDate( ); //$JR_EXPR_ID=8$

    break;

    }

    case 9 :

    {

    value = UPPER("gugu"); //$JR_EXPR_ID=9$

    break;

    }

    default :

    {

    }

    }

     

    return value;

    }

     

     

    /**

    *

    */

    public java.util.Date SysDate()

    {

    return getFunctionSupport(net.sf.jasperreports.printserver.functions.JRPrintServerFunctions.class).SysDate();

    }

     

     

    /**

    *

    */

    public java.lang.String UPPER(java.lang.String arg0)

    {

    return getFunctionSupport(net.sf.jasperreports.functions.standard.TextFunctions.class).UPPER(arg0);

    }

     

     

    }

     

    The very same Function Extension works fine with JSS 6.16.0.

    If it's useful, I could provide the jar file with the custom Function Extension.

     

    Regards,

    Michael

     



    User Feedback

    Recommended Comments

    Hello Michael,

     

    I have the same problem I think. One question (only for testing purpose): If you change the report language to groovy compile correctly?

     

    Thank you.

    Link to comment
    Share on other sites

    Changed Priority from Normal to High


    Hi fddam,quite possible that those issue have the same root cause...Now, when I switch my test report Language "java" to "groovy" the report compile into a jasper file. Good so far.But when I execute/preview the report the I get an exception:net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: SysTimestamp( ) at com.jaspersoft.studio.editor.preview.view.control.ReportController.fillReport(ReportController.java:551) at com.jaspersoft.studio.editor.preview.view.control.ReportController.access$18(ReportController.java:526) at com.jaspersoft.studio.editor.preview.view.control.ReportController$1.run(ReportController.java:444) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: SysTimestamp( ) at net.sf.jasperreports.engine.fill.JREvaluator.handleEvaluationException(JREvaluator.java:294) at net.sf.jasperreports.compilers.GroovyEvaluator.handleEvaluationException(GroovyEvaluator.java:98) at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:328) at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:673) at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:641) at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:1173) at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:555) at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:540) at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:383) at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:548) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2613) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:836) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:275) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:135) at java.base/java.lang.Thread.run(Unknown Source)Caused by: java.lang.NoClassDefFoundError: Lnet/sf/jasperreports/repo/RepositoryUtil; at java.base/java.lang.Class.getDeclaredFields0(Native Method) at java.base/java.lang.Class.privateGetDeclaredFields(Unknown Source) at java.base/java.lang.Class.getDeclaredFields(Unknown Source) at org.codehaus.groovy.reflection.CachedClass$1.lambda$initValue$2(CachedClass.java:59) at java.base/java.security.AccessController.doPrivileged(Native Method) at org.codehaus.groovy.reflection.CachedClass$1.initValue(CachedClass.java:62) at org.codehaus.groovy.reflection.CachedClass$1.initValue(CachedClass.java:54) at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:50) at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:37) at org.codehaus.groovy.reflection.CachedClass.getFields(CachedClass.java:255) at groovy.lang.MetaClassImpl.addFields(MetaClassImpl.java:2546) at groovy.lang.MetaClassImpl.inheritFields(MetaClassImpl.java:2541) at groovy.lang.MetaClassImpl.setupProperties(MetaClassImpl.java:2427) at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3464) at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3437) at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:273) at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:315) at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:258) at org.codehaus.groovy.runtime.DefaultGroovyMethods.getMetaClass(DefaultGroovyMethods.java:17709) at net.sf.jasperreports.compilers.GroovyEvaluator.functionCall(GroovyEvaluator.java:117) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:193) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:61) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:66) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:194) at Blank_A445FT_1622216531716_247760.methodMissing(calculator_Blank_A445FT_1622216531716_247760:22) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107) at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:953) at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1347) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1270) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1120) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:61) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:176) at Blank_A445FT_1622216531716_247760.evaluate(calculator_Blank_A445FT_1622216531716_247760:82) at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:313) ... 14 moreCaused by: java.lang.ClassNotFoundException: net.sf.jasperreports.repo.RepositoryUtil at java.base/java.net.URLClassLoader.findClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) at java.base/java.net.FactoryURLClassLoader.loadClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) ... 60 moreThe used function of my Function Extension is "SysTimestamp()".The Function Extension class has a init method like this:@Override public void init(FunctionContext context) { super.init(context); functionContext = getContext(); JasperReportsContext jasperReportsContext = getJasperReportsContext(); propertiesUtil = JRPropertiesUtil.getInstance(jasperReportsContext); repositoryUtil = RepositoryUtil.getInstance(jasperReportsContext); fontUtil = FontUtil.getInstance(jasperReportsContext); ... }Here obviously the net.sf.jasperreports.repo.RepositoryUtil class cannot be found!?! Why???When I execute the generated jasper file outside of JSS, i.e. with pure JasperReports Library the report and my function execute fine.So, somehow the class resolution in JSS is flawed...I also tried to switch to Language "javascript": Compile works and execution/preview in JSS.I hope that gets fixed soon, otherwise JSS 6.17 is useless for us...Regards,Michael
    Link to comment
    Share on other sites

    Changed Status from New to Confirmed


    Hi, I can confirm I was able to reproduce your issue. I will have to debug further to understand if it's somehow related to JR as well, because everything seems to be working fine if you are working with sources in your project. Meaning that if you have your functions library code inside the project and build normally, also the preview seems to be working fine (see screenshot setup).The issue comes in place when you are working with jar, as you guys reported. Moreover I tried to verify the issue in the normal develop environment + launching runtime and it seemed to work fine. I have to "remote debug" the standalone version in order to understand what's going on.If you can, please try to work with the custom functions Java code inside the project to confirm that is working on your side too with this method. Thanks!Regards,Massimo.
    Link to comment
    Share on other sites

    Hi Massimo,

     

    I created a Function Extension in JSS.

    The creation was quite easy with the wizard.

     

    I have now a Java package com.test.functions in my project.

    There a two java files there.

    First, the category file "Test.java":

     

    package com.test.functions;

     

    import net.sf.jasperreports.functions.annotations.FunctionCategory;

     

    @FunctionCategory()

    public class Test {

    }

     

    And then the more interesting file "TestFunctionLibrary.java":

     

    package com.test.functions;

     

    import net.sf.jasperreports.functions.annotations.Function;

    import net.sf.jasperreports.functions.annotations.FunctionCategories;

    import net.sf.jasperreports.functions.annotations.FunctionParameter;

    import net.sf.jasperreports.functions.annotations.FunctionParameters;

     

    @FunctionCategories({ com.test.functions.Test.class })

    public class TestFunctionLibrary {

     

    @Function("HELLO_WORLD_MSG")

    public static String HELLO_WORLD_MSG() {

    return "Hello World!";

    }

    }

     

    The wizard additionally created a file "jasperreports_messages.properties" in this package.

    And in the root of my build path a file "jasperreports_extension.properties" was created with this content:

     

    net.sf.jasperreports.extension.registry.factory.functions=net.sf.jasperreports.functions.FunctionsRegistryFactory

    net.sf.jasperreports.extension.functions.testfunctionlibrary=com.test.functions.TestFunctionLibrary

     

    Now, I create an empty report that uses the HELLO_WORLD_MSG function. (It's available in the Expression Wizard.)

     

    When the report language is set to "java" compilation fails with:

     

    net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:

    1. Only a type can be imported. com.test.functions.TestFunctionLibrary.HELLO_WORLD_MSG resolves to a package

    import static com.test.functions.TestFunctionLibrary.HELLO_WORLD_MSG;

    <---------------------------------------------------->

    2. The method HELLO_WORLD_MSG() is undefined for the type Blank_A445FT_1622656423500_53801

    value = HELLO_WORLD_MSG( ); //$JR_EXPR_ID=9$

    <------------->

    3. The method HELLO_WORLD_MSG() is undefined for the type Blank_A445FT_1622656423500_53801

    value = HELLO_WORLD_MSG( ); //$JR_EXPR_ID=9$

    <------------->

    4. The method HELLO_WORLD_MSG() is undefined for the type Blank_A445FT_1622656423500_53801

    value = HELLO_WORLD_MSG( ); //$JR_EXPR_ID=9$

    <------------->

    4 errors

    .

    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:229)

    at net.sf.jasperreports.eclipse.builder.JasperReportCompiler.compileReport(JasperReportCompiler.java:289)

    at net.sf.jasperreports.eclipse.builder.JasperReportCompiler.compileReport(JasperReportCompiler.java:141)

    at net.sf.jasperreports.eclipse.builder.JasperReportsBuilder.compileJRXML(JasperReportsBuilder.java:212)

    at com.jaspersoft.studio.editor.action.CompileAction.actionCompile(CompileAction.java:154)

    at com.jaspersoft.studio.editor.action.CompileAction$1.run(CompileAction.java:98)

    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

     

    The java source is:

     

    /*

    * Generated by JasperReports - 02.06.21, 19:56

    */

    import static com.test.functions.TestFunctionLibrary.HELLO_WORLD_MSG;

    import net.sf.jasperreports.engine.*;

    import net.sf.jasperreports.engine.fill.*;

     

    import java.util.*;

    import java.math.*;

    import java.text.*;

    import java.io.*;

    import java.net.*;

     

     

     

    /**

    *

    */

    public class Blank_A445FT_1622656576990_621694 extends JREvaluator

    {

     

     

    /**

    *

    */

     

     

    /**

    *

    */

    public void customizedInit(

    Map pm,

    Map fm,

    Map vm

    )

    {

    initParams(pm);

    initFields(fm);

    initVars(vm);

    }

     

     

    /**

    *

    */

    private void initParams(Map pm)

    {

    }

     

     

    /**

    *

    */

    private void initFields(Map fm)

    {

    }

     

     

    /**

    *

    */

    private void initVars(Map vm)

    {

    }

     

     

    /**

    *

    */

    public Object evaluate(int id) throws Throwable

    {

    Object value = null;

     

    switch (id)

    {

    case 8 :

    {

    value = UPPER("Gugu"); //$JR_EXPR_ID=8$

    break;

    }

    case 9 :

    {

    value = HELLO_WORLD_MSG( ); //$JR_EXPR_ID=9$

    break;

    }

    default :

    {

    }

    }

     

    return value;

    }

     

     

    /**

    *

    */

    public Object evaluateOld(int id) throws Throwable

    {

    Object value = null;

     

    switch (id)

    {

    case 8 :

    {

    value = UPPER("Gugu"); //$JR_EXPR_ID=8$

    break;

    }

    case 9 :

    {

    value = HELLO_WORLD_MSG( ); //$JR_EXPR_ID=9$

    break;

    }

    default :

    {

    }

    }

     

    return value;

    }

     

     

    /**

    *

    */

    public Object evaluateEstimated(int id) throws Throwable

    {

    Object value = null;

     

    switch (id)

    {

    case 8 :

    {

    value = UPPER("Gugu"); //$JR_EXPR_ID=8$

    break;

    }

    case 9 :

    {

    value = HELLO_WORLD_MSG( ); //$JR_EXPR_ID=9$

    break;

    }

    default :

    {

    }

    }

     

    return value;

    }

     

     

    /**

    *

    */

    public java.lang.String UPPER(java.lang.String arg0)

    {

    return getFunctionSupport(net.sf.jasperreports.functions.standard.TextFunctions.class).UPPER(arg0);

    }

     

     

    }

     

     

    When I set the report language to "groovy" compilation and preview works!

    The groovy file's content:

     

    /*

    * Generated by JasperReports - 02.06.21, 19:57

    */

    import net.sf.jasperreports.engine.*;

    import net.sf.jasperreports.engine.fill.*;

     

    import java.util.*;

    import java.math.*;

    import java.text.*;

    import java.io.*;

    import java.net.*;

     

     

     

    /**

    *

    */

    class Blank_A445FT_1622656673002_844779 extends net.sf.jasperreports.compilers.GroovyEvaluator

    {

     

    def methodMissing(String name, args) {

    return functionCall(name, args);

    }

     

    /**

    *

    */

     

     

    /**

    *

    */

    void customizedInit(

    Map pm,

    Map fm,

    Map vm

    )

    {

    initParams(pm);

    initFields(fm);

    initVars(vm);

    }

     

     

    /**

    *

    */

    void initParams(Map pm)

    {

    }

     

     

    /**

    *

    */

    void initFields(Map fm)

    {

    }

     

     

    /**

    *

    */

    void initVars(Map vm)

    {

    }

     

     

    /**

    *

    */

    Object evaluate(int id)

    {

    Object value = null;

     

    if (id == 8)

    {

    value = (UPPER("Gugu"));

    }

    else if (id == 9)

    {

    value = (HELLO_WORLD_MSG( ));

    }

     

    return value;

    }

     

     

    /**

    *

    */

    Object evaluateOld(int id)

    {

    Object value = null;

     

    if (id == 8)

    {

    value = (UPPER("Gugu"));

    }

    else if (id == 9)

    {

    value = (HELLO_WORLD_MSG( ));

    }

     

    return value;

    }

     

     

    /**

    *

    */

    Object evaluateEstimated(int id)

    {

    Object value = null;

     

    if (id == 8)

    {

    value = (UPPER("Gugu"));

    }

    else if (id == 9)

    {

    value = (HELLO_WORLD_MSG( ));

    }

     

    return value;

    }

     

     

    }

     

    Compilation and preview also work when I set the language to "javascript".

     

    Hope this helps with analyzing this issue.

     

    Best regards,

    Michael

     

     

    Link to comment
    Share on other sites

    Hi thanks for the feedback.

    I will try to debug further also setting up a Linux dev environment.

    I can confirm that in Mac OS X BigSur it seems to work fine using the Java code inside the project (creating the functions library like you did from wizard). The only operation needed is of course the manual build of the related classes (using CMD/CTRL + B).

    On the other side I re-tried also the Javascript and Groovy language with the usage of the external jar library. And they work fine. Only Java language seems not ok.

     

    Regards,

    Massimo.

    Link to comment
    Share on other sites

    Hi, I Got same problem in Windows 10

    But in my case sources is in the project and 6.17 will trow this error

    when trying to preview report same project was working fine in 6.16 (Im not sure how to switch Java to Groovy so I didn't try that)

     

    Start Report Execution

    Compiling report......net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:

    1. Only a type can be imported. mypackage.customFunctions.myclass.MYFUNCTION resolves to a package

    import static mypackage.customFunctions.myclass.MYFUNCTION;

    <------------------------------------------------------->

     

     

     

    Link to comment
    Share on other sites

    Hi Massimo,

     

    I copied the file net.sf.jasperreports.patch_6.17.0.js-patch01.jar to my plugins directory.

    In my case it's: /opt/jaspersoft/TIB_js-studiocomm_6.17.0/plugins

     

    Then I started JSS with: /opt/jaspersoft/TIB_js-studiocomm_6.17.0/runjss.sh -clean

     

    When I first tried my test reports the errors showed up :-(

     

    Then I quit JSS and started it again with: /opt/jaspersoft/TIB_js-studiocomm_6.17.0/runjss.sh

     

    And now the compilation worked with language java! :-)

     

    So, the patch helped.

     

    But, unfortunately I think I found the next problem:

    I'm using my own ChartCustomizers and they are part of a jar that is part of a user library of my project. (The same jar that includes my own Function Extension.)

    Now, I can compile the report, but when I execute/preview I get:

     

    net.sf.jasperreports.engine.JRRuntimeException: Could not create chart customizer instance.

    at net.sf.jasperreports.engine.fill.JRFillChart.createAndInitCustomizer(JRFillChart.java:354)

    at net.sf.jasperreports.engine.fill.JRFillChart.(JRFillChart.java:320)

    at net.sf.jasperreports.engine.fill.JRFillObjectFactory.visitChart(JRFillObjectFactory.java:704)

    at net.sf.jasperreports.engine.base.JRBaseChart.visit(JRBaseChart.java:586)

    at net.sf.jasperreports.engine.JRAbstractObjectFactory.getVisitResult(JRAbstractObjectFactory.java:88)

    at net.sf.jasperreports.engine.fill.JRFillElementGroup.(JRFillElementGroup.java:82)

    at net.sf.jasperreports.engine.fill.JRFillElementContainer.(JRFillElementContainer.java:95)

    at net.sf.jasperreports.engine.fill.JRFillFrame$JRFillFrameElements.(JRFillFrame.java:505)

    at net.sf.jasperreports.engine.fill.JRFillFrame.(JRFillFrame.java:99)

    at net.sf.jasperreports.engine.fill.JRFillObjectFactory.visitFrame(JRFillObjectFactory.java:1475)

    at net.sf.jasperreports.engine.base.JRBaseFrame.visit(JRBaseFrame.java:92)

    at net.sf.jasperreports.engine.JRAbstractObjectFactory.getVisitResult(JRAbstractObjectFactory.java:88)

    at net.sf.jasperreports.engine.fill.JRFillElementGroup.(JRFillElementGroup.java:82)

    at net.sf.jasperreports.engine.fill.JRFillElementContainer.(JRFillElementContainer.java:95)

    at net.sf.jasperreports.engine.fill.JRFillBand.(JRFillBand.java:129)

    at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getBand(JRFillObjectFactory.java:524)

    at net.sf.jasperreports.engine.fill.JRFillSection.(JRFillSection.java:74)

    at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getSection(JRFillObjectFactory.java:500)

    at net.sf.jasperreports.engine.fill.JRBaseFiller.(JRBaseFiller.java:285)

    at net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:82)

    at net.sf.jasperreports.engine.fill.JRFiller.createBandReportFiller(JRFiller.java:251)

    at net.sf.jasperreports.engine.fill.JRFiller.createReportFiller(JRFiller.java:272)

    at net.sf.jasperreports.engine.fill.BaseFillHandle.(BaseFillHandle.java:86)

    at net.sf.jasperreports.engine.fill.AsynchronousFillHandle.(AsynchronousFillHandle.java:120)

    at net.sf.jasperreports.engine.fill.AsynchronousFillHandle.createHandle(AsynchronousFillHandle.java:244)

    at com.jaspersoft.studio.editor.preview.view.control.ReportController$1.run(ReportController.java:441)

    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

    Caused by: java.lang.ClassNotFoundException: net.sf.jasperreports.printserver.customizers.SeriesColorCustomizer cannot be found by net.sf.jasperreports_6.17.0.final

    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:519)

    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:171)

    at java.base/java.lang.ClassLoader.loadClass(Unknown Source)

    at java.base/java.lang.Class.forName0(Native Method)

    at java.base/java.lang.Class.forName(Unknown Source)

    at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:208)

    at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:148)

    at net.sf.jasperreports.engine.fill.JRFillChart.createAndInitCustomizer(JRFillChart.java:348)

    ... 26 more

     

    When I execute the jasper file that JSS compiled in "pure" JapserReports Library 6.17 environment it works...

    Should I create a new issue for this problem?

     

    Best regards,

    Michael

     

    Link to comment
    Share on other sites

    Changed Resolution from Open to Fixed

    Changed Status from Confirmed to Resolved


    Hi, you should be able to make it work using the following patch below as also for #13656.You can remove the previous one and use this only.Regards,Massimo.
    Link to comment
    Share on other sites

    Changed Resolution from Fixed to Open

    Changed Status from Resolved to New


    Hi Massimo,unfortunately I experienced the same problem again with the current version 19.1. Jaspersoft Studio as plugin in Eclipse j2ee 2022-03 on windows.I am asking myself, why your patch seems to not make it into the main dev branch?Can you help?Thanks in advance, Thomasedit: i´m sorry, my information above was not 100% correct; first, the patch removes the general "cannot find symbol" error when executing the preview in Jaspersoft Studio. And that works in 19.1 as well.But the problem is still there, when executing the report out of a java class (execution without a function library call in the report works fine, preview as well).Switching the report to groovy interpreter helps in 6.17, but not in 19.1 due an class compatibility error. Anyway, switching to groovy is not an option in my project generally.Please help!
    Link to comment
    Share on other sites

    Changed Status from New to Feedback Requested


    Hi Thomas, the fixes should be already in 6.19.1. Not sure why you still have the issue.I assume there is still something strange that is not properly triggering the "classpath reload" that would allow to see the modifications your are performing.It would help if you can rewrite down the full (minimal) list of steps that are causing the issue. Even starting from the JSS opening. In order to face such similar (strange) situations, I added in the latest release a menu item that "forces" the reload of the project classpath. This should help with your issue. I know it's just a workaround, but it might work until we are able to debug and further solve the issue. You can find it, right clicking on: "JASPERREPORTS_PROJECT > JasperReports > Reload Classpath" (see screenshot).Let me know if this somehow helps.Regards,Massimo.
    Link to comment
    Share on other sites

    Hi Massimo,

     

    I attached the full description with prefferences as PDF.

     

    The quick steps (in Eclipse 2022-03, JSS 6.19.1):

    1. create new Jasperproject TEST

    2. create sample functions library, change report interpreter to java

    3. create simple java test class compile/fill/export

     

    => cannot be executed, error:

     

    Exception in thread "main" net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:

    E:\_workspaces\_workspace_jss_202203\TEST\SampleFunctions_1655364589161_803839.java:77: error: cannot find symbol

    value = HELLO_WORLD_MSG( ); //$JR_EXPR_ID=8$

    ^

    symbol: method HELLO_WORLD_MSG()

    location: class SampleFunctions_1655364589161_803839

    ...

     

    6 errors

    .

    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:229)

    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:358)

    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:291)

    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:576)

    at net.thomaszimmer.jasperreports.TestSamplesReport.main(TestSamplesReport.java:16)

     

    Let me know if you need anything else.

     

    Thanks a lot in advance!

     

    Thomas

     

    Link to comment
    Share on other sites

    Changed Status from Assigned to Feedback Requested


    Hi Thomas, apparently I was able to reproduce your behavior and error on my Mac environment as well. I tried of course your same setup with the "Java and Web Developers" flavor of Eclipse 4.23.That said I re-created a similar scenario also into a brand new workspace with a JSS 6.19.1 standalone installation.At first I got an exception mentioning the "org.eclipse.jdt.debug.ui" plugin. I tracked back the issue to the fact we currently ships a JRE bundle.So after modifying the Jaspersoft Studio.ini file pointing to a proper JDK I was able to successfully run the example you posted.Example:====================================-vmC:/dev/jdk/jdk-11.0.15+10/bin====================================instead of:====================================-vmfeatures/jre.win32.win32.x86_64.feature_11.0.8/adoptopenjdk_jre/bin====================================Indeed the Eclipse plug-in scenario requires a further investigation considering there is something wrong. Groovy report run seems to not work as it should.About the JRE vs JDK thing there is already something open about it (see here: https://community.jaspersoft.com/jaspersoft-studio/issues/13846). I will try to trigger again internally the discussion about moving to shipping a JDK instead of the simpler JRE in order to cover more developer-oriented scenarios.Best regards,Massimo.P.S: let me know if you can confirm that it works fine also for you into a JSS 6.19.1 standalone.P.P.S: I will keep the bug open in order to have in the TODO list the investigation about the Eclipse plugin "broken" scenario.
    Link to comment
    Share on other sites

    Hi Massimo,

     

    sorry for my late reply...

     

    I tried it as you described (on Windows 11):

     

    java version "11.0.2" 2019-01-15 LTS

    Java SE Runtime Environment 18.9 (build 11.0.2+9-LTS)

    Java HotSpot 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)

     

    -vm D:/Java/jdk-11.0.2/bin in Jaspersoft Studio.ini, fresh workspace

     

    Created SampleFunctions, changed Report interpreter to java.

     

    Created Java Class:

    ...

    HashMap params = new HashMap();

     

    JasperReport jasperReport = JasperCompileManager.compileReport("...SampleFunctionsReport.jrxml");

    JasperPrint jprint = JasperFillManager.fillReport(jasperReport, params, new JREmptyDataSource(1));

     

    JasperExportManager.exportReportToPdfFile(jprint, "...SampleFunctionsReport.pdf");

    ...

     

     

    Unfortunately with the same result:

    ...

    symbol: method HELLO_WORLD_MSG()

    location: class SampleFunctions_1656696244374_608167

    E:\_workspaces\_workspace_jss_6191-2\MyReports\SampleFunctions_1656696244374_608167.java:138: error: cannot find symbol

    value = REPEAT_MSG("A message that will be probably repeated",5,true); //$JR_EXPR_ID=9$

    ^

    symbol: method REPEAT_MSG(String,int,boolean)

    location: class SampleFunctions_1656696244374_608167

    6 errors

    .

    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:229)

    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:358)

    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:291)

    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:576)

    at net.thomaszimmer.jasperreports.TestSamples.main(TestSamples.java:20)

     

    Not really a satisfied situation, as I experience these and similar problems already since about version 6.10...

     

    I checked it again with the professional version 8.0.0

    > same result as with 6.19.1

     

    I tried several other jdk versions:

     

    openjdk version "11.0.3" 2019-04-16 LTS

    OpenJDK Runtime Environment Corretto-11.0.3.7.1 (build 11.0.3+7-LTS)

    OpenJDK 64-Bit Server VM Corretto-11.0.3.7.1 (build 11.0.3+7-LTS, mixed mode)

     

    > same result

     

    openjdk version "18.0.1.1" 2022-04-22

    OpenJDK Runtime Environment (build 18.0.1.1+2-6)

    OpenJDK 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)

     

    JDK compliance set to 11:

    > same result with java, additionally not working with groovy due to class version incompatability (preview as well):

    Exception in thread "main" BUG! exception in phase 'semantic analysis' in source unit 'calculator_SampleFunctions_1656742383742_969305' Unsupported class file major version 62

    at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:905)

    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:671)

    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:635)

    at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:112)

    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:226)

    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:358)

    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:291)

    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:576)

    at net.thomaszimmer.jasperreports.TestSamples.main(TestSamples.java:20)

    Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 62

    at groovyjarjarasm.asm.ClassReader.(ClassReader.java:189)

    at groovyjarjarasm.asm.ClassReader.(ClassReader.java:170)

    at groovyjarjarasm.asm.ClassReader.(ClassReader.java:156)

    at groovyjarjarasm.asm.ClassReader.(ClassReader.java:277)

    ...

    > setting JDK compliance to 1.8 doesn't change anything

     

    At last, I started Studio with the first mentioned JDK 11.0.2, but set execution environment and compliance to an old 1.8:

     

    java version "1.8.0_202"

    Java SE Runtime Environment (build 1.8.0_202-b08)

    Java HotSpot 64-Bit Server VM (build 25.202-b08, mixed mode)

     

    > again, the same result, groovy works, java doesn't

    > java 1.8 wouldn't have been an option anyway

     

    Summary

    > Not able to get it working on windows with fresh standalone client, several jdks nad current JSS versions (CE/PRO)

    > Works with groovy as long the java version is compatible with the groovy lib

    > I didn't check external applications, like jasperserver yet, but will soon.

     

    Thanks in advance,

    Thomas

     

     

     

     

     

    Link to comment
    Share on other sites

    Changed Status from Feedback Requested to Assigned


    Should I change the status of the issue somehow after giving feedback?Sorry I don´t know the status model exactly, is that documented somewhere?THX in advance,Thomas
    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...