Headless Client shutdown

Hey guys!

I have a webclient solution that creates a headless client with another solution to calculate something without blocking the interface.

How do I close the headless client after the calculation is over? I have now lot of headless clients in the list which does nothing. On the callback in the webclient solution, if I call shutdown on the headless client reference, I’ll get an strange error and the webpage will go offline.

Thanks a lot!
Bogdan.

in the end, do: application.exit()

At the end of the method in the headless client I tried: application.closeSolution();, but then the callback response would be of type exception. I’ll try exit and see how it behave.

It’s not working with application.exit().

I receive on the callback

JSEvent(type = headlessExceptionCallback …

and also in the log I can see:

Error calling method generateInvoicesForFlight, context: null on client FC69E03D-4DC8-470E-A806-C19C6B3D48CA

, which is quite strange because this is the method in the headless client that is executed:

function generateInvoicesForFlight(userLoginId, flightId, invoiceOnSave) {
	if (!globals.userLogin(userLoginId)) {
		return;
	}

	globals.databaseStartTransaction();
	forms.commons_logbook.generateInvoices(flightId, invoiceOnSave);
	globals.databaseCommit();

	application.exit();
}

Removing application.exit(); from the end will make things work. But the client remains open.

Any other solution? Btw, I’m using Servoy 5.2. Please don’t ask me to switch to a newer one…

You can close the HC in the callback method of the calling client:

if(event.getType() == JSClient.CALLBACK_EXCEPTION_EVENT)
	{
		application.setStatusText(null)
		application.output(application.getServerTimeStamp()+" WARNING! totalizeCallback: Exception callback, name: " + event.data,LOGGINGLEVEL.ERROR);
		// Kill the HC
		_hc.shutdown(true)
		return;
	}
	
	if(event.getType() == JSClient.CALLBACK_EVENT)
	{
		var _log = event.data
                .....
		// Kill the HC
		_hc.shutdown(true)
         }

Hi Nicola,

Thanks for answering.

I tried that as well, but then the user gets the error screen in the browser, I could see a wicket exception in the log, and he needs to refresh the page to get to the app again.

Kind Regards,
Bogdan.

It works fine for me, what wicket error do you get?

It was different last time, but now I’ve added the force argument. And I still get the error page.

org.apache.wicket.WicketRuntimeException: Exception in rendering component: LABEL(web)[name:btn_delete,x:736,y:0,width:24,height:23,label:] 
    	at org.apache.wicket.Component.renderComponent(Component.java:2764) 
    	at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1559) 
    	at com.servoy.j2db.server.headlessclient.dataui.WebBaseSubmitLink.onRender(WebBaseSubmitLink.java:179) 
    	at org.apache.wicket.Component.render(Component.java:2525) 
    	at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1461) 
    	at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1624) 
    	at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1548) 
    	at org.apache.wicket.Component.renderComponent(Component.java:2725) 
    	at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1559) 
    	at com.servoy.j2db.server.headlessclient.dataui.WebDataRenderer.onRender(WebDataRenderer.java:422) 
    	at org.apache.wicket.Component.render(Component.java:2525) 
    	at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1461) 
    	at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1624) 
    	at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1548) 
    	at org.apache.wicket.Component.renderComponent(Component.java:2725) 
    	at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1559) 
    	at org.apache.wicket.Component.render(Component.java:2525) 
    	at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1461) 
    	at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1624) 
    	at org.apache.wicket.MarkupContainer.renderAssociatedMarkup(MarkupContainer.java:717) 
    	at org.apache.wicket.markup.html.panel.Panel.onComponentTagBody(Panel.java:114) 
    	at org.apache.wicket.Component.renderComponent(Component.java:2725) 
    	at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1559) 
    	at org.apache.wicket.Component.render(Component.java:2525) 
    	at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1461) 
    	at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1624) 
    	at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1548) 
    	at org.apache.wicket.Component.renderComponent(Component.java:2725) 
    	at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1559) 
    	at com.servoy.j2db.server.headlessclient.dataui.WebTabPanel.onRender(WebTabPanel.java:476) 
    	at org.apache.wicket.Component.render(Component.java:2525) 
    	at org.apache.wicket.Component.renderComponent(Component.java:2666) 
    	at org.apache.wicket.ajax.AjaxRequestTarget.respondComponent(AjaxRequestTarget.java:876) 
    	at org.apache.wicket.ajax.AjaxRequestTarget.respondComponents(AjaxRequestTarget.java:680) 
    	at org.apache.wicket.ajax.AjaxRequestTarget.respond(AjaxRequestTarget.java:590) 
    	at org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:105) 
    	at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1260) 
    	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:9) 
    	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) 
    Caused by: java.lang.NullPointerException 
    	at com.servoy.j2db.server.headlessclient.dataui.WebBaseSubmitLink$2.getObject(WebBaseSubmitLink.java:393) 
    	at com.servoy.j2db.server.headlessclient.dataui.WebBaseSubmitLink$2.getObject(WebBaseSubmitLink.java:1) 
    	at org.apache.wicket.model.Model.getObject(Model.java:1) 
    	at org.apache.wicket.AttributeModifier.getReplacementOrNull(AttributeModifier.java:378) 
    	at org.apache.wicket.AttributeModifier.replaceAttributeValue(AttributeModifier.java:280) 
    	at org.apache.wicket.AttributeModifier.onComponentTag(AttributeModifier.java:243) 
    	at org.apache.wicket.Component.renderComponentTag(Component.java:4305) 
    	at org.apache.wicket.Component.renderComponent(Component.java:2716) 
    	... 57 more

Weird.
You should try to reproduce it within a very simple sample solution and create a case in the support system.