elbyron Posted December 22, 2016 Share Posted December 22, 2016 I have two reports that share a set of custom functions. The reports and functions were created in Jaspersoft Studio 5.5.0 Professional, and uploaded to JasperReports Server 6.2.1 Professional. Originally there was just one report that used the custom functions. In Studio, I used the right-click-->Export on the custom package to create a .jar file, which I then uploaded as a file resource on the server. I then added that resource under the report's "Controls & Resources" section.Everything worked great, until several months later, I now have a second report that needs the functions, along with a new function added in the same java file. The report works fine in Studio, successfully running the custom function (called GET_LIMIT). Again I generated the .jar file (overwrote the old one unfortunately so I can't compare them) and edited the resource to upload the new version of the .jar. But when I went to run the second report, it complained that it couldn't find the custom function. Even worse, the first report now also complains about not finding the custom function. If it were merely a caching issue, I would have expected the first report to continue working. I also tried deleting the resource from the report, then adding a new resource choosing "Upload a Local File" option this time instead of referencing the JAR resource on the server. But both reports still fail to see the custom functions. Please note that I do not have access to the machine hosting the JasperReports Server. Therefore I cannot try dumping the jar files into any particular directory - but I shouldn't need to, since using the file resource method should (and used to) work. I also cannot reboot the server, though if it were truly neccessary, I could ask the client who owns the server to do it. The error message produced by the report is unhelpful, basically the same as you'd expect to see if the jar wasn't there at all: net.sf.jasperreports.engine.JRRuntimeException: Function GET_LIMIT not found. at net.sf.jasperreports.compilers.GroovyEvaluator.functionCall(GroovyEvaluator.java:76)at ... I tried undoing all my changes and rebuilding the jar again, in hopes that I could at least get the first report working again, but it's still failing to find the custom function now. I suspect that I'm doing something wrong with generating the jar, but I can't figure out what. My Project Explorer in Studio looks like this:I build the jar by right-clicking on the customFunctions package and choosing Export, and selecting "JAR File". I accept the default settings for the export:I've also tried building the jar with just the CustomFunctions.java file by itself. I did add function names and descriptions in both the jasperreports_messages.properties files, but I don't think that matters for the JasperReports Server. The reports both work fine when running in Studio, so I don't think there's any issue with my function or how I use it, but just in case, the custom function that it's failing on is defined in CustomFunctions.java like this:@Function("GET_LIMIT")@FunctionParameters({ @FunctionParameter("count"), @FunctionParameter("type")})public static Integer GET_LIMIT(java.math.BigDecimal count, String type) { and it's called from the report like this:<![CDATA[GET_LIMIT($F{count}, "alpha")]]> Can anyone tell me what I'm missing, or at least suggest some other things to try? Link to comment Share on other sites More sharing options...
elbyron Posted December 23, 2016 Author Share Posted December 23, 2016 So I managed to find a backup copy of the old jar file, and compared its contents with my new one. I discovered that the two properties files in the parent folder of the package were not being included: Once I checked off those two files, everything worked fine!It's really too bad that the various wiki pages and instructions I've read all just say "Export the package to JAR" and none of them actually include steps on how to do that correctly! Even though I answered my own question, hopefully someone else having this same problem finds this and is helped by it! Link to comment Share on other sites More sharing options...
Recommended Posts
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