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
Recommended Comments
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 accountSign in
Already have an account? Sign in here.
Sign In Now