Hi,
I got a report to run in a Jframe in a swing popup.
I got it to work locally in eclipse but not when I run my jnlp application outside eclipse.
I get the following error;
oct. 04, 2013 5:18:54 PM org.eclipse.birt.report.engine.api.impl.EngineTask handleFatalExceptions
SEVERE: An error happened while running the report. Cause:
java.lang.IllegalArgumentException: securityDomain should be null if setSecurityController() was never called
at org.mozilla.javascript.Context.compileImpl(Context.java:2340)
at org.mozilla.javascript.Context.compileString(Context.java:1359)
at org.mozilla.javascript.Context.compileString(Context.java:1348)
Here is my JFrame code with the resource locator I had to create to run a report from a jar file and my error at the very bottom.
If anyone has any idea ( it looks like I need to set some sort of javascriptengine context)
package gizmo.userinterface;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IRenderOption;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
public class RunReport extends JFrame {
/**
*
*/
private static final long serialVersionUID = 4255436363495737794L;
JEditorPane myEditorPane = null;
IReportEngine engine = null;
EngineConfig config = null;
RunReport() {
myEditorPane = new JEditorPane();
myEditorPane.setEditable(false);
JScrollPane scrollPane = new JScrollPane(myEditorPane);
JFrame myframe = new JFrame("Comparaison processus");
myframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myframe.getContentPane().add(scrollPane);
myframe.setSize(600, 600);
myframe.setVisible(true);
startPlatform();
runReport();
stopPlatform();
}
@SuppressWarnings("unchecked")
public void runReport() {
try {
IReportRunnable design = null;
// Open the report design
InputStream stream = this
.getClass()
.getResourceAsStream(
"/gizmo/resources/CompareProcessInTwoEnvironment.rptdesign");
design = engine.openReportDesign(stream);
// Create task to run and render the report,
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
HTMLRenderOption options = new HTMLRenderOption();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
options.setOutputStream(bos);
options.setOutputFormat(IRenderOption.OUTPUT_FORMAT_HTML);
options.setEmbeddable(true);
task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, RunReport.class.getClassLoader());
task.setParameterValue("Process", "ATV01");
task.setRenderOption(options);
task.run();
task.close();
myEditorPane.setContentType("text/html");
myEditorPane.setText(bos.toString());
System.out.println("Finished Gen");
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void startPlatform() {
try {
config = new EngineConfig();
config.setResourceLocator(new GizmoRessourceLocator());
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
engine = factory.createReportEngine(config);
}
catch (Exception e) {
e.printStackTrace();
}
}
public void stopPlatform() {
engine.destroy();
Platform.shutdown();
}
}
package gizmo.userinterface;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.util.Collections;
import java.util.Map;
import org.eclipse.birt.report.model.api.IResourceLocator;
import org.eclipse.birt.report.model.api.ModuleHandle;
public class GizmoRessourceLocator implements IResourceLocator {
public GizmoRessourceLocator() {
// TODO Auto-generated constructor stub
}
@Override
public URL findResource(ModuleHandle module, String filename, int type) {
return findResource(module, filename, type, Collections.emptyMap());
}
@Override
public URL findResource(final ModuleHandle moduleHandle,
final String fileName, final int type,
@SuppressWarnings("rawtypes") final Map appContext) {
try {
// The actual URL is not important, it just needs to be valid.
// We will later use the parameters to this method to resolve the
// InputStream.
return new URL(null, "birtres://"+fileName, new URLStreamHandler() {
@Override
protected URLConnection openConnection(URL url)
throws IOException {
return new URLConnection(url) {
@Override
public InputStream getInputStream() throws IOException {
// TODO Return your stream here.
// Do something with fileName for example.
System.out
.println("getInputStream called. fileName is: "
+ fileName);
InputStream stream = this
.getClass()
.getResourceAsStream(
"/gizmo/resources/"+fileName);
return stream;
}
@Override
public void connect() throws IOException {
// TODO Auto-generated method stub
}
};
}
});
} catch (MalformedURLException e) {
// Since it is our own URL, this should not happen.
throw new IllegalStateException(
"Hardcoded URL malformed. Please revisit this class.");
}
}
}
Now i'm stuck with a error when I run the application outside eclipse.
getInputStream called. fileName is: procedurecode.rptlibrary
oct. 04, 2013 5:18:54 PM org.eclipse.birt.report.engine.api.impl.EngineTask handleFatalExceptions
SEVERE: An error happened while running the report. Cause:
java.lang.IllegalArgumentException: securityDomain should be null if setSecurityController() was never called
at org.mozilla.javascript.Context.compileImpl(Context.java:2340)
at org.mozilla.javascript.Context.compileString(Context.java:1359)
at org.mozilla.javascript.Context.compileString(Context.java:1348)
at org.eclipse.birt.report.engine.javascript.JavascriptEngine$3.run(JavascriptEngine.java:240)
at org.eclipse.birt.report.engine.javascript.JavascriptEngine$3.run(JavascriptEngine.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.birt.report.engine.javascript.JavascriptEngine.compile(JavascriptEngine.java:236)
at org.eclipse.birt.report.engine.javascript.JavascriptEngine.compile(JavascriptEngine.java:1)
at org.eclipse.birt.core.script.ScriptContext.compile(ScriptContext.java:148)
at org.eclipse.birt.report.engine.executor.ExecutionContext.compile(ExecutionContext.java:773)
at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:707)
at org.eclipse.birt.report.engine.executor.ReportItemExecutor.evaluate(ReportItemExecutor.java:284)
at org.eclipse.birt.report.engine.executor.TextItemExecutor.executeHtmlText(TextItemExecutor.java:115)
at org.eclipse.birt.report.engine.executor.TextItemExecutor.execute(TextItemExecutor.java:70)
at org.eclipse.birt.report.engine.executor.ReportExecutorUtil.executeAll(ReportExecutorUtil.java:87)
at org.eclipse.birt.report.engine.executor.ReportExecutorUtil.executeAll(ReportExecutorUtil.java:92)
at org.eclipse.birt.report.engine.executor.ReportExecutor.createPageExecutor(ReportExecutor.java:229)
at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplciateReportExecutor.createPageExecutor(SuppressDuplciateReportExecutor.java:61)
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportExecutor.createPageExecutor(WrappedReportExecutor.java:49)
at org.eclipse.birt.report.engine.executor.ReportExecutorUtil.executeMasterPage(ReportExecutorUtil.java:63)
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.start(HTMLPageLM.java:147)
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:91)
at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:181)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
at gizmo.userinterface.RunReport.runReport(RunReport.java:69)
at gizmo.userinterface.RunReport.<init>(RunReport.java:42)
at gizmo.userinterface.AideDevelopment$Listener.actionPerformed(AideDevelopment.java:74)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
org.eclipse.birt.report.engine.api.EngineException: Error happened while running the report.
at org.eclipse.birt.report.engine.api.impl.EngineTask.handleFatalExceptions(EngineTask.java:2329)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:191)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
at gizmo.userinterface.RunReport.runReport(RunReport.java:69)
at gizmo.userinterface.RunReport.<init>(RunReport.java:42)
at gizmo.userinterface.AideDevelopment$Listener.actionPerformed(AideDevelopment.java:74)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)