Home
Analytics
Java Exception, Not Enough Information
linucksrox
<p>Hello,</p>
<p> </p>
<p>I have a report that runs fine in BIRT viewer 3.7.2. I'm working through all my reports migrating them to BIRT 4.5 and using MySQL 5.7. When I run this one report in the 4.5 viewer, it gives a java.lang.nullpointerexception and gives a stacktrace. However, it's not enough information (usually these things don't give enough information in the web viewer). I see that the preview function has been removed in newer BIRT releases, but I used to rely on that in cases like this for more information about where the exception was being thrown. How can I get more information about this issue? Is there an error log somewhere that I can access?</p>
<p> </p>
<p>In case it helps, I did happen to narrow down the exception to line 3 of this code:</p>
<pre class="_prettyXprint _lang-js _linenums:1">
// get the DelinquentDuesTable handle to be used for setting its sort direction
table = reportContext.getDesignHandle().findElement("DelinquentDuesTable");
table.getListProperty("sort").get(0).setProperty("direction",params["sortDirection"].value);
</pre>
Find more posts tagged with
Comments
Matthew L.
<p>You can still access the .log file within the <Workspace>/.metadata folder to get more information about the error.</p>
<p>My guess is that "table.getListProperty("sort")" is returning null and therefore the ".get(0)" cannot get 0 of null.</p>
<p>This can occur when the list property doesn't have a pre-existing condition.</p>
<p>Use setListProperty() to create a new property from scratch: <a data-ipb='nomediaparse' href='
http://help.eclipse.org/mars/topic/org.eclipse.birt.doc.isv/model/api/org/eclipse/birt/report/model/api/DesignElementHandle.html#setProperty(java.lang.String, java.lang.Object)'>http://help.eclipse.org/mars/topic/org.eclipse.birt.doc.isv/model/api/org/eclipse/birt/report/model/api/DesignElementHandle.html#setProperty(java.lang.String
, java.lang.Object)</a></p>
linucksrox
<p>Is there a configuration option to enable error logging? I don't see any .log files in my workspace/.metadata folder.</p>
<p>I've broken line 3 into several lines so I can trace where the error occurs.</p>
<pre class="_prettyXprint _lang-js">
table = reportContext.getDesignHandle().findElement("DelinquentDuesTable");
propertyList = table.getListProperty("sort"); // returns an ArrayList
sortProperty = propertyList.get(0);
if (sortProperty == null) {
log("sortProperty is null");
}
else {
log(sortProperty.getClass());
}
//sortProperty.setProperty("direction", params["sortDirection"].value);
</pre>
<p>Everything works until the last line, and sortProperty.getClass() is logged to my console which shows "class org.eclipse.birt.report.model.api.elements.structures.SortKey" The last line is commented out because as soon as I enable it, the error comes back. How can I trace this further?</p>
Matthew L.
<p>If you are on a windows box, make sure you have hidden files turned on and your extensions are turned on to see the log file (see attached images difference).</p>
<p>If the log file still doesn't appear, verify you are in the correct workspace by clicking "File -> Switch Workspace -> Other" in the designer. Then copy the path listed and select "Cancel".</p>
<p>Then paste the path in your file Explorer.</p>
<p> </p>
<p>If you are running on a MAC or Linux machine, the .log file is a hidden file and you will need to view hidden files in order to see the .log file.</p>
<p> </p>
<p>Also, I debugged the code you posted. I believe the reason for the error you were receiving is due to the value you were setting for the "direction".</p>
<p>As long as you already have a sort key defined in the table, your code should work when passing "asc" or "desc" as the "direction" values.</p>
<p> </p>
<p>I've attached a sample report to demonstrate this.</p>
<p>Hopefully this helps.</p>
linucksrox
<p>Aha, you're right. My sortDirection parameter is a String text box, with a default value of "desc" (as a literal string value, including double quotes). When I changed the default value from "desc" to desc, it worked. Apparently the old version of the report viewer just ignores this error. Thank you for figuring that out.</p>
<p> </p>
<p>As far as error logging, I'm still not sure if the .log file is any help. I'm running Windows 8.1 and I always show hidden files. The .log file appeared today, although it doesn't contain any errors thrown when running in the viewer (I run in Firefox if that matters). If I purposely cause this NullPointerException, no new entries are added to the .log file. Is there a configuration setting for this? It's such a pain because sometimes the message in the dialog box doesn't contain enough information, even to the point of truncating the stack trace so I can be sure to have absolutely no idea what to look for.</p>
Matthew L.
<p>That is interesting behavior and I am unsure why no .log file gets generated for you.</p>
<p>Also unfortunately, I have not found a way to change the Logging Level in the BIRT Designer.</p>
linucksrox
<p>Well thanks for helping me solve this one.</p>
<p>Looking at the little information that is being logged in my workspace log file, it seems to only relate to errors caused by the designer itself, and not errors that occur during report generation. I would hope there's actually a different log file somewhere which logs errors related to report generation, but you haven't seemed to indicate anything like that.</p>
<p>Having said that, is there a way to get the Preview tab back in 4.5? In cases like this I used to always use Preview and it would give me much more information, so it seems like a step in the wrong direction to remove the Preview tab and leave users with a truncated stack trace (which is only marginally better than Microsoft's "Something happened" error message).</p>
Matthew L.
<p>There are actually lots of log files that BIRT generates.</p>
<p>Perhaps the log files in this location will have what you are looking for: <WorkspaceFolder>\.metadata\.plugins\org.eclipse.birt.report.viewer\logs\</p>
<p> </p>
<p>Also I am not sure about the decision for the Preview Tab, however I do know that on rare occasions the Preview Tab would generate a different output than running the report design through the Run menu.</p>
linucksrox
<blockquote class="ipsBlockquote">
<p> </p>
<p> </p>
<span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"><WorkspaceFolder>\.metadata\.plugins\org.eclipse.birt.report.viewer\logs\</span></blockquote>
<p>That is what I was looking for. I never learned about this when I started with BIRT a few years ago and instead relied on the preview tab. But I think this provides more information and I don't have to worry about running the report in different modes to track down errors. Thanks Matthew!</p>