Catching messages thrown by classes in a lower level - scala

There are four levels in my application: (1) My application, (2) pivot4j, (3) olap4j, and (4) Mondrian
If I run this code in Scala:
try {
renderer.render(model, new HtmlRenderCallback(sw))
}
catch {
case ex: Exception => println(ex.getMessage)
}
The application prints the error thrown by pivot4j:
org.olap4j.OlapException: mondrian gave exception while parsing query
If I don't catch the error, the stack trace is (in bold the relevant messages):
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution
exception[[PivotException: org.olap4j.OlapException: mondrian gave
exception while parsing query]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:293)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:220)
at play.api.GlobalSettings$class.onError(GlobalSettings.scala:160)
at play.api.DefaultGlobal$.onError(GlobalSettings.scala:188)
at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:100)
at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:100)
at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:99)
at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:346)
at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:345)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:36) Caused
by: org.pivot4j.PivotException: org.olap4j.OlapException: mondrian
gave exception while parsing query
at org.pivot4j.impl.PivotModelImpl.getCellSet(PivotModelImpl.java:598)
at org.pivot4j.ui.table.TableRenderer.render(TableRenderer.java:425)
at olap.process.RunOlap.doRunMdx(RunOlap.scala:91)
at olap.process.RunOlap$$anonfun$runMdx$1.apply(RunOlap.scala:53)
at olap.process.RunOlap$$anonfun$runMdx$1.apply(RunOlap.scala:51)
at login.Authentication$LoggedAction$$anonfun$invokeBlock$1.apply(LoggedAction.scala:47)
at login.Authentication$LoggedAction$$anonfun$invokeBlock$1.apply(LoggedAction.scala:42)
at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:253)
at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:36) Caused
by: org.olap4j.OlapException: mondrian gave exception while parsing
query
at mondrian.olap4j.MondrianOlap4jConnection$Helper.createException(MondrianOlap4jConnection.java:858)
at mondrian.olap4j.MondrianOlap4jStatement.parseQuery(MondrianOlap4jStatement.java:375)
at mondrian.olap4j.MondrianOlap4jStatement.executeOlapQuery(MondrianOlap4jStatement.java:346)
at org.pivot4j.impl.PivotModelImpl.executeMdx(PivotModelImpl.java:646)
at org.pivot4j.impl.PivotModelImpl.getCellSet(PivotModelImpl.java:596)
at org.pivot4j.ui.table.TableRenderer.render(TableRenderer.java:425)
at olap.process.RunOlap.doRunMdx(RunOlap.scala:91)
at olap.process.RunOlap$$anonfun$runMdx$1.apply(RunOlap.scala:53)
at olap.process.RunOlap$$anonfun$runMdx$1.apply(RunOlap.scala:51)
at login.Authentication$LoggedAction$$anonfun$invokeBlock$1.apply(LoggedAction.scala:47)
Caused by: mondrian.olap.MondrianException: Mondrian Error: MDX object '[Measures].[Unit Cost]' not found in cube 'Sales'
Mondrian is the one that is originating the error, and I need to get the message that is throwing:
MDX object '[Measures].[Unit Cost]' not found in cube 'Sales'
I tried:
try {
renderer.render(model, new HtmlRenderCallback(sw))
}
catch {
case ex: MondrianException => println(ex.getMessage)
}
But is not catching the error.

Use Apache Commons ExceptionUtils to get the root exception.

Related

Spark cannot catch Size exceeds Integer.MAX_VALUE error exception?

I get this Exception while making repartition operation(decreasing partition size).
Caused by: java.lang.IllegalArgumentException: Size exceeds Integer.MAX_VALUE
While trying to catch this exception somehow below try-catch block doesn't work. It didn't catch the exception.
try{
someDF.repartition(10)
.persist(StorageLevel.MEMORY_AND_DISK)
.write.mode("overwrite").format(format).save(temp_location)
}
catch {
case ex: java.lang.IllegalArgumentException => {
// Do something else
}
But if I make exception type more generic it started to catch exception.
try{
someDF.repartition(10)
.persist(StorageLevel.MEMORY_AND_DISK)
.write.mode("overwrite").format(format).save(temp_location)
}
catch {
case ex: Exception => {
// Do something else
}
So what is the reason behind it?
Does spark somehow throw an other exception internally, different than written as error message?
Note "caused by" in the exception message; it means IllegalArgumentException is the cause of the exception and you should look at the stack trace before it for the exception class and message itself. It'll look like
Exception in thread "<thread-name>" <exception-class>: <message>
See also Setting Exception cause in java which gives this example stack trace:
Exception in thread "main" java.lang.RuntimeException: Some other message
at Exceptions.main(Exceptions.java:4)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.RuntimeException: Some message
at Exceptions.main(Exceptions.java:3)
... 5 more

Media type separator is missing

Please help as I don't know what is wrong here. I have a very simple REST GET service but I keep running into the error below:
#GET
#Path("users/{id}")
#Produces("text/plain")
public Response getUserById(#PathParam("id") String id) {
return Response.status(200).entity("getUserById is called, id : " + id).build();
}
And the exception I'm seeing is below:
[ERROR ] SRVE0315E: An exception occurred: java.lang.Throwable: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:5000)
at [internal classes]
Caused by: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:401)
... 1 more
Caused by: java.lang.IllegalArgumentException: Media type separator is missing
at org.apache.cxf.jaxrs.impl.MediaTypeHeaderProvider.handleMediaTypeWithoutSubtype(MediaTypeHeaderProvider.java:196)
... 1 more
Any idea what is wrong here? TIA

Logback no ExceptionInInitializerError in file only on console

I'm using logback 1.7.5 with play framework 2.2.4, during working I'm getting such error:
Exception in thread "Thread-5" java.lang.ExceptionInInitializerError
at controllers.db.SyncDBManager.createDeviceCollectionsIfNotExists(SyncDBManager.scala)
at server.impl.logic.controller.DeviceInitializer.checkAuthenticationResponse(DeviceInitializer.java:226)
at server.impl.logic.controller.DeviceInitializer.processReceivedFrames(DeviceInitializer.java:117)
at server.impl.logic.controller.DeviceController.onReceivedPackets(DeviceController.java:77)
at server.impl.logic.io.DeviceReader.run(DeviceReader.java:130)
Caused by: java.util.NoSuchElementException: None.get
at scala.None$.get(Option.scala:313)
at scala.None$.get(Option.scala:311)
at controllers.base.MongoSyncHelper$class.$init$(MongoSyncHelper.scala:16)
at controllers.db.SyncDBManager$.<init>(SyncDBManager.scala:32)
at controllers.db.SyncDBManager$.<clinit>(SyncDBManager.scala)
... 5 more
But only on console, how can I catch such exception and write it to file?
Seems like an ordinary stack trace in a console printed with the sysout. Depending on your design if you want to log an exception with the Play logger you should do it in a catch block with one of logger's methods by passing an exception as one of parameters. For example:
try {
// code
} catch {
case e: Exception => play.api.Logger.error("An error occurred", e)
}
The logger level is up to you. If you don't have a catch block and want to log an unexpected exception that occurs in any place of an application you should log it in the Global object by overriding onError method.
override def onError(request: RequestHeader, e: Throwable): Future[SimpleResult] = {
play.api.Logger.error("An error occurred", e)
super.onError(request, e)
}
Remember that onError method is called only in the production mode.

GroovyTemplate of test runner throws exceptions and won't show error detail

Sometimes when a scalatest fails, Play test framework does not report the cause of the failure, instead I see the following. Any ideas why?
Reporter completed abruptly with an exception after receiving event:
TestFailed(org.scalatest.events.Ordinal#6db,java.util.NoSuchElementException,AsgUpdateActorTest,Some(com.netflix.tachyon.nac.AsgUpdateActorTest),parse xml,Some(java.util.NoSuchElementException),Some(42),None,Some(<function7>),None,play-thread-1,1324496590792).
java.lang.NullPointerException
at play.test.TestEngine$TestResults.add(TestEngine.java:191)
at org.scalatest.tools.PlayReporter.apply(ScalaTestRunner.scala:122)
at org.scalatest.DispatchReporter$$anonfun$1$$anonfun$apply$1$$anonfun$apply$2.apply(DispatchReporter.scala:152)
at org.scalatest.DispatchReporter$$anonfun$1$$anonfun$apply$1$$anonfun$apply$2.apply(DispatchReporter.scala:151)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
at scala.collection.immutable.List.foreach(List.scala:45)
at org.scalatest.DispatchReporter$$anonfun$1$$anonfun$apply$1.apply(DispatchReporter.scala:151)
at org.scalatest.DispatchReporter$$anonfun$1$$anonfun$apply$1.apply(DispatchReporter.scala:101)
at scala.actors.Actor$class.receive(Actor.scala:524)
at scala.actors.Actor$$anon$1.receive(Actor.scala:134)
at scala.actors.Actor$.receive(Actor.scala:189)
at org.scalatest.DispatchReporter$$anonfun$1.apply(DispatchReporter.scala:101)
at org.scalatest.DispatchReporter$$anonfun$1.apply(DispatchReporter.scala:50)
at scala.Function0$class.apply$mcV$sp(Function0.scala:39)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
at scala.actors.Actor$$anon$1.act(Actor.scala:135)
at scala.actors.Reactor$$anonfun$dostart$1.apply(Reactor.scala:222)
at scala.actors.Reactor$$anonfun$dostart$1.apply(Reactor.scala:222)
at scala.actors.ReactorTask.run(ReactorTask.scala:36)
at scala.concurrent.forkjoin.ForkJoinPool$AdaptedRunnable.exec(ForkJoinPool.java:611)
at scala.concurrent.forkjoin.ForkJoinTask.quietlyExec(ForkJoinTask.java:422)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.mainLoop(ForkJoinWorkerThread.java:340)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:325)
11:43:11,038 ERROR ~
#68nef9k71
Cannot ouput XML unit output
Template execution error (In {module:testrunner}/app/views/TestRunner/results-xunit.xml around line 23)
Execution error occured in template {module:testrunner}/app/views/TestRunner/results-xunit.xml. Exception raised was NullPointerException : Cannot invoke method escapeXml() on null object.
play.exceptions.TemplateExecutionException: Cannot invoke method escapeXml() on null object
at play.templates.BaseTemplate.throwException(BaseTemplate.java:86)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:257)
at play.templates.Template.render(Template.java:26)
at play.templates.GroovyTemplate.render(GroovyTemplate.java:187)
at controllers.TestRunner.run(TestRunner.java:79)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:548)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:502)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.NullPointerException: Cannot invoke method escapeXml() on null object
at {module:testrunner}/app/views/TestRunner/results-xunit.xml.(line:23)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:232)
... 9 more
Update:
It happened because of the following exception that the test had triggered. Does the test framework supposed to blow up when a test throws an exception?
java.util.NoSuchElementException
at scala.collection.IterableLike$class.head(IterableLike.scala:101)
at scala.xml.NodeSeq.head(NodeSeq.scala:43)

Drools: Compiling rules (or loading compiled rules) fails with obscure exceptions in JamVM

I'm developing a framework that, as one of its features, enables robots to use a rule based system. We began with Jess as the RBS, and now wanted to implement drools (using Drools 5.2.0 final), which works on our development machines running on OpenJDK 6.
Our robot controller runs ARM Linux and JamVM, previously 1.4.3, but I recently compiled 1.5.4 because it was missing classes needed by drools. After failures, I installed JamVM in a virtual machine using the same configurations as when I compiled it for the controller, and there it failed with the same exceptions.
A little research showed that there are bug reports for Drools + JamVM, but this also means that it generally does work.
When Running the framework with precompiled rules with the following code...
kBase = KnowledgeBaseFactory.newKnowledgeBase();
ObjectInputStream in;
Collection<KnowledgePackage> kpkgs;
try {
in = new ObjectInputStream(Thread.currentThread().getContextClassLoader().getResourceAsStream(
packageFile));
kpkgs = (Collection<KnowledgePackage>) in.readObject();
in.close();
} catch(IOException e) {
throw new DisboticsException("Couldn't read drools knowledge package file!", e);
} catch(ClassNotFoundException e) {
throw new DisboticsException("Drools knowledge package file didn't contain expected instance.", e);
}
kBase.addKnowledgePackages(kpkgs);
kSession = kBase.newStatefulKnowledgeSession();
...I got this exception:
java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:131)
at java.util.AbstractList.add(AbstractList.java:152)
at org.drools.rule.JavaDialectRuntimeData.write(JavaDialectRuntimeData.java:383)
at org.drools.rule.JavaDialectRuntimeData.merge(JavaDialectRuntimeData.java:266)
at org.drools.rule.JavaDialectRuntimeData.clone(JavaDialectRuntimeData.java:251)
at org.drools.rule.DialectRuntimeRegistry.merge(DialectRuntimeRegistry.java:110)
at org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:496)
at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:427)
at org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:149)
at disbotics.core.config.DroolsRulesPlugin.initialize(DroolsRulesPlugin.java:76)
at disbotics.core.common.DisboticsCore.startFramework(DisboticsCore.java:109)
at disbotics.core.common.DisboticsCore.main(DisboticsCore.java:56)
Exception in thread "main" org.drools.RuntimeDroolsException: java.lang.UnsupportedOperationException
at org.drools.rule.JavaDialectRuntimeData.write(JavaDialectRuntimeData.java:386)
at org.drools.rule.JavaDialectRuntimeData.merge(JavaDialectRuntimeData.java:266)
at org.drools.rule.JavaDialectRuntimeData.clone(JavaDialectRuntimeData.java:251)
at org.drools.rule.DialectRuntimeRegistry.merge(DialectRuntimeRegistry.java:110)
at org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:496)
at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:427)
at org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:149)
at disbotics.core.config.DroolsRulesPlugin.initialize(DroolsRulesPlugin.java:76)
at disbotics.core.common.DisboticsCore.startFramework(DisboticsCore.java:109)
at disbotics.core.common.DisboticsCore.main(DisboticsCore.java:56)
Caused by: java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:131)
at java.util.AbstractList.add(AbstractList.java:152)
at org.drools.rule.JavaDialectRuntimeData.write(JavaDialectRuntimeData.java:383)
...9 more
...which works in OpenJDK. weirdly, it turns out that the list in question in JavaDialectRuntimeData is obtained via Collections.emptyList() and is never changed again (or so eclipse suggests...).
When running with bare .drl files using this code:
Properties props = new Properties();
props.put("drools.dialect.java.compiler", "JANINO");
KnowledgeBuilderConfiguration kbConfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(props,
(ClassLoader[]) null);
KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(kbConfig);
kBuilder.add(ResourceFactory.newClassPathResource("disbotics/core/rules/drools/function.drl",
DroolsRulesPlugin.class), ResourceType.DRL);
kBuilder.add(ResourceFactory.newClassPathResource(rulesFile, DroolsRulesPlugin.class), ResourceType.DRL);
if(kBuilder.hasErrors()) {
String errorMessage = "";
for(KnowledgeBuilderError error:kBuilder.getErrors())
errorMessage = errorMessage + error.getMessage() + "\n";
throw new DisboticsException(errorMessage);
}
kBase = KnowledgeBaseFactory.newKnowledgeBase();
kBase.addKnowledgePackages(kBuilder.getKnowledgePackages());
kSession = kBase.newStatefulKnowledgeSession();
... I get these (unexpected) exceptions from the rules compiler:
Exception in thread "main" disbotics.core.common.DisboticsException: Line 2:8 unexpected exception at input '"mvel"'. Exception: java.lang.UnsupportedOperationException. Stack trace:
java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:131)
at java.util.AbstractList.add(AbstractList.java:152)
at org.drools.lang.descr.PackageDescr.addAttribute(PackageDescr.java:138)
at org.drools.lang.api.impl.PackageDescrBuilderImpl.attribute(PackageDescrBuilderImpl.java:93)
at org.drools.lang.ParserHelper.start(ParserHelper.java:684)
at org.drools.lang.DRLParser.stringAttribute(DRLParser.java:1289)
at org.drools.lang.DRLParser.attribute(DRLParser.java:1062)
at org.drools.lang.DRLParser.statement(DRLParser.java:276)
at org.drools.lang.DRLParser.compilationUnit(DRLParser.java:155)
at org.drools.compiler.DrlParser.compile(DrlParser.java:225)
at org.drools.compiler.DrlParser.parse(DrlParser.java:136)
at org.drools.compiler.DrlParser.parse(DrlParser.java:141)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:352)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:538)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
at disbotics.core.config.DroolsRulesPlugin.initialize(DroolsRulesPlugin.java:55)
at disbotics.core.common.DisboticsCore.startFramework(DisboticsCore.java:109)
at disbotics.core.common.DisboticsCore.main(DisboticsCore.java:56)
[ERR 107] Line 2:8 mismatched input '"mvel"' expecting one of the following tokens: '[package, import, global, declare, function, rule, query]'.
Line 4:0 unexpected exception at input 'global'. Exception: java.util.EmptyStackException. Stack trace:
java.util.EmptyStackException
at java.util.Stack.pop(Stack.java:109)
at org.drools.lang.ParserHelper.popParaphrases(ParserHelper.java:421)
at org.drools.lang.ParserHelper.end(ParserHelper.java:732)
at org.drools.lang.DRLParser.globalStatement(DRLParser.java:401)
at org.drools.lang.DRLParser.statement(DRLParser.java:261)
at org.drools.lang.DRLParser.compilationUnit(DRLParser.java:155)
at org.drools.compiler.DrlParser.compile(DrlParser.java:225)
at org.drools.compiler.DrlParser.parse(DrlParser.java:136)
at org.drools.compiler.DrlParser.parse(DrlParser.java:141)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:352)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:538)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
at disbotics.core.config.DroolsRulesPlugin.initialize(DroolsRulesPlugin.java:55)
at disbotics.core.common.DisboticsCore.startFramework(DisboticsCore.java:109)
at disbotics.core.common.DisboticsCore.main(DisboticsCore.java:56)
Parser returned a null Package
Line 2:8 unexpected exception at input '"java"'. Exception: java.lang.UnsupportedOperationException. Stack trace:
java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:131)
at java.util.AbstractList.add(AbstractList.java:152)
at org.drools.lang.descr.PackageDescr.addAttribute(PackageDescr.java:138)
at org.drools.lang.api.impl.PackageDescrBuilderImpl.attribute(PackageDescrBuilderImpl.java:93)
at org.drools.lang.ParserHelper.start(ParserHelper.java:684)
at org.drools.lang.DRLParser.stringAttribute(DRLParser.java:1289)
at org.drools.lang.DRLParser.attribute(DRLParser.java:1062)
at org.drools.lang.DRLParser.statement(DRLParser.java:276)
at org.drools.lang.DRLParser.compilationUnit(DRLParser.java:155)
at org.drools.compiler.DrlParser.compile(DrlParser.java:225)
at org.drools.compiler.DrlParser.parse(DrlParser.java:136)
at org.drools.compiler.DrlParser.parse(DrlParser.java:141)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:352)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:538)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
at disbotics.core.config.DroolsRulesPlugin.initialize(DroolsRulesPlugin.java:57)
at disbotics.core.common.DisboticsCore.startFramework(DisboticsCore.java:109)
at disbotics.core.common.DisboticsCore.main(DisboticsCore.java:56)
[ERR 107] Line 2:8 mismatched input '"java"' expecting one of the following tokens: '[package, import, global, declare, function, rule, query]'.
Line 4:0 unexpected exception at input 'import'. Exception: java.util.EmptyStackException. Stack trace:
java.util.EmptyStackException
at java.util.Stack.pop(Stack.java:109)
at org.drools.lang.ParserHelper.popParaphrases(ParserHelper.java:421)
at org.drools.lang.ParserHelper.end(ParserHelper.java:732)
at org.drools.lang.DRLParser.importStatement(DRLParser.java:349)
at org.drools.lang.DRLParser.statement(DRLParser.java:258)
at org.drools.lang.DRLParser.compilationUnit(DRLParser.java:155)
at org.drools.compiler.DrlParser.compile(DrlParser.java:225)
at org.drools.compiler.DrlParser.parse(DrlParser.java:136)
at org.drools.compiler.DrlParser.parse(DrlParser.java:141)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:352)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:538)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
at disbotics.core.config.DroolsRulesPlugin.initialize(DroolsRulesPlugin.java:57)
at disbotics.core.common.DisboticsCore.startFramework(DisboticsCore.java:109)
at disbotics.core.common.DisboticsCore.main(DisboticsCore.java:56)
Line 6:0 unexpected exception at input 'rule'. Exception: java.util.EmptyStackException. Stack trace:
java.util.EmptyStackException
at java.util.Stack.pop(Stack.java:109)
at org.drools.lang.ParserHelper.popParaphrases(ParserHelper.java:421)
at org.drools.lang.ParserHelper.end(ParserHelper.java:732)
at org.drools.lang.DRLParser.rule(DRLParser.java:886)
at org.drools.lang.DRLParser.statement(DRLParser.java:267)
at org.drools.lang.DRLParser.compilationUnit(DRLParser.java:155)
at org.drools.compiler.DrlParser.compile(DrlParser.java:225)
at org.drools.compiler.DrlParser.parse(DrlParser.java:136)
at org.drools.compiler.DrlParser.parse(DrlParser.java:141)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:352)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:538)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
at disbotics.core.config.DroolsRulesPlugin.initialize(DroolsRulesPlugin.java:57)
at disbotics.core.common.DisboticsCore.startFramework(DisboticsCore.java:109)
at disbotics.core.common.DisboticsCore.main(DisboticsCore.java:56)
Parser returned a null Package
at disbotics.core.config.DroolsRulesPlugin.initialize(DroolsRulesPlugin.java:63)
at disbotics.core.common.DisboticsCore.startFramework(DisboticsCore.java:109)
at disbotics.core.common.DisboticsCore.main(DisboticsCore.java:56)
again, compiling the rules worked just fine in OpenJDK. We're using Janino, and it is properly referenced on the classpath (the classpath used at runtime is created by the Maven build, so contains all jars referenced by drools/janino/ anything else)
Does anyone know what's going on here and/or how to get Drools working with JamVM?
Are you compiling the knowledge packages using OpenJDK 1.6? and then trying to load it with 1.5.4? You should try compiling the original packages using 1.5.4 and see if you have the same errors.
For the stack trace, it looks like you are trying to add something to an unmodifiable list right?
Basically you are getting the exception here: kBase.addKnowledgePackages(kpkgs);
Right?