How to publish custom functions from Jasper Studio to the Jasper Server

0

Hello, I was able to create custom functions in Jasper Studio, and they work on my computer when I test the reports.  But when I published the report to the Jasper server I get an error like this

 

Errors were encountered when compiling report expressions class file: 1. The method CURRENT_MONTH_BEGINNING() is undefined for the type TotalTaskHrsOnly...

 

What is the proper way to include the custom functions that I made, so that the report works when making a request to the Jasper server?  If anyone can provide me with a tutorial on how to do this, that would be great. Thank you

ericb_1's picture
Joined: Jun 22 2015 - 12:05pm
Last seen: 1 year 5 months ago

The reason why my custom functions were not working was because I did not export the 2 properties files that are generated when creating new library functions.

  • jasperreports_messages.properties
  • jasperreports_extension.properties

The steps that I took to add my new functions to the Jasper server are here:

  • Create the jar file. Right click on your Jasper project in Jasper Studio, and select Export

  • Click on the src folder and check the jasperreports_extension.properties file

  • Click on the package folder and select everything inclucing the jasperreports_messages.properties file

  • Pick the destination folder to export the new .jar file to and click finish. 

Once the jar file is exported, you will need to log into the Jasper Server, and add the jar file as a resource to the report

  • Log into Jasper Server
  • Select your report, and click Edit
  • Click Controls & Resources
  • Click Add Resource

  • Select Upload a Local File and locate the jar file that you exported from earlier

  • Edit your resource Name and Resource ID, then click Next on the bottom of your browser.
  • Note - The resource name and id are defaulted to be the same

  • Make sure your jar file has been added to the Resources in the Controls & Resources page, then click Submit
  • Note - The devhours.jar in the image below is the Name and Resource ID that I gave it. Your resource may be called something else 

 

Hopefully this helps others who may have had problems adding custom functions to the Jasper Server.

ericb_1 - 1 year 5 months ago

2 Answers:

1

Take a look at this question. You need to export your custom function as jar file and uploading the jar file to JasperReports Server.

https://community.jaspersoft.com/questions/1038286/reports-jasper-server...

hozawa's picture
49243
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 months 1 week ago
0

Using scriplets works well for me.

Take a look at: https://community.jaspersoft.com/blog/all-you-want-know-about-scriptlets

Mariano

mlopez_1's picture
909
Joined: Oct 21 2013 - 8:08am
Last seen: 1 week 11 hours ago
Feedback