Jump to content
We've recently updated our Privacy Statement, available here ×

How to add a custom function jar to a report


luke2000

Recommended Posts

Hello,

i have the following problem:
in my database i have a table with credentials and values, the credentials come from System UserDomain and user name.

i already implemented a custom method for Jasper

    /**
     * USER DOMAIN NAME
     * @return
     */
    @Function("OWNER")
    public static String OWNER() {
        return String.format("%s%s%s", System.getenv("USERDOMAIN"), "\", System.getProperty("user.name"));
    }

this is working fine and i can put the owner on the report.
but i need to limit my results with this parameter.

therefore i created a Parameter OWNER, which is of type java.lang.String and its Default Value Expression = OWNER() (note that i set Evaluation Time to Early.

currently my query for the Dataset looks like this:

SELECT * FROM tContactsWHERE conIdContact IN (    SELECT value    FROM tReports    WHERE class = 'Contact'        AND owner = OWNER)

this is working nice if i run my jrxml from within Jaspersoft Studio.
When i use my .jasper file in my Applications window i get the following error message:

net.sf.jasperreports.engine.JRException: Error preparing Satatement for executing the report query (followed by the query above)
so i guess i am missing something - i guess its the jar with my custom methods

how can i include this in the report (i am not suing jasper server)

 

NOTE: i get the same error in jaspersoft studio when i create the report and include the custom method jar in build path
PS: obviously i can provide the jar
 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Have you set the correct import at report level in jrxml? (e.g. "com.yourpackage.YourToolsOwnerClass" )

When I use my own custom functions within expressions and so on  I always had to setup the import within the report design correctly. (but I've never used it within the main query ...unfortunately, so not sure, whether the import could solve your problem)

Perhaps it helps 

regards

C-Box

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...