HeadlessException

Forum to discuss the Web client version of Servoy.

HeadlessException

Postby maria » Sat Dec 17, 2011 6:02 am

Hi Guys,

We have a webclient application that uses a plugin to pop up a java bean with canvas to capture the user signature from a signature pad.
In Developer everything works perfectly fine. However when I deploy it on a remote server and run on a different machine then an exception prevent my bean from execution:

I understand there's not much detail here about the environment and everything but I'm not sure what info I should be looking at/providing.
Perhaps this is familiar to someone and that someone could figure out where I'm coming from?

Thanks guys.

Code: Select all
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 com.tsm.servoy.plugins.signplus.SignPlusScreen.<init>(SignPlusScreen.java:42)
       at com.tsm.servoy.plugins.signplus.SignPlusPluginProvider.js_launchSignPlus(SignPlusPluginProvider.java:76)
       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:353)
       at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3666)
       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:3135)
       at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:165)
       at com.servoy.j2db.scripting.ScriptEngine.executeFunction(ScriptEngine.java:476)
       at com.servoy.j2db.FormController.executeFunction(FormController.java:3982)
       at com.servoy.j2db.FormController.executeFunction(FormController.java:3870)
       at com.servoy.j2db.FormController.executeFunction(FormController.java:3792)
       at com.servoy.j2db.FormController$ScriptExecuter.executeFunction(FormController.java:3647)
       at com.servoy.j2db.ui.BaseEventExecutor.fireEventCommand(BaseEventExecutor.java:272)
       at com.servoy.j2db.ui.BaseEventExecutor.fireActionCommand(BaseEventExecutor.java:217)
       at com.servoy.j2db.server.headlessclient.dataui.WebEventExecutor.onEvent(WebEventExecutor.java:364)
       at com.servoy.j2db.server.headlessclient.dataui.WebEventExecutor$2.onEvent(WebEventExecutor.java:168)
       at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:177)
       at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:302)
       at org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:157)
       at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
       at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1252)
       at org.apache.wicket.RequestCycle.step(RequestCycle.java:1331)
       at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1438)
       at org.apache.wicket.RequestCycle.request(RequestCycle.java:546)
       at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
       at com.servoy.j2db.server.servlets.Zl.doGet(Zl.java:5)
       at org.apache.wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:138)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:567)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
       at java.lang.Thread.run(Unknown Source)



Cheers,
Maria
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney

Re: HeadlessException

Postby ptalbot » Sat Dec 17, 2011 7:28 am

You get a HeadlessException because your bean is instantiated on the server side, where the server is run in a headless environment (meaning no UI). Understand that you cannot instantiate a bean in a web client: a browser is not a Java client!
You can eventually create an Applet and wrap an Wicket component around it to deliver it to the web client.

When you see this working in Developer this is because your web client and your server are running on the same machine in the context of the Eclipse developer JVM so you have the illusion that this is working!
Please review my article on ServoyForge about where your code is executed to better understand that: https://www.servoyforge.net/projects/ar ... eExecution

If you want to retrieve a signature from a web client, have a look at my DrawBean on ServoyForge: https://www.servoyforge.net/projects/drawbean

You will be able to achieve what you want to do it with this bean because this bean runs in web client as an Applet delivered by a Wicket wrapper. Have a look at the code if you want (it's available in the project repository) and you will see that the bean is in fact 2 components: 1 regular Swing bean and one Wicket component.

Hope this helps.
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: HeadlessException

Postby maria » Sun Dec 18, 2011 3:49 pm

ptalbot wrote:You get a HeadlessException because your bean is instantiated on the server side, where the server is run in a headless environment (meaning no UI). Understand that you cannot instantiate a bean in a web client: a browser is not a Java client!
You can eventually create an Applet and wrap an Wicket component around it to deliver it to the web client.

When you see this working in Developer this is because your web client and your server are running on the same machine in the context of the Eclipse developer JVM so you have the illusion that this is working!
Please review my article on ServoyForge about where your code is executed to better understand that: https://www.servoyforge.net/projects/ar ... eExecution

If you want to retrieve a signature from a web client, have a look at my DrawBean on ServoyForge: https://www.servoyforge.net/projects/drawbean

You will be able to achieve what you want to do it with this bean because this bean runs in web client as an Applet delivered by a Wicket wrapper. Have a look at the code if you want (it's available in the project repository) and you will see that the bean is in fact 2 components: 1 regular Swing bean and one Wicket component.

Hope this helps.


Hi Patrick.

Thanks a lot for your post and the links, understanding how things work is important.
Patrick, the DrawBean has been successfully used in one of our solutions to capture signatures. However, one of the customers changed the hardware to Topaz signature pads and they aren't working with the bean :(
Would you happen to know why and how hard it is to fix?

The company that makes that signature pad (http://www.topazsystems.com/) provides a Java plugin and I thought it might be easier to just use it.
Please share your thoughts on this.

Cheers,
Maria

Patrick, would you be able to quickly have a look at the company site
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney

Re: HeadlessException

Postby ptalbot » Sun Dec 18, 2011 9:07 pm

It seems that this signature pad is not a regular input device: meaning it doesn't emulate the mouse so the DrawBean cannot work with it because it is expecting a regular mouse (or pad) input. I suppose you cannot use this signature pad in a drawing software as well, can you?

If you look at the signplus SDK, you'll see that its bean is communicating with the device using the RXTX java library on a serial port.
For a Topaz USB version, it also uses a SigUsb.dll (for 32 or 64 bit) that you need to install on your client as well (and have a VC++ 2008 or 2010 redistributable as well). There is an applet version but for this one you will also need to grant extra permission, thus having it signed properly... And for the Topaz USB the same requirements apply for the applet as well.

I could have a look at building a bean with these components if you want because right now you will not be able to use the bean or applet as-is in your Servoy application, they are just not meant for it. A Servoy bean would be wrapping both the bean (for smart clients) and the applet (for web clients) and will work with the API to get the result back to Servoy using callback methods.
Just contact me in PM if you need me to have a further look...
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: HeadlessException

Postby maria » Tue Dec 20, 2011 2:32 am

ptalbot wrote:It seems that this signature pad is not a regular input device: meaning it doesn't emulate the mouse so the DrawBean cannot work with it because it is expecting a regular mouse (or pad) input. I suppose you cannot use this signature pad in a drawing software as well, can you?

If you look at the signplus SDK, you'll see that its bean is communicating with the device using the RXTX java library on a serial port.
For a Topaz USB version, it also uses a SigUsb.dll (for 32 or 64 bit) that you need to install on your client as well (and have a VC++ 2008 or 2010 redistributable as well). There is an applet version but for this one you will also need to grant extra permission, thus having it signed properly... And for the Topaz USB the same requirements apply for the applet as well.

I could have a look at building a bean with these components if you want because right now you will not be able to use the bean or applet as-is in your Servoy application, they are just not meant for it. A Servoy bean would be wrapping both the bean (for smart clients) and the applet (for web clients) and will work with the API to get the result back to Servoy using callback methods.
Just contact me in PM if you need me to have a further look...


Thanks heaps, Patrick.
Looks like the effort is not worth the gain for us in this one.
Still appreciate the educational bits of your posts! Will come in handy in future for sure.

Cheers,
Maria
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney

Re: HeadlessException

Postby ptalbot » Tue Dec 20, 2011 3:17 am

No problem. Glad to help.
Cheers,
-Patrick
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC


Return to Servoy Web Client

Who is online

Users browsing this forum: No registered users and 9 guests

cron