Play! framework [1.2.4] from Drools to Heroku

I tried to make a simple web application integrated with the Drools rule engine and deployed it to the hero. In the controller action, I execute a method that imports and parses the DRL file and returns the result. I noticed strange behavior. When I start the application with the command play run Drools do not want to work (I get some import errors for the rules and exception parsing exception), but when I start my application through Eclipse, everything works.

I checked what exactly is being done in these various ways:

I tried to run play run with additional Java arguments existing in Eclipse execution, but I did not find a working combination.

Any ideas what arguments the play run command adds to find a working solution?

Thanks in advance for your help.

Stacktrace:

 java.lang.IllegalArgumentException: at drools.RuleEngine.readKnowledgeBase(RuleEngine.java:66) at drools.RuleEngine.run(RuleEngine.java:28) at controllers.Application.index(Application.java:17) 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 play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:546) at play.mvc.ActionInvoker.invoke(ActionInvoker.java:500) at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:476) at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:471) at play.mvc.ActionInvoker.invoke(ActionInvoker.java:159) at play.server.PlayHandler$NettyInvocation.execute(PlayHandler.java:220) at play.Invoker$Invocation.run(Invoker.java:265) at play.server.PlayHandler$NettyInvocation.run(PlayHandler.java:200) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:165) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:679) 
+4
source share
2 answers

Ok, I found a solution for me here: fooobar.com/questions/1384808 / ... I packed the classes related to Drools and the rules file in a single jar file, and I put this jar in the same directory included in the classpath , - he solved the problem.

+2
source

I have no idea how to make a workaround / hack it work.

I decided to do the following. I added the following line to the play \ framework \ pym \ play \ application.py file in the def method getClasspath (self):

  classpath.append(os.path.normpath(os.path.join(os.path.join(self.path, 'tmp'),'classes'))) 

The above simply adds the classes that are them to the play tmp> classes directory in the classpath.

Everything is working fine.

But I really did not understand how the game is able to resolve these links, where Drools cannot do this.

+1
source

Source: https://habr.com/ru/post/1384804/


All Articles