-
1. Re: Using Drools within an Java Enterprise Application
psiroky Oct 16, 2014 6:29 PM (in response to jesstei)Hi,
it is kind of simplification, but Drools (meaning just the core rule engine) is "just" a Java library and can be used/embedded into your application basically as easily as any other set of third party jars. As you mentioned, you already have the standalone Drools application. It should be fairly easy then to just add the logic into the MDB and embed the Drools libraries in the EAR/WAR.
There also some advanced advanced features like CDI integration that could be useful in this case. See Chapter 10. CDI or drools/drools-examples-cdi/cdi-example at master · droolsjbpm/drools · GitHub for more information.
You could also create the Drools runtime as a separate application (or use the currently developed kie-server) and use remote APIs (like REST) to interact with the engine. But from your description, it seems embedding the engine is a better choice.
Since you are asking in BPM Suite forum, do you plan to use also the jBPM? In that case it is still fairly easy to embed the engine, but you typically also need to setup persistence and few other things.
Thanks,
Petr
-
2. Re: Using Drools within an Java Enterprise Application
jesstei Oct 17, 2014 2:40 AM (in response to psiroky)Hello Petr,
thanks for your advice.
If I try to integrate Drools into my ear file fails to deploy and I get several exceptions.
If I add this line:
KieServices ks = KieServices.Factory.get();
I receive the following exception: java.lang.NoClassDefFoundError: org/kie/api/KieServices$Factory
Even so I added the kie-api-6.10.Final.jar to the project and the KieService.class is available.
If a add these lines:
@Inject
@KSession("ksession-rules")
KieSession kSession;
I receive the following exception: java.lang.NoClassDefFoundError: Lorg/kie/api/runtime/KieSession; and java.lang.ClassNotFoundException: org.kie.api.runtime.KieSession.
These .class files are also available within kie-api-6.10.Final.jar.
Regarding your question: Do you plan to use also the jBPM? You typically also need to setup persistence and few other things.
I need to create profiles out of the reactions initiated after the occurence of some messages. These profiles are stored within a no sql database and are taken into account for future reactions.
I do not know if jBPM would be too much or useful in this case but persistence will be a topic anyway :-).
Kind regards,
jesstei
-
3. Re: Using Drools within an Java Enterprise Application
psiroky Oct 17, 2014 4:54 AM (in response to jesstei)Hi jesstei,
unfortunately, I am not much familiar with the EARs and how the classloading works in WildFly 8. It seems the kie-api-<version>.jar is not on the classpath (for whatever reason), but I guess you already figured that out.
Would it be possible to share the sources of your project (e.g. on github), so we can look at them? I believe this would be the fastest way to get it working.
Thanks,
Petr
-
4. Re: Using Drools within an Java Enterprise Application
jesstei Oct 21, 2014 4:03 AM (in response to psiroky)Hello Petr,
as soon as I have uploaded the files I will post an URL to the repro. I need to change the messages I send because they are confidential.
The repro URL is : jesstei/Drools · GitHub
Kind regards,
jesstei
-
5. Re: Using Drools within an Java Enterprise Application
psiroky Oct 28, 2014 9:21 AM (in response to jesstei)Hello,
sorry for the delay, I somehow missed the update of your post with the link to github. I will look into the sources shortly.
One thing that struck me at first sight is that you are actually using different versions of drools artifacts, some of them are 6.0.0.Beta2 and some of them 6.2.0.Beta3. This does not necessarily cause your problem, but it is bad idea to mix the versions.
Thanks,
Petr
-
6. Re: Using Drools within an Java Enterprise Application
psiroky Oct 28, 2014 9:30 AM (in response to psiroky)I just briefly looked through the sources and I have following questions:
- is the WAR module missing? This way I can't compile the project.
- is the actual drools integration missing? I could not find any code that would use/call drools engine. There is a class RulesEngine, but it is empty.
Petr
-
7. Re: Using Drools within an Java Enterprise Application
jesstei Nov 3, 2014 8:46 AM (in response to psiroky)Hi Petr,
unfortunatly, I did not receive a notification that you respond to my message.
I wanted to integrate drools into the Class RulesEngine. But I receive the following error: ERROR [org.drools.compiler.kie.builder.impl.KieContainerImpl] (Thread-0 (HornetQ-client-global-threads-1906460542)) Unknown KieSession name: ksession-rules.
I am going to upload a current version to github.
The version mix might have occurred as I changed versions several times to try to get it working.
Kind regards and thanks a lot for your help.
jesstei
-
8. Re: Using Drools within an Java Enterprise Application
jesstei Nov 3, 2014 1:59 PM (in response to jesstei)Hi Petr,
I uploaded my current .ear file to my git repro.
Kind regards,
jesstei