Hi all,
I have written a simple test scheduler script to store file on a windows machine every minute. When I execute the methods on the client it works fine.
When I execute as a Batch Process using Servoy Server admin interface. I get the following error on the server log
I tried to extract the file.jar in order to check the error for com.servoy.extensions.plugins.file.FileProvider.js_writeTXTFile(FileProvider.java:647). But there was no java files provided along with the class files
java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(Unknown Source)
at java.awt.Window.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(Unknown Source)
at javax.swing.SwingUtilities.getSharedOwnerFrame(Unknown Source)
at javax.swing.JOptionPane.getRootFrame(Unknown Source)
at javax.swing.JOptionPane.getWindowForComponent(Unknown Source)
at javax.swing.JFileChooser.createDialog(Unknown Source)
at javax.swing.JFileChooser.showDialog(Unknown Source)
at javax.swing.JFileChooser.showSaveDialog(Unknown Source)
at com.servoy.j2db.util.FileChooserUtils.getAWriteFile(FileChooserUtils.java:18)
at com.servoy.extensions.plugins.file.FileProvider.js_writeTXTFile(FileProvider.java:647)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:179)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:347)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:73)
at org.mozilla.javascript.gen.c7._c0(cron_method:9)
at org.mozilla.javascript.gen.c7.call(cron_method)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:387)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3122)
at org.mozilla.javascript.gen.c7.call(cron_method)
at com.servoy.j2db.scripting.ScriptEngine.executeFunction(ScriptEngine.java:45)
at com.servoy.j2db.plugins.ClientPluginAccessProvider$MethodExecutor.run(ClientPluginAccessProvider.java:18)
at com.servoy.j2db.server.headlessclient.SessionClient.invokeLater(SessionClient.java:292)
at com.servoy.j2db.plugins.ClientPluginAccessProvider$1.run(ClientPluginAccessProvider.java:5)
at com.servoy.j2db.util.TaskExecuter.run(TaskExecuter.java:9)
at java.lang.Thread.run(Unknown Source)
This is the function that is executed on startup:
function test()
{
//My startup script on open of the solution
var batch_command = arguments[0];
if(batch_command == "test")
{
globals.create_cron_jobs();
}
}
function create_cron_jobs()
{
plugins.scheduler.addCronJob('1min','0 0/1 * * * ?',globals.cron_method);
}
function cron_method()
{
// Method that creates the file on the PC machine
var fileName = 'test.txt';
var filePath = plugins.file.getDesktopFolder();
filePath +="/" + fileName;
plugins.file.writeTXTFile(filePath,'test');
}
function remove_cron_jobs()
{
plugins.scheduler.removeJob('1min')
}
On the Servoy admin Batch Processor interface I have the following parameters sets
Solution: test_solution
args: test
User: Admin
Startup Msg: -Empty-
Status: Is running
when i check the logs it actually runs the cron_method() every 1 minute and throws the error on the server log file.
Any help would be appreciated?
Regards
James Dcunha