Weird "Could not eval the string" error

I have a form in a web client solution with an html area for a global variable that contains a link to a form method, eg.

New Applicant? Click here to set up your account

The method register() closes the existing solution and opens another, eg:

function register()
{
application.closeSolution(‘register’);
}

Clicking on the link in the form fires the register() method and it seems to function ok most of the time, eg. the register solution opens, but an error is thrown whenever the link is clicked:

com.servoy.j2db.util.Debug Could not eval the string ‘register()’

The troublesome thing is that about 20% of the time the application.closeSolution in the function doesn’t fire - the new solution won’t open and the screen from the first solution remains displayed in the browser. I’ve tried moving the register() method to a global method, and even changed its name - but I still get the error – it is complaining about the name of the method.

Anybody have an idea of what’s going on?

Servoy 4.1.4 - build 681. The stack trace follows;

org.mozilla.javascript.WrappedException: Wrapped com.servoy.j2db.ExitScriptException: Solution closed (register#3) at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1828) at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:199) at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:347) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3666) at script.register(register:3) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2680) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:166) at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:101) at org.mozilla.javascript.gen.c1._c0(internal_anon:1) at org.mozilla.javascript.gen.c1.call(internal_anon) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:387) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3125) at org.mozilla.javascript.gen.c1.call(internal_anon) at org.mozilla.javascript.gen.c1.exec(internal_anon) at org.mozilla.javascript.Context.evaluateString(Context.java:1233) at com.servoy.j2db.FormController.eval(FormController.java:1067) at com.servoy.j2db.server.headlessclient.dataui.InlineScriptExecutorBehavior.respond(InlineScriptExecutorBehavior.java:2) at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:297) at org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:104) at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:91) at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1239) at org.apache.wicket.RequestCycle.step(RequestCycle.java:1316) at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1418) at org.apache.wicket.RequestCycle.request(RequestCycle.java:532) at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:356) at org.apache.wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:124) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 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:230) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:636) Caused by: com.servoy.j2db.ExitScriptException: Solution closed at com.servoy.j2db.scripting.JSApplication.js_closeSolution(JSApplication.java:796) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:179) … 39 more

Can you add an issue about this in our system ? (and please attach a sample)

Laurian,

Could it be related to the bug #243284 that has been fixed recently and which will be included in the next release?

Martin

I don’t see any NPE error in the provided log (so, doesn’t seem related to case). This seems to be a timing issue, it tries to eval something when solution is already closed. But not sure if this is the root of the problem.

Issue posted - case 244584.

Thanks!

I am not convinced this is a timing issue as the following presents the same problem and there is no close function be called

/**

  • @properties={typeid:35,uuid:“0a8442ec-654b-4444-8197-d1b0ea8ff66f”}
    */
    var navHtml = null;

/**

  • @properties={typeid:24,uuid:“7b6e20f3-989b-4ab7-8655-b2b40b3d6005”}
    */
    function test1()
    {

navHtml = ‘’;
navHtml += ‘’;
navHtml += ‘a {color:#999999; text-decoration: none; font-size: 12px; font-weight:450;}’;
navHtml += ‘a:hover {color:#717171}’;
navHtml += ‘a.on {color:#363636; font-weight:bold }’;
//navHtml += ‘a:link{color:#000000}’;
navHtml += ‘’;

var testVar = ‘Trains’;

navHtml += ‘<a ‘;
navHtml += ‘class=“on”’;
navHtml += ’ href="javascript:navAction(’+testVar+’)">';
navHtml += ‘Trains’;
navHtml += ‘’;
navHtml += ’   ';
navHtml += '<a ‘;
navHtml += ‘class=“on”’;
navHtml += ’ href=“javascript:navAction(2)”>’;
navHtml += ‘Cars’;
navHtml += ‘’;
navHtml += ‘’;

}

/**

  • @properties={typeid:24,uuid:“ae6695ba-d660-4103-8229-280644a43bd4”}
    */
    function navAction()
    {
    application.output(arguments[0]);
    }

/**

  • @properties={typeid:24,uuid:“6b039962-a0eb-4b6a-9572-1c6ed549191f”}
    */
    function test2()
    {
    navAction(‘Trains’);
    }

The output on Test1 throws the error for the string ‘Trains’ from the var testVar while the cars link works no problem with the numeric

The Test2 outputs the word ‘Triains’ as expected in the navAction script

Overall there does seem to be a bug in the way that the string is handled by the embedded JavaScript call in the html

Cheers
Gordon

you are forgetting quotes:

test1() and test2() are not generating the same call…

this:

navHtml += ’ href=“javascript:navAction(‘+testVar+’)”>';

is not

navAction(‘Trains’);

this is the same:

navHtml += ’ href=“javascript:navAction('‘+testVar+’')”>';

Thank you for clarifying this

Gordon

We have similar issues in our solution. Both in 4.x and Tano.
It always happens on the link to a method that does the closeSolution. For other methods, it is not so easy to reproduce but is does occur from time to time with similar results as described by Gordon. In our case, when the problem occurs it sometimes persist from that point on until you restart the session.