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

Nullpointer when reading fields from query (3.5.2)


luciano_castro

Recommended Posts



Using IReport 3.5.2, when i try to read fields from a query using the check box "Automatically retrieve fields" or pressing "Read Fields" button, i receive this message: "Error:null "


Looking at IDE's Log file, i found this exception:

java.lang.NullPointerException
        at com.jaspersoft.ireport.designer.data.ReportQueryDialog.recursiveInterpreter(ReportQueryDialog.java:1843)
        at com.jaspersoft.ireport.designer.data.ReportQueryDialog$FieldReader.run(ReportQueryDialog.java:546)


The Database connection seems to be ok, I can preview the report using it.

the full log file is attached.

Is it a bug or i'm missing some configuration?
 

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

hi iancr01 !



The query is fine, actually any query that i use produces the error, even the easiest ones like 'select id from my_table'.



I put the fields manually into the report, compiled it and used it with my application. The report worked just like i expected.



The only problem is when i try to read the fields.




tks for the reply


=)

Link to comment
Share on other sites

  • 3 months later...

Hi luciano_castro,

Giulio and I came across your post while troubleshooting the same error message from a customer. It seems like it's a subtle design issue. I can recreate your scenario by creating two simple parameters:

  • parameter1, type string, no default value
  • parameter2, type string, default value = $P{parameter1}

iReport returns Error:null when you click Read Fields in the Report query box.

In this scenario the default value for parameter2 is "null" because that's the value for parameter1. Set a default value for parameter1 and the field list is returned.

It seems like you may have a similar issue where at least one parameter has a default value that is evaluating to null. In my customer's case the default value is being set by a custom method and we need to work that out. In your case I hope it's as simple as the example above.

Good luck!

Mary Flynn

Jaspersoft sales engineer

 

Link to comment
Share on other sites

  • 2 years later...

I'm running into a similar error when attempting to "Read Fields" using my custom Fields Provider.

Ensuring that all the parameters in the report have valid defaultValueExpressions (as suggested above) seem to be doing the trick.... except when I try to use my custom REPORT_SCRIPTLET within the default expression, such as:

 <parameter name="ToDate" class="java.lang.String" isForPrompting="false">
  <defaultValueExpression><![CDATA[$P{REPORT_SCRIPTLET}.getFormattedDate()]]></defaultValueExpression>
 </parameter>
 

Is there a trick to ensuring that the REPORT_SCRIPTLET parameter itself is initialized?

 

 

Link to comment
Share on other sites

FYI: I found that if I try to instantiate my custom REPORT_SCRIPTLET in the parameter using something like this: 

<parameter name="ToDate" class="java.lang.String" isForPrompting="false">
  <defaultValueExpression><![CDATA[new my.company.reports.MyReportScriptlet().getFormattedDate()]]></defaultValueExpression>
</parameter>
 

...that appears to allow the "Read Fields" functionality to work.

I'm guessing that is not the safest way becaues it looks like instantiating my custom report scriptlet myself ... causes certain other parameters that the report scriptlet methods might depend on ... such as REPORT_LOCALE may not get set propertly.  But at least it seems to work for static/independent methods in the report scriptlet that perform simple functions that don't need other parameters or environmental settings.

 

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