I’m are trying to set up a batch process to run jobs on the start-up of my program. I’ve looked through the forums and found threads with similar problems and I’ve tried the suggestions, but am still having problems getting my batch process to recognize arguments.
Here is how my process is setup: Solution: mySolutionName Args: true User: myUserName Startup Msg: -empty- Status: Is running
Here is my open method:
function Program_Open()
{
var isBatchProcessor = arguments[0];
//Set global date and time fields
var date = new Date();
globals.g_Current_Date = utils.dateFormat(date,"MM/dd/yyyy");
globals.g_CC_Box2_Wait_Time = date;
globals.g_CC_Box3_Wait_Time = date;
globals.g_CC_Box4_Wait_Time = date;
globals.g_CC_Total_Wait_Time = date;
if(isBatchProcessor)
{
//Updates qtab_encounters timer
plugins.scheduler.addCronJob('Qtab In Room','0/3 0 * * * ?',globals.Qtab_CC_Update);
//Updates CC Box 2 timer
plugins.scheduler.addCronJob('Wait Time','0 0/1 * * * ?',globals.CC_Update_Box2_Time);
//Updates CC Box 3 timer
plugins.scheduler.addCronJob('Room Time','0 0/1 * * * ?',globals.CC_Update_Box3_Time);
//Updates CC Box 4 timer
plugins.scheduler.addCronJob('Checkout Time','0 0/1 * * * ?',globals.CC_Update_Box4_Time);
}
else
{
plugins.dialogs.showErrorDialog("Didn't Work","isBatchProcessor = " + isBatchProcessor,"OK");
}
My variable isBatchProcessor always returns “undefined.” Could someone show me where I’m getting off course?
I tried your suggestion and am now getting the following error:
TypeError: Cannot read property “0” from (C:\Users\Nicholas\Documents\servoy_workspace\eClinic\globals.js#2333)
at C:\Users\Nicholas\Documents\servoy_workspace\eClinic\globals.js:2333 (Program_Open)
Do I have the Args setup properly in my batch process?
When running this through the debugger the first line of code, var args = application.getStartupArguments(), var args returns null. I’ve looked in the Server Admin Guide and noticed when they list arguments for the batch process the arguments are in brackets: arguments[0]. I tried using arguments[true], but couldn’t get that to work. I found a post that suggested just listing the argument. That is what I’m currently doing. In the batch process my Args: true. Is that correct?
I appreciate your help and patience. I turned off debugger and started my solution. The console still shows “No argument”. I don’t know why I’m having so much trouble with this.
I was having trouble understanding Batch Processor arguments, but martinh helped me see what I was doing wrong. Now my problem is getting my CronJob to execute. For testing purposes, I have a global method that sets a copyright field to “2009”.
function Test_Method()
{
forms.DEV_Preferences.copyright = "2009";
}
My batch processor is setup like so:
Soloution: eClinic
Args: true
User: userName
Startup Msg: -empty-
Status: Is running
If I leave the CronJob out of my Program_Open method, this works fine:
function Program_Open()
{
var batchProcessor = arguments[0];
if(batchProcessor == "true")
{
globals.Test_Method();
}
}
When I add the CronJob, it’s almost like the batch process doesn’t fire:
function Program_Open()
{
var batchProcessor = arguments[0];
if(batchProcessor == "true")
{
//Remove jobs
plugins.scheduler.removeJob('Test Job');
//Create Jobs
plugins.scheduler.addCronJob('Test Job','0/15 0 * * * ?',globals.Test_Method);
}
}
Without the CronJob the copyright field changes to “2009”. With the CronJob, the copyright field never populates.
I found this in my server log:
2009-09-14 14:18 | BatchProcess: eClinic |ERROR | com.servoy.j2db.util.Debug | Throwable
java.lang.ClassCastException: com.servoy.j2db.plugins.ClientPluginAccessProvider cannot be cast to com.servoy.j2db.server.headlessclient.IWebClientPluginAccess
at com.servoy.extensions.beans.dbtreeview.WicketDBTreeView.(WicketDBTreeView.java:58)
at com.servoy.extensions.beans.dbtreeview.DBTreeView.getWicketDBTreeView(DBTreeView.java:78)
at com.servoy.extensions.beans.dbtreeview.DBTreeView.createWicketTree(DBTreeView.java:61)
at com.servoy.extensions.beans.dbtreeview.DBTreeView.getBeanInstance(DBTreeView.java:45)
at com.servoy.j2db.dataui.ComponentFactory.createBean(ComponentFactory.java:365)
at com.servoy.j2db.dataui.ComponentFactory.createComponentEx(ComponentFactory.java:701)
at com.servoy.j2db.dataui.ComponentFactory.createComponent(ComponentFactory.java:475)
at com.servoy.j2db.server.headlessclient.dataui.Zmb.Za(Zmb.java:142)
at com.servoy.j2db.server.headlessclient.dataui.Zmb.Za(Zmb.java:41)
at com.servoy.j2db.FormController.Za(FormController.java:402)
at com.servoy.j2db.FormController.Za(FormController.java:64)
at com.servoy.j2db.FormManager.Zf(FormManager.java:160)
at com.servoy.j2db.FormManager.Za(FormManager.java:122)
at com.servoy.j2db.server.headlessclient.dataui.Zwb.Zb(Zwb.java:8)
at com.servoy.j2db.server.headlessclient.dataui.WebTabPanel.getDefaultSort(WebTabPanel.java:312)
at com.servoy.j2db.server.headlessclient.dataui.WebTabPanel.Za(WebTabPanel.java:185)
at com.servoy.j2db.server.headlessclient.dataui.WebTabPanel.notifyVisible(WebTabPanel.java:30)
at com.servoy.j2db.dataprocessing.Zfb.Za(Zfb.java:361)
at com.servoy.j2db.server.headlessclient.dataui.WebDataRenderer.notifyVisible(WebDataRenderer.java:88)
at com.servoy.j2db.FormController.notifyVisible(FormController.java:353)
at com.servoy.j2db.FormManager.Za(FormManager.java:112)
at com.servoy.j2db.FormManager.Zd(FormManager.java:92)
at com.servoy.j2db.FormManager.Za(FormManager.java:399)
at com.servoy.j2db.Zjb.run(Zjb.java:1)
at com.servoy.j2db.server.headlessclient.SessionClient.invokeLater(SessionClient.java:263)
at com.servoy.j2db.FormManager.propertyChange(FormManager.java:443)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at com.servoy.j2db.J2DBGlobals.firePropertyChange(J2DBGlobals.java:2)
at com.servoy.j2db.server.headlessclient.SessionClient.Za(SessionClient.java:373)
at com.servoy.j2db.ClientState.handleLoadedSolution(ClientState.java:13)
at com.servoy.j2db.server.headlessclient.SessionClient.Za(SessionClient.java:475)
at com.servoy.j2db.server.headlessclient.HeadlessClientFactory.createSessionBean(HeadlessClientFactory.java:2)
at com.servoy.j2db.server.headlessclient.HeadlessClientFactory.createSessionBean(HeadlessClientFactory.java:3)
at com.servoy.j2db.server.Zi.Zf(Zi.java:21)
at com.servoy.j2db.server.Zh.run(Zh.java:1)
at java.lang.Thread.run(Unknown Source)
After more testing, I have discovered that using “addJob”
function Program_Open()
{
var date = new Date();
var batchProcessor = arguments[0];
if(batchProcessor == "true")
{
//Remove jobs
plugins.scheduler.removeJob('Test Job');
//Create Jobs
plugins.scheduler.addJob("Test Job", date, globals.Test_Method, 15000);
}
}
instead of “addCronJob”
function Program_Open()
{
var batchProcessor = arguments[0];
if(batchProcessor == "true")
{
//Remove jobs
plugins.scheduler.removeJob('Test Job');
//Create Jobs
plugins.scheduler.addCronJob('Test Job','0/15 0 * * * ?',globals.Test_Method);
}
}
works great. So either I have my CronJob setup incorrectly or it could be a bug…?
I’m setting the field just so that I can see that the batch processor is doing something. I have CronJobs that keeps track of patient wait times. Waiting Room, In Exam Room, Checkout, etc. I made sure the CronJobs worked in Developer, then made it a batch process to call my method so I could test it using the servoy client. When the method containing the CronJobs is called by the batch process, my patient wait times don’t calculate. In trying to figure out why my jobs aren’t working, I’ve taken out the time calculations and resorted to something simple like assigning a value to a field. That is why I have my test method that sets a copyright field to “2009”. Ultimately, I won’t be doing anything like this within the batch process. I was just wondering why using a addCronJob caused the method to stop working. And why it works when I use addJob. Did I clear anything up or just muddy the water?
Can you tell me a better way to get my desired result? Basically, I need all clients to see these patient times. I need the times to update every minute, that is why I thought having CronJobs run in a batch process would be best.
Thanks again for all your help. It is greatly appreciated.
But there is a problem with Servoy in databroadcasting where updates from headless client are not visible on other clients.
Adrian McGilly has created a sample and gave that to Servoy, but as far as I know this issue was not fixed in 4.1.4
So it can be possible (perhaps you don’t have the problem) that the value is not shown on other clients.
Of course after quit client and restart client, then it will be visible
Thanks Robert. Now I know why I’m getting a treeView error in my log. I was still not able to get the CronJob to work properly. I’m looking into alternative ways of increment my times by one minute.
Im having a similar problem with the CronJob i use it in my application to run some global method every second.
if i run it from the developer it works just fine, but when i run it from the client then its no use the method is never executed unless i log in my PC with administrator profile, then it works just fine. This makes me think of a permission trouble, perhaps firewall blocking something the scheduler uses to call the method but im not sure, still trying to figure that out. So if anyone knows what could it be id appreciate some help
Thanks
I’m having apparently the same issue.
When I start the Batch user I get the following error in the logs:
java.lang.ClassCastException: com.servoy.j2db.plugins.ClientPluginAccessProvider cannot be cast to com.servoy.j2db.server.headlessclient.IWebClientPluginAccess
at com.servoy.extensions.beans.dbtreeview.WicketDBTreeView.(WicketDBTreeView.java:59)
at com.servoy.extensions.beans.dbtreeview.DBTreeView.getWicketDBTreeView(DBTreeView.java:78)
at com.servoy.extensions.beans.dbtreeview.DBTreeView.createWicketTree(DBTreeView.java:61)
at com.servoy.extensions.beans.dbtreeview.DBTreeView.getBeanInstance(DBTreeView.java:45)
at com.servoy.j2db.dataui.Zeb.createBean(Zeb.java:327)
at com.servoy.j2db.dataui.Zeb.createComponentEx(Zeb.java:462)
at com.servoy.j2db.dataui.Zeb.createComponent(Zeb.java:527)
at com.servoy.j2db.server.headlessclient.dataui.Zac.Za(Zac.java:205)
at com.servoy.j2db.server.headlessclient.dataui.Zac.Za(Zac.java:39)
at com.servoy.j2db.Zpb.Za(Zpb.java:846)
at com.servoy.j2db.Zpb.Zb(Zpb.java:1260)
at com.servoy.j2db.Zwb.Zg(Zwb.java:134)
at com.servoy.j2db.Zwb.Za(Zwb.java:82)
at com.servoy.j2db.server.headlessclient.dataui.Znc.Zb(Znc.java:21)
at com.servoy.j2db.server.headlessclient.dataui.WebTabPanel.getDefaultSort(WebTabPanel.java:14)
at com.servoy.j2db.server.headlessclient.dataui.WebTabPanel.Za(WebTabPanel.java:96)
at com.servoy.j2db.server.headlessclient.dataui.WebTabPanel.notifyVisible(WebTabPanel.java:384)
at com.servoy.j2db.dataprocessing.Zgb.Za(Zgb.java:96)
at com.servoy.j2db.server.headlessclient.dataui.Zkg.notifyVisible(Zkg.java:147)
at com.servoy.j2db.Zpb.Za(Zpb.java:332)
at com.servoy.j2db.Zwb.Za(Zwb.java:316)
at com.servoy.j2db.Zwb.Ze(Zwb.java:146)
at com.servoy.j2db.Zwb.Za(Zwb.java:291)
at com.servoy.j2db.Zzb.run(Zzb.java:3)
at com.servoy.j2db.server.headlessclient.Zb.invokeLater(Zb.java:317)
at com.servoy.j2db.Zwb.propertyChange(Zwb.java:170)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at com.servoy.j2db.J2DBGlobals.firePropertyChange(J2DBGlobals.java:40)
at com.servoy.j2db.server.headlessclient.Zb.Za(Zb.java:311)
at com.servoy.j2db.ClientState.handleLoadedSolution(ClientState.java:263)
at com.servoy.j2db.server.headlessclient.Zb.Za(Zb.java:54)
at com.servoy.j2db.server.headlessclient.Zp.createSessionBean(Zp.java:1)
at com.servoy.j2db.server.headlessclient.Zp.createHeadlessClient(Zp.java:2)
at com.servoy.j2db.server.Zi.Za(Zi.java:44)
at com.servoy.j2db.server.Zh.run(Zh.java:1)
at java.lang.Thread.run(Unknown Source)
And then the scheduled method is not called apparently. Nothing happens.
The errors seems to be linked to the DBTreeView bean. Indeed, I’m using it in the solution but not with the Batch user.