7

I wrote some Java class, created jar file. I want to add it to JasperReports Server. When I determine the path to my jar file, using Tools -> Preferences -> Classpath menu in my iReport, it works correctly. But it doesn't work, when I take access to JR Server from another host.

What I must to do, to make this jar file available on this JR Server, from anywhere?

2
  • 3
    You should copy your jar file to the WEB-INF\lib folder (for jasperserver application). And don't forget to restart the application server (may be Tomcat in your case)
    – Alex K
    Oct 9, 2012 at 12:30
  • Thank you. I`ll try to do it right now
    – yura
    Oct 9, 2012 at 12:35

2 Answers 2

2

Option 1 - If you want to use your Jar in a several reports.

You should "Add Jar" (as it called in iReport repository manager) to some folder in the Jasper Server folder tree. Then "Add reference" to this resource in Resources section of you specific report.

Option2 - You need a jar in a specifc report.

Use "Add Jar" option in a resources section of specific report.

Worked perfectly on JasperServer 4.7

1

Add the jar as a resource of the report (if it's one time use) or add it to some path in Jasper Report Server and add a reference to it as Alex suggested.

I'd suggest you to create some folders in Jasper Server (via web interface or iReport) and put all commonly used filed there (be sure to manage correctly the permissions ROLE_USER should have access to the file but you can remove it from the folder so it's not listed).

Then use references on the reports that need those. For example, I use it for the report logo and some helper Java classes.

Edit as @NormTatlock asked more details on how to do it:

  1. Create your Java package my.sample.package for example:

    public class MyClass extends JRDefaultScriptlet ...

  2. Compile it and upload the jar as a resource using its full name (e.g. my.sample.package.jar) or upload it to another folder and create a reference to it in the resources folder of the report.

  3. Edit the report and set the Scriptlet Class property to:

    my.sample.package.MyClass

  4. Or set the property in the XML tag jasperreports (the root tag) as:

    scriptletClass="my.sample.package.MyClass"

  5. Use the scriptlet in your report like this:

    $P{REPORT_SCRIPTLET}.myMethod(myParam1, myParam2)

Mind the return type of the methods and so on.

Hope it helps. Have fun!

1
  • Are these scriptlets in your reports? If so can you please give an example of exactly how you're referencing them in your report, and what resource id, etc... you used when uploading them to the jasper server. No matter what I try my scriptlet cannot be found on jasper server. Thanks!
    – ununiform
    Nov 4, 2014 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.