I have a solution “Sola”
I have a form “FormA” which contains a method “methA” and a callback method
.
I have tried different syntax:
function onActionLaunchClient()
{
client = plugins.headlessclient.createClient('Sola','login','pwd',null);
// I tried this
client.queueMethod(null,"forms.FormA.methA",["something"],callback);
// I tried this
client.queueMethod(null,"FormA.methA",["something"],callback);
// I tried a global method
client.queueMethod(null,"globalMethod",["something"],callback);
}
function methA(param)
{
// do something
}
function callback(event) {
// do some stuff
if (JSClient.CALLBACK_EVENT == event.getType())
{
// handle normal execute of remote method
application.output("work");
}
else if (JSClientC.ALLBACK_EXCEPTION_EVENT == event.getType())
{
// handle exception execute of remote method
application.output("notwork");
}
client.shutdown()
}
In all the case I get CALLBACK_EXCEPTION_EVENT in my callback method
If you look at the sample code for the queueMethod function, you see this:
// this calls a 'remoteMethod' on the server as a global method, because the context (first argument is set to null), you can use a formname to call a form method
jsclient.queueMethod(null, "remoteMethod", [x], callback);
So, translated to your example, the following should work:
client = plugins.headlessclient.createClient('Sola','login','pwd',null);
// I tried this
client.queueMethod('FormA',"methA",["something"],callback);
// I tried a global method
client.queueMethod(null,"globalMethod",["something"],callback)
So, the latter method queued, the global method should’ve worked already in your example. Are you sure you got the name correct?
In the sample code you can also see that the details of the exception that occurred is stored in teh data property of the event:
With the formName in the context param, I’m getting now a CALLBACK_EVENT, but my method is not called!!
I have the following error in my servoy_log.txt
2010-08-26 09:51:03,868 ERROR [authenticator] com.servoy.j2db.util.Debug - A Plugin with the internal name file has already been loaded
2010-08-26 09:51:03,915 ERROR [authenticator] com.servoy.j2db.util.Debug - A Plugin with the internal name file has already been loaded
2010-08-26 09:51:34,603 ERROR [authenticator] com.servoy.j2db.util.Debug - A Plugin with the internal name file has already been loaded
2010-08-26 09:51:34,634 ERROR [authenticator] com.servoy.j2db.util.Debug - A Plugin with the internal name file has already been loaded
2010-08-26 09:51:52,775 ERROR [AWT-EventQueue-0] com.servoy.j2db.util.Debug - A Plugin with the internal name file has already been loaded
My solution has a mustAuthenticate flag on, so I have a login and authenticator modules.
I don’t thing these errors are related to the headless_client plugin: it indicates that you seem to have 2 file.jar in your class path (check in /beans and /plugins maybe?)
I tried to trace where the headless_client passes using application.output with LOGINLEVEL.EROOR
I see that it goes up the onload of form login.
I tried to re-authenticate it with security.authenticate (‘module_authenticator’ methLogin, [params]).
I saw that it is authenticated Successfully But What Happened after, this is my big question!
I’ve made a simple solution that illustrates my problem of launching a headlessClient through a solution that requires an authentication.
The solution includes three modules:
main solution: testHeadlessClient
Solution login: SGM_LOGIN
solution authenticator: SGM_AUTHENTICATOR
To test the behaviour
launch the solution
click on the login button to log
click on the button “Launch headless client” who creates a client and associates to it the method “CallMe” which is simply an output of the string “headless method executed” with a LOGGINLEVEL.ERROR.
When I disable authentication (mustAuthenticate = false and loginSolutionName = default), everything works perfectly and my method “CallMe” is called by the headlessClient.
When I enable authentication (mustAuthenticate = true and loginSolutionName = SGM_LOGIN), the headless client is created and the onload method of my login form is called but unfortunately, the method “CallMe” is not called by the headlessClient!
I really do not know what else to test and I really need to use the headless client to associate to it a long process that we have to do in a solution we are developping in version 5.2.
We have another solutions developped with version 5.1.4 witch use batchProcessor which is in effect a headlessClient, So I’m wondering if they will still work if we passes to the 5.2 version
I hope that I was clear enough and If someone can explain to me what I’m doing wrong, that would be very appreciated.
I tried the solution in a real server-smartclient as you suggested and it works
I hope there’s an explanation for why it does longer works on developer
I tried the submitted sample solution in 5.2.1+ from latest SVN source (so containing your fix - rev 1031) and found that although it is now running fine in Smart client, this is still not working in web client.
In Web client, I ran into that Exception:
Exception in thread "pool-5-thread-1" org.apache.wicket.WicketRuntimeException: There is no application attached to current thread pool-5-thread-1
at org.apache.wicket.Application.get(Application.java:179)
at com.servoy.j2db.server.headlessclient.SessionClient.unsetThreadLocals(SessionClient.java:645)
at com.servoy.j2db.server.headlessclient.SessionClient$3.afterExecute(SessionClient.java:1252)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Which is obviously in a Runnable, but I’m not sure where it is called from.
Also after a try in web client (and the above exception occuring), relaunching Smart client and trying again fail to call the queued method (although the login works) anymore.