Starting the runtime failed (An error occurred while initializing modules) - Input $ could not be parsed

Hi, I'm seeing an error on trying to run our app through the modeller after making some local changes, and haven't yet tracked down the reason.   1) No Java actions have been changed 2) I've tried cleaning the deployment directory 3) I've tried using the default built-in database with the same results 4) I've tried restarting the modeller and the computer running it 5) Due to the quantity of local changes I can't easily revert them, and no recent changes seem to be likely to have caused this (microflow and domain model changes) 6) (Obviously) no errors show in the modeller "Errors" tab    The problem seems to be whilst initializing modules, that some  parameter is missing or empty.  I'm investigating further and searching for clues, but if anyone has any pointers I'd be grateful.   Stack trace and error info: --------------------------------------     An error occurred while initializing modules -------- com.mendix.m2ee.api.AdminException: An error occurred while initializing modules     at com.mendix.core.impl.MxRuntimeImpl.initializeModules( Caused by: com.mendix.systemwideinterfaces.MendixRuntimeException: Input '$' could not be parsed Error on line 1 character 1: mismatched character '<EOF>' expecting set null     at com.mendix.languages.ASTBuilder$class.processRecognitionExceptions(ASTBuilder.scala:33)     at com.mendix.languages.ASTBuilder$class.process$1(ASTBuilder.scala:14)     at com.mendix.languages.ASTBuilder$$anonfun$processRecognitionExceptions$1.apply(ASTBuilder.scala:17)     at com.mendix.languages.ASTBuilder$$anonfun$processRecognitionExceptions$1.apply(ASTBuilder.scala:16)     at scala.collection.immutable.List.foreach(List.scala:383)     at com.mendix.languages.ASTBuilder$class.processRecognitionExceptions(ASTBuilder.scala:16)     at com.mendix.languages.mxexpressions.MxExpressionASTBuilder.processRecognitionExceptions(MxExpressionASTBuilder.scala:9)     at com.mendix.languages.mxexpressions.MxExpressionASTBuilder.buildMxExpressionAST(MxExpressionASTBuilder.scala:18)     at com.mendix.languages.LanguageParser$.parseMxExpression(LanguageParser.scala:16)     at com.mendix.languages.LanguageParser.parseMxExpression(LanguageParser.scala)     at com.mendix.modules.microflowengine.microflowstructure.MicroflowStructureFactory.processEventWithIncomingFlows(     at com.mendix.modules.microflowengine.microflowstructure.MicroflowStructureFactory.createMicroflowStructure(     at com.mendix.modules.microflowengine.internal.MicroflowEngineModuleImpl$$anonfun$2.apply(MicroflowEngineModuleImpl.scala:34)     at com.mendix.modules.microflowengine.internal.MicroflowEngineModuleImpl$$anonfun$2.apply(MicroflowEngineModuleImpl.scala:33)     at scala.collection.TraversableLike$WithFilter$$anonfun$map$2.apply(TraversableLike.scala:728)     at scala.collection.Iterator$class.foreach(Iterator.scala:743)     at scala.collection.AbstractIterator.foreach(Iterator.scala:1174)     at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)     at scala.collection.AbstractIterable.foreach(Iterable.scala:54)     at scala.collection.TraversableLike$     at com.mendix.modules.microflowengine.internal.MicroflowEngineModuleImpl.initMicroflowStructures(MicroflowEngineModuleImpl.scala:33)     at com.mendix.modules.microflowengine.internal.MicroflowEngineModuleImpl.initialize(MicroflowEngineModuleImpl.scala:28)     at com.mendix.core.impl.MxRuntimeImpl.initializeModules(     at com.mendix.core.impl.MxRuntimeImpl.doFire(     at com.mendix.core.impl.MxRuntimeImpl.fireZeeMissile(     at com.mendix.core.impl.MxRuntimeImpl.start(     at com.mendix.core.impl.MxRuntimeImpl.start(     at com.mendix.m2ee.appcontainer.actions.StartAction.startRuntime(     at com.mendix.m2ee.appcontainer.actions.StartAction.execute(     at com.mendix.m2ee.appcontainer.server.handler.HttpAdminHandler.handle(     at org.eclipse.jetty.server.handler.HandlerWrapper.handle(     at org.eclipse.jetty.server.Server.handle(     at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(     at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(     at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(     at org.eclipse.jetty.http.HttpParser.parseNext(     at org.eclipse.jetty.http.HttpParser.parseAvailable(     at org.eclipse.jetty.server.AsyncHttpConnection.handle(     at     at$     at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(     at org.eclipse.jetty.util.thread.QueuedThreadPool$     at  
3 answers

I managed to track it down to the return value of one microflow. At a previous stage I'd had a return value for it, but removed the returned value, and set it to return Nothing (The microflow isn't currently called from anywhere but is work in progress.)


Changing it to return a value allowed the application to start up. Subsequently changing it back to return Nothing resolved the issue.


I think there's a possible bug in code generation in the modeller where after changing it, the return type or value of a microflow can get out of sync with the generated code. It appears this can cause runtime errors without showing modeller errors in some cases. 


For anyone else who comes across this issue, try the above solution.


From the stacktrace it seems as if you have just a $ somewhere in your expression.  I don't know why the modeler wouldn't give a consistency error about this.

To resolve it I would try and search the modeler for the text '$ ' (so the dollar sign followed by a white space). Hopefully you have an expression somewhere that says $ > 5  which is obviously invalid. If that doesn't work I would recommend searching on just the $ sign without the whitespace, this is obviously a lot of work, but I can't thing of many other ways to find the issue.


As an alternative you could try and start your application with TRACE logging enabled, this might print which microflow it was evaluating just before it gives you this exception.


Thanks Jasper, that's a great suggestion. I'd assumed that it would show as a consistency error if it were an issue in an expression I'd changed, but I can check that, as it's certainly possible I've made typos or failed to provide defaults properly whilst refactoring


So far, enabling TRACE debugging hangs with a spinner, and it doesn't show up with a search for "$ ". The search for "$" shows up 15000 results so that may not be feasible, but I can definitely check my recent changes.