Drools 6 Spring JTA Persistence
by Alexander Herwix
Hey guys,
I'm working on a Grails plugin for Drools/Jbpm 6 and I have trouble to get persistence working in a user friendly way. It would be awesome if someone with a better understanding of drools and especially drools spring integration could help me to figure this out :)
I have considered multiple approaches:
- Use a spring LocalContainerEntityManagerFactoryBean with a local JpaTransactionManager to configure a KieEnvironment via Spring.
I basically got this working, but this doesn't provide real integration with Grails, as there are 2 seperate local TransactionManagers involved - limiting the ability to integrate drools in the grails app.
- Use JTA-Transactions.
As I want the plugin to be as user friendly as possible I would like to keep using the default tomcat container for development. There is the Atomikos Plugin for Grails which configures Grails to work with JTA. This works pretty nicely and should suffice for the development environment.
My problem is integrating the Atomikos backed JTATransactionManager with the drools 6 spring environment configuration as I have not much experience with JTA. I have looked at the Tests for Kie-Spring and looked at as much documentation as I could find, but I can't seem to figure this out.
This is what I use to configure the environment via spring (in Grails groovy syntax)
jbpmGlobals(MapGlobalResolver)
dacceptor(ClassObjectMarshallingStrategyAcceptor,['*.*'])
kie.kstore(id:'kiestore')
kie.environment(id: 'jbpmEnv'){
kie.'entity-manager-factory'(ref:'entityManagerFactory')
kie.globals(ref:'jbpmGlobals')
kie.'object-marshalling-strategies'(){
kie.'jpa-placeholder-resolver-strategy'()
kie.'serializable-placeholder-resolver-strategy'('strategy-acceptor-ref':"dacceptor")
}
}
//Tried to wrap my JtaTransactionManager with KieSpringTransactionManager
jbpmTransactionManager(KieSpringTransactionManager, ref('transactionManager'))
the environment value for transactionManager cannot be set here, because the parser expects a JpaTransactionManager. I tried to add the transactionManager manually to the environment and found the KieSpringTransactionManager, which looked like it could help me somehow, but in the end, there is always the default implementation of the JtaTransactionManager used which can't find the transactionManager that I configured.
Error:
NamingException occurred when processing request: [GET] /bpm/test/testJbpm
Cannot create resource instance. Stacktrace follows:
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:116)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:122)
at org.drools.persistence.jta.JtaTransactionManager.<init>(JtaTransactionManager.java:69)
at org.drools.persistence.SingleSessionCommandService.initTransactionManager(SingleSessionCommandService.java:325)
at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:114)
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:129)
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newKieSession(KnowledgeStoreServiceImpl.java:67)
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newKieSession(KnowledgeStoreServiceImpl.java:36)
at bpm.TestController.testJbpm(TestController.groovy:119)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:200)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
I would be glad about any input.
Cheers, Alex
12 years, 3 months
Re: [rules-users] Fully qualified name for generated classes
by Lance Leverich
The issue isn't that Foo cannot be resolved, as it was imported into both
packages from the Global Area. The packages compile just fine. I believe
what might be happening, though, is that each package is creating its own
version of Foo.
For example, am I experiencing something like...
com.mypkg.a generates a class with a fully qualified name of
drools.com.mypkg.a.Foo
com.mypkg.b generates a class with a fully qualified name of
drools.com.mypkg.b.Foo
?
If this is the case, is there someway within Guvnor to refer to a
particular version? I'm beginning to think that my best option might be to
create a POJO and import it. At least that way, I can make sure I know the
fully qualified (i.e. canonical) class name.
~ Lance
Cc:
> Date: Wed, 4 Sep 2013 15:41:55 +0100
> Subject: Re: [rules-users] Fully qualified name for generated classes
> Guvnor's Global Area has no affect on fully qualified type names; it's
> just a container for things you want to share.
>
> If Foo could not be resolved in myRuleB the rule would fail to compile.
>
> What do you observations show if you don't have any rule flow?
>
>
> On 4 September 2013 15:28, Lance Leverich <lance.leverich(a)gmail.com>wrote:
>
>> What would be the fully qualified name for a generated class, that is
>> based upon a fact type (for example a type named "Foo") that is defined
>> inside a declarative model?
>> How is the fully qualified name affected if the model resides in the
>> Global Area, and is imported into multiple packages?
>>
>> The reason for my question is that I have the following issue:
>>
>> In the Global Area, I have a declarative model (named MyModel) with a
>> definition like...
>> declare Foo
>> bar: String
>> version: String
>> end
>>
>> In a package (com.mypkg.a), I have imported MyModel from the Global Area.
>> I have a rule like...
>>
>> rule "myRuleA"
>> ruleflow-group "firstGroup"
>> when
>> not Foo( bar=="bar" )
>> then
>> Foo fact = new Foo();
>> fact.setBar("bar");
>> fact.setVersion("1");
>> insert(fact);
>>
>> In another package (com.mypkg.b), I have also imported MyModel from the
>> Global Area. I have a rule like
>>
>> rule "myRuleB"
>> ruleflow-group "secondGroup"
>> when
>> Foo()
>> then
>> System.out.println("got at least one Foo");
>>
>> Looking at logs, the rule myRuleA fires as is appropriate; however, the
>> rule myRuleB does not fire, even though both ruleflow groups are
>> represented in the ruleflow. I have verified that both of the ruleflow
>> groups are activated, using the logs. My best guess at this point is that
>> the class generated for fact type Foo is different for each package. So,
>> how can I make sure that I am instantiating and checking for the same type
>> across packages?
>>
>>
>>
>> Lance Leverich
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
12 years, 3 months
Fully qualified name for generated classes
by Lance Leverich
What would be the fully qualified name for a generated class, that is based
upon a fact type (for example a type named "Foo") that is defined inside a
declarative model?
How is the fully qualified name affected if the model resides in the Global
Area, and is imported into multiple packages?
The reason for my question is that I have the following issue:
In the Global Area, I have a declarative model (named MyModel) with a
definition like...
declare Foo
bar: String
version: String
end
In a package (com.mypkg.a), I have imported MyModel from the Global Area. I
have a rule like...
rule "myRuleA"
ruleflow-group "firstGroup"
when
not Foo( bar=="bar" )
then
Foo fact = new Foo();
fact.setBar("bar");
fact.setVersion("1");
insert(fact);
In another package (com.mypkg.b), I have also imported MyModel from the
Global Area. I have a rule like
rule "myRuleB"
ruleflow-group "secondGroup"
when
Foo()
then
System.out.println("got at least one Foo");
Looking at logs, the rule myRuleA fires as is appropriate; however, the
rule myRuleB does not fire, even though both ruleflow groups are
represented in the ruleflow. I have verified that both of the ruleflow
groups are activated, using the logs. My best guess at this point is that
the class generated for fact type Foo is different for each package. So,
how can I make sure that I am instantiating and checking for the same type
across packages?
Lance Leverich
12 years, 3 months
ClassNotFoundException org.drools.compiler.kie.builder.impl.KieModuleCache$KModuleCache in Grails project
by Martin Minka
working projects are attached
This simple code works in Groovy project:
{code}
KieServices ks = KieServices.Factory.get();
KieRepository kr = ks.getRepository();
KieFileSystem kfs = ks.newKieFileSystem();
// String drl = new File("rules/r1.drl").getText()
// kfs.write("src/main/resources/org/kie/example5/HAL5.drl", drl);
KieBuilder kb = ks.newKieBuilder(kfs);
kb.buildAll(); // kieModule is automatically deployed to KieRepository if
successfully built.
{code}
but it fails with error if executed in Grails 2.2.4 application
{code}
1. ERROR errors.GrailsExceptionResolver - ClassNotFoundException
occurred when processing request: [GET] /grails-drools6/drools/index
2. org.drools.compiler.kie.builder.impl.KieModuleCache$KModuleCache.
Stacktrace follows:
3. Message:
org.drools.compiler.kie.builder.impl.KieModuleCache$KModuleCache
4. Line | Method
5. ->> 366 | run in java.net.URLClassLoader$1
6. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
7. | 355 | run in ''
8. | 354 | findClass . . . . . . . . in java.net.URLClassLoader
9. | 424 | loadClass in java.lang.ClassLoader
10. | 357 | loadClass . . . . . . . . in ''
11. | 2521 | privateGetDeclaredMethods in java.lang.Class
12. | 1845 | getDeclaredMethods . . . in ''
13. | 46 | getLocked in
org.codehaus.groovy.util.LazyReference
14. | 33 | get . . . . . . . . . . . in ''
15. | 64 | loadEngine in grails.drools6.DroolsService
16. | 8 | index . . . . . . . . . . in
grails.drools6.DroolsController
17. | 195 | doFilter in
grails.plugin.cache.web.filter.PageFragmentCachingFilter
18. | 63 | doFilter . . . . . . . . in
grails.plugin.cache.web.filter.AbstractFilter
19. | 1145 | runWorker in
java.util.concurrent.ThreadPoolExecutor
20. | 615 | run . . . . . . . . . . . in
java.util.concurrent.ThreadPoolExecutor$Worker
21. ^ 724 | run in java.lang.Thread
{code}
do I need to configure custom (Grails) class loader to Kie ?
12 years, 3 months
JBPM : Need solution with SwimLane
by Zahid Ahmed
Hi,
I am testing swim lanes for a scenario in my requirements. But, I am unable to get my desired results.
Scenario: The scenario is that when a subordinate task completes and assigns back to ManagerTask. The manager who assigned the task should be getting the task again now without having to claim it. For this I have tried to use swim lanes but its not working. PFA BPMN2 and process image.
[cid:image001.png@01CEA7F1.E4F40F80]
Regards,
Zahid
12 years, 3 months
Guvnor Version
by pritha.ghosh@wipro.com
Hi,
Please let me know the compatible drools guvnor version for JBoss EAP 6.1
Thanks,
Pritha
Please do not print this email unless it is absolutely necessary.
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
12 years, 3 months