[#3556] - iReport embedded can't save multiple opened Jrxml files

Category:
Bug report
Priority:
High
Status:
New
Project: Severity:
Major
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:
0

I experience issue regarding JRXML files save action within iReport Designer 5.5.0/5.5.1.
iReport Designer is embedded inside a Java 7 application, which means we launch iReport platform from a source code :

Thread work = new Thread() {

@Override
public void run() {

String params[] = new String[0];
try {
NbBundle.setBranding("ireport");

Main.main(params);

IReportManager.getPreferences().putBoolean("askForImportingSettings", false);
} catch (Exception e) {
e.printStackTrace();
}
}
};

work.start();

iReport is launching with Netbeans 7.4 platform, so far so good.
If I open a single Jrxml file from source code into iReport I can save the Jrxml file several time without any issue.

The problem appears each time I load several Jrxml files into iReport. It's impossible to save any file and an exception appears in console:

SEVERE [global]
java.lang.NullPointerException
at com.jaspersoft.ireport.designer.JrxmlEditorSupport$3.run(JrxmlEditorSupport.java:267)
at org.openide.util.Mutex.doEvent(Mutex.java:1348)
at org.openide.util.Mutex.writeAccess(Mutex.java:462)
at com.jaspersoft.ireport.designer.JrxmlEditorSupport.saveDocument(JrxmlEditorSupport.java:263)
at com.jaspersoft.ireport.designer.JrxmlEditorSupport$1.save(JrxmlEditorSupport.java:73)

After digging in source code, I managed to understand the process. Each file opened close the others with DocumentOpenClose class, more precisely with the folling code line:

private final class DocumentRef extends WeakReference<StyledDocument> implements Runnable {

public DocumentRef(StyledDocument doc) {
super(doc, org.openide.util.Utilities.activeReferenceQueue());
}

@Override
public void run() {
synchronized (lock) {
if (this == docRef) {
closeImplLA(null, true); // Delayed close
}
}
}

}

This call result by making the JxmlEditorSupport saveDocument() method crashing at the following line :

public void saveDocument() throws IOException {
...

final String theContent = content;
Mutex.EVENT.writeAccess(new Runnable() {

public void run() {
try {
getDocument().remove(0, getDocument().getLength()); <--- CRASH HERE
getDocument().insertString(0, theContent, null);
((JrxmlVisualView) getDescriptions()[0]).setNeedModelRefresh(false);
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
}
});
... }

because getDocument is CLOSED and the refDocument is NULL.
Is there any parameter or JVM argument I could use to prevent GC from closing the document ?

v5.5.1
o.clercq's picture
Joined: Apr 14 2014 - 7:13am
Last seen: 7 years 5 months ago

1 Comment:

#1
  • Assigned:nobody»

(100%) Replicable in iReports-5.6 running on
* OS: Ubuntu-14.04.
* JVM: Oracle-Java7 (v1.7.0_60)

I am launching from source code via Netbeans (v8.0).

Feedback
randomness