Can't use the dialog plugin in a none Swing thread/environme

Forum to discuss the Web client version of Servoy.

Can't use the dialog plugin in a none Swing thread/environme

Postby bobm » Tue Dec 20, 2016 2:57 pm

All of a sudden I am getting the following message when running the Web Client and closing a popup.
org.mozilla.javascript.WrappedException: Wrapped java.lang.RuntimeException: Can't use the dialog plugin in a none Swing thread/environment (exitProgram#557)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1815)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:180)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:311)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1768)
at script.exitProgram(exitProgram:557)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:837)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:158)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:406)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3192)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:156)
at com.servoy.j2db.scripting.ScriptEngine.executeFunction(ScriptEngine.java:574)
at com.servoy.j2db.scripting.ScopesScope.executeGlobalFunction(ScopesScope.java:172)
at com.servoy.j2db.ClientState.callCloseSolutionMethod(ClientState.java:1267)
at com.servoy.j2db.ClientState.closeSolution(ClientState.java:1163)
at com.servoy.j2db.server.headlessclient.WebClient.closeSolution(WebClient.java:758)
at com.servoy.j2db.ClientState.shutDown(ClientState.java:1039)
at com.servoy.j2db.server.headlessclient.SessionClient.shutDown(SessionClient.java:346)
at com.servoy.j2db.server.headlessclient.WebClient.shutDown(WebClient.java:645)
at com.servoy.j2db.server.headlessclient.SessionClient.valueUnbound(SessionClient.java:458)
at org.apache.catalina.session.StandardSession.removeAttributeInternal(StandardSession.java:1686)
at org.apache.catalina.session.StandardSession.expire(StandardSession.java:801)
at org.apache.catalina.session.StandardSession.isValid(StandardSession.java:576)
at org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:712)
at org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:697)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1364)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1649)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1658)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1658)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1638)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Can't use the dialog plugin in a none Swing thread/environment
at com.servoy.extensions.plugins.dialog.DialogProvider.js_showDialogEx(DialogProvider.java:231)
at com.servoy.extensions.plugins.dialog.DialogProvider.js_showQuestionDialog(DialogProvider.java:211)
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:158)


I've followed this thread (viewtopic.php?f=34&t=11885) and am using the recommended Dialogs Module - any suggestions??

Thanks,
Bob
Bob Mezzadri
EyeCOR By Nteon
bobm
 
Posts: 67
Joined: Thu Dec 29, 2011 8:24 pm

Re: Can't use the dialog plugin in a none Swing thread/envir

Postby patrick » Tue Dec 20, 2016 3:49 pm

exitProgram sounds like you are in a method that closes the solution? I have seen some issues with that before. Can you explain a bit what that method does?
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3598
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Can't use the dialog plugin in a none Swing thread/envir

Postby bobm » Tue Dec 20, 2016 4:12 pm

Patrick,
I get this error each time any popup window is closed. The command is whatever the default is when closing a dialog box with the "X" close for the window default.
On the popup windows I have a close option on I am using "_window.destroy()" - to close that window.

The client sees the following message: "TypeError: startWindow.triggerAjaxUpdate is not a function"
This is not happening through developer - only on the live server. After this message is closed the system continues to function normally.

Bob
Bob Mezzadri
EyeCOR By Nteon
bobm
 
Posts: 67
Joined: Thu Dec 29, 2011 8:24 pm

Re: Can't use the dialog plugin in a none Swing thread/envir

Postby patrick » Tue Dec 20, 2016 4:20 pm

Looking closer at your error it seems that somehow you are really using the dialog plugin here. The dialogs module should be using a form and not the swing dialog plugin. Please share some code of where this goes wrong.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3598
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Can't use the dialog plugin in a none Swing thread/envir

Postby bobm » Tue Dec 20, 2016 4:38 pm

Patrick,
Following the close command through debugger the only code it is reaching is in a comModelViewControllerBase.js and is:
Code: Select all
function onHide(event) {
   isVisible = false;
   return true
}


The mod_dialog we are using is version 1.1.1 from: https://www.servoyforge.net/projects/mod-dialog
Bob Mezzadri
EyeCOR By Nteon
bobm
 
Posts: 67
Joined: Thu Dec 29, 2011 8:24 pm

Re: Can't use the dialog plugin in a none Swing thread/envir

Postby patrick » Tue Dec 20, 2016 4:51 pm

I'm still not with you in terms of what you are doing. It looks like you are using the showFormInModalDialog method? I am interested in the code you have that shows the dialog...

Also interesting that you originally said this happens "all of a sudden". What has changed?

And also I understood that despite of that error log, everything works normal?

I also don't understand what you mean by
On the popup windows I have a close option on I am using "_window.destroy()" - to close that window
. As far as I know mod_dialog, it can show a dialog and once the users closes that, your code continues. So I don't really get where, how and why you do your _window.destroy(). Code example would shed some light on this, I hope. Sorry for being a bit slow maybe today...
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3598
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Can't use the dialog plugin in a none Swing thread/envir

Postby bobm » Tue Dec 20, 2016 5:01 pm

I noticed this started shortly after we added a new certificate for the java security.
Here is an example of the code that opens one of the popups.

Code: Select all
/**
* @param {JSEvent} _event
* @param {String} _title
* @param {String} _field name of field to show
* @properties={typeid:24,uuid:"EC7FBE7A-4494-408D-8BA6-D879E30CF792"}
*/
function showNoteInDialog(_event, _title, _field) {
   var _form = _event.getFormName()
   var _note = forms[_form][_field]
   //Method call
   forms.notesDetail.show(_title, _note)
}

/**
* @param {String} _title
* @param {String} _note
* @properties={typeid:24,uuid:"B796AE70-5C77-4CAF-B875-2F775D3B0E60"}
*/
function show(_title, _note) {
   
   note = _note
   
   if(!_title) _title = 'Details of the note'

   if(!window)
      window = application.createWindow("note", JSWindow.DIALOG);
   window.title = _title;
   controller.show(window);
   
}

Bob Mezzadri
EyeCOR By Nteon
bobm
 
Posts: 67
Joined: Thu Dec 29, 2011 8:24 pm

Re: Can't use the dialog plugin in a none Swing thread/envir

Postby patrick » Tue Dec 20, 2016 6:19 pm

Where in this code snippet do you use mod_dialogs? This is just a plain servoy window!? And why do you store the window created in a variable called "window"? Usually what you would do looks something like this:

Code: Select all
var window = application.getWindow('note');
if (!window) {
   //doesn't exist yet
   window = application.createWindow('note', JSWindow.DIALOG);
}
window.title = _title;
window.show(controller.getName());


This window is reusable (doesn't have to be recreated) until destroyed. No need to store it in any variable, you can reference it any time by its name ('note').

I can't test right now if closing this window will throw this error, but would think that we'd have this reported more often if it did.

Your error, however, seems to come from this kind of call

Code: Select all
plugins.dialogs.showXyDialog(...)


as far as I can see, and not from the window that you create in your code snippet.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3598
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Can't use the dialog plugin in a none Swing thread/envir

Postby bobm » Tue Dec 20, 2016 8:03 pm

Patrick thanks

Here is my question.
I understand that the Variable Window is being used.
You also made a minor change to the code for var window
The first time through the if test

Code: Select all
var window = application.getWindow('note');
if (!window) {       
   //doesn't exist yet   
Here if the var window is null then create in window

Code: Select all
   window = application.createWindow('note', JSWindow.DIALOG);
}
window.title = _title;
window.show(controller.getName());


See comments below
Then when the window is closed either with X or "Close" in the window. The window is simply hidden. Code:
Code: Select all
function onHide(event) {
   isVisible = false;
   return true
}

Immediately opening the window a second time re-executes the same code above.
However, even though the windows was only hidden, the value of window is again null.
then the window is created again. Which i believe is causing the ultimate error.

Would the solution (instead of the onHide event) be to Close or kill the window so if recreated it still would be the only copy.
Bob Mezzadri
EyeCOR By Nteon
bobm
 
Posts: 67
Joined: Thu Dec 29, 2011 8:24 pm

Re: Can't use the dialog plugin in a none Swing thread/envir

Postby patrick » Wed Dec 21, 2016 3:50 pm

We are going from one thing to another... I find it strange that you say that getWindow('note') doesn't return a window after you have gone through that once before. But even if, it doesn't matter, does it? The window will be created again and all is fine.

Btw: when you say "The window is simply hidden. Code:" that is not quite right. The window is not hidden by that code, but by the user hitting the close box. onHide is an event, not a method of a form. It will be fired any time a form disappears on screen, either by closing a window that shows it or by navigating to another form. To close the window programatically, you would do something like

application.getWindow('note').hide()

Your original question was where that error comes from and I still have the impression it comes from a call of plugins.dialog, as I said before. We are now discussing completely different things...
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3598
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Can't use the dialog plugin in a none Swing thread/envir

Postby bobm » Wed Dec 21, 2016 10:41 pm

Patrick,

Sorry for all the confusion, but it looks as if I have two separate issues happening here.

1: is the plugin.dialog error I first posted about
2: is an error I get when a dialog box is closed when running the web-client live.

I was confusing the two because I would CLOSE the web-client after the on screen error, THEN look at the server log

So this issue was due to an exit message with a dialog-box
Code: Select all
function exitProgram(event){
      var msg = 'You are about to close EyeCOR, are you sure?'
      var confirm = plugins.dialogs.showQuestionDialog('Exit EyeCOR',msg,'Yes', 'No');
      if (confirm != 'Yes'){
         return false;
   }
}

Commented that out and the error stops. Easy solution = no exit confirmation.

Thank you very much for all your help on this. Now to post help for the second issue.
Thanks again your comments/suggestions were a big help.
Bob Mezzadri
EyeCOR By Nteon
bobm
 
Posts: 67
Joined: Thu Dec 29, 2011 8:24 pm


Return to Servoy Web Client

Who is online

Users browsing this forum: No registered users and 1 guest