I have make an headless client jsp page to run a method on the server. And in order to do the call (showURL) in background, I used some java code.
It works well: the page is called in background and the method runs on the server. But at the end I get a pop-up message on the Smart Client saying:
Error: Current script terminated
In the Developer console I get:
Current script terminated
> java.lang.RuntimeException: Current script terminated
In the logs I get:
- Code: Select all
2009-03-17 13:20:03,942 ERROR [AWT-EventQueue-0] com.servoy.j2db.util.Debug - Throwable
java.lang.RuntimeException: Current script terminated
at org.eclipse.dltk.rhino.dbgp.DBGPStackManager.changeLine(DBGPStackManager.java:84)
at org.eclipse.dltk.rhino.dbgp.DBGPDebugFrame.onLineChange(DBGPDebugFrame.java:83)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:4138)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2680)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:166)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:387)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3122)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:165)
at com.servoy.j2db.scripting.RemoteDebugScriptEngine.executeFunction(RemoteDebugScriptEngine.java:109)
at com.servoy.j2db.FormController.Za(FormController.java:668)
at com.servoy.j2db.FormController.executeFunction(FormController.java:253)
at com.servoy.j2db.FormController.actionPerformed(FormController.java:391)
at com.servoy.j2db.Zfb.actionPerformed(Zfb.java:11)
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.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)
Here is the code I use to start the headless client in background:
- Code: Select all
var javaIoPackage = Packages.java.io;
var javaNetPackage = Packages.java.net;
var myUrl = new javaNetPackage.URL('http://localhost:8085/pdfTool/doc2pdf2.jsp?docID='+docID);
var conn = myUrl.openConnection();
var inputStream = new javaIoPackage.InputStreamReader(conn.getInputStream()); //Error during that line
//No application.output working from this point
var buffRead = new javaIoPackage.BufferedReader(inputStream);
var line;
while ((line = buffRead.readLine()) != null) {
application.output('Line: '+line);
}
My jsp file (which works well):
- Code: Select all
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import = "java.util.*" %>
<%@ page import = "com.servoy.j2db.server.headlessclient.*" %>
<%@ page import = "com.servoy.j2db.util.*" %>
<%@ page import = "com.servoy.j2db.dataprocessing.IDataSet" %>
<%@ page errorPage="errorpage.jsp" %>
<%
ISessionBean servoy_hc = (ISessionBean)session.getAttribute("servoy");
if (servoy_hc == null)
{
servoy_hc = HeadlessClientFactory.createSessionBean(request,"doc2pdf_v2");
session.setAttribute("servoy",servoy_hc);
boolean ok = servoy_hc.setMainForm("formv2");
if (!ok)
{
out.print("error cannot work on required form");
//return;
}
}else{
out.print("Not in if !");
//return;
}
String docID = request.getParameter("docID");
Object pdfNameObj = servoy_hc.executeMethod(null,"genPDF",new Object[]{docID});
String pdfName = pdfNameObj.toString();
session.setAttribute("servoy",null);
out.print("<br><center>PDF file check...</center>");
%>
<html>
<head>
<title>PDF file Generator</title>
</head>
<body>
<br><center>PDF file checksssss...</center>
</body>
</html>