Persitence configuration issue in Drools Flow 5.1.M1 (PersistenceException/AnnotationException)
by Nol de Wit
Hi,
(using Droolw Flow 5.1.M1)
I've made a reasonably simple Drool Flow model, containing a ForEach,
a split and and a couple of actions. Without Persistence it works
nicely: I start it with one variable/parameter, a class I call Report
with 4 Lines of data . Each of the lines get's worked on correctly in
the ForEach.
Next I want to add Persistence to the model; I made a persistence.xml,
which is based on the one as shown in chapter 5 of the online Drools
Flow documentation. See below.
I changed the H2 db to a mysql DB.
The firs call (after creating the datasource) in my test now gives an
exception. See the call and exception below.
1) what's wrong? I think my persistence.xml is correct. So what is the
error trying to tell me? Is saying that I should map my parameters
data (Report and Line)? I just read an article from salaboy about
variable persistence 5.1, but I'm not using that...
2) What puzzles me is the link between the persistence.xml (containing
mapping info), and the datasource (containing the credentials of the
DB). In the doc and PerformanceTest.java class in the examples I don't
see any link. Is creating the DataSource enough to get it in JNDI?
Thanks,
Nol
Some of my code and config:
// See makeDataSource() below
PoolingDataSource ds = makeDataSource();
// this call gives an exception:
EntityManagerFactory emf =
Persistence.createEntityManagerFactory( "nl.dnb.avb.drools.jpa" );
25-mrt-2010 14:30:00 org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class:
org.drools.persistence.processinstance.WorkItemInfo
25-mrt-2010 14:30:00 org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity org.drools.persistence.processinstance.WorkItemInfo
on table WorkItemInfo
javax.persistence.PersistenceException: [PersistenceUnit:
nl.dnb.avb.drools.jpa] Unable to configure EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:265)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:125)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
at pilot.tests.DroolFlowPersistenceTest.main(DroolFlowPersistenceTest.java:41)
Caused by: org.hibernate.AnnotationException: Use of @OneToMany or
@ManyToMany targeting an unmapped class:
org.drools.persistence.processinstance.ProcessInstanceInfo.variables[org.drools.persistence.processinstance.variabletypes.VariableInstanceInfo]
at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1071)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:602)
at org.hibernate.cfg.annotations.MapBinder$1.secondPass(MapBinder.java:79)
Persistence.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence
version="1.0"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="nl.dnb.avb.drools.jpa">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/processInstanceDS</jta-data-source>
<class>org.drools.persistence.session.SessionInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceEventInfo</class>
<class>org.drools.persistence.processinstance.WorkItemInfo</class>
<properties>
<!-- property name="hibernate.dialect"
value="org.hibernate.dialect.H2Dialect"/ -->
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
</properties>
</persistence-unit>
</persistence>
private static PoolingDataSource makeDataSource() {
PoolingDataSource ds = new PoolingDataSource();
ds.setUniqueName("jdbc/processInstanceDS");
ds.setClassName("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");
ds.setMaxPoolSize(3);
ds.setAllowLocalTransactions(true);
ds.getDriverProperties().put("user", "drools");
ds.getDriverProperties().put("password", "drools");
ds.getDriverProperties().put("URL", "jdbc:mysql://DNB35362:3306/drools");
ds.init();
return ds;
}
14 years, 9 months
Activated rule not firing eventhough was never cancelled
by H.C.
I have about a dozen rules across various ruleflow groups orchestrated
through a ruleflow. I am trying to troubleshoot why a particular rule in a
downstream ruleflow group is not firing.
I see an activation created for this particular rule as facts are added to
working memory (by looking at the audit log). My ruleflow starts and I
insepct all cancelled activations for all subsequent fact
inserts/updates/retracts and don't see the rule's activation ever being
cancelled before it reaches the rule's ruleflow group activation. The rule's
ruleflow group is activated but the rule's activation isn't executed.
I would think I would see a cancellation of the rule if a prior fact change
had rendered the rule uneligible.
Why might this happen?
--
View this message in context: http://n3.nabble.com/Activated-rule-not-firing-eventhough-was-never-cance...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 9 months
Call class method from LHS of a rule
by orchid
Hi All,
I'm trying to call a class method from the LHS of a rule in the following
way:
public class Cheese{
private string type;
//setters and getters
public boolean existsInShop(String shop){
...
return true;
}
}
I would like to call the method "existsInShop" from a rule:
Rule "Rule1"
when
$c:Cheese(type == "chedar", existsInShop "shopName")
then
System.out.println("Rule1 is fired");
end
I get the compilation error: "no viable alternative at input "shopName" in
rule "Rule1" in pattern document". How can I call the method from the rule?
Thanks in advance.
--
View this message in context: http://n3.nabble.com/Call-class-method-from-LHS-of-a-rule-tp108383p108383...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 9 months
drools-guvnor, problem when creating test scenarios based on referenced domain model
by Krunoslav Sabljak
Hi all,
first of all, i appologise if i'm starting a topic that already exists (but
i couldn't find one :-)
i'm having some difficulties with creating test scenarios in guvnor when the
domain model is based on referenced objects.
Suppose we have a model like this one:
Class Role with attributes:
roleId: Long
roleName: String
Class User with attributes:
userId: Long
userName: String
firstName: String
lastName: String
role: Role
Then, lets suppose the rule like this one (it's pritty simple one)
rule "my first rule"
dialect "mvel"
when
usr: User(firstName=="John", lastName="Doe", role.roleName="ADMIN" )
then
usr.userName="ADMIN"
end
Now, i'm trying to create a test scenario for this rule. And my nightmare
begins...
Seems to me that there is no possibility to define referenced object in test
scenario, ie:
GIVEN
User [usr]
firstName = "..."
lastName = "..."
*role.roleName = "..."*
EXPECTING
..............
Hope that you can understand what i'm talking about. Can somebody (pretty
please) give me some directions how to achieve something like this in test
scenarios.
Thank you for your answers and suggestions (if any) :-))
14 years, 9 months
Mechanism to prevent redundant inferences
by Tracey Lall
Hi folks
I am writing a logical inference engine in drools. Logical sentences (class
Sentence) which are proven are indicated by the fact Proven( sentence =
$sentence )
All Proven(sentence) facts are asserted using the drools logical mechanism
(since logical backtracking is required).
For efficiency purposes I want to be able to suppress firing any rules which
assert proof of a logical sentence which has already been proven (there may
be multiple inferences which prove the same sentence).
If the non existence of a proof of a sentence (not exists
Proven(sentence=$sentence) is included in the lhs conditions then that
causes problems when the rule logically asserts Proven(sentence) since the
insertion invalidates the lhs conditions and hence the rule causes its own
retraction (the inserted fact handle return is null).
As a way around this I created a class Piton() to record whether a
particular rule has fired. The lhs conditions then become:
(Proven( predicate == $sentence ) or Piton( fireName == $descriptor ) )
And then in the body of the rule the first thing it asserts is the fact:
Piton( fireName == $descriptor )
Where $descriptor is a string built from the rulename + the set of facts
which matched the lhs (ie a descriptor which is unique to the rule fire)
With this approach when a rule asserts Proven(sentence) because it has also
asserted Piton( fireName == descriptor ) ) the lhs of the rule still
matches the the rule fire is not retracted.
This approach works, but it is rather tedious to implement since the
descriptor must be defined in such as way to make it unique (or as far as
possible unique) to the particular rule activation. Since the drools
variable is not accessible in the lhs of a rule (and hence the activation
details are not accessible in the lhs), this means that the descriptor must
be handcoded to consist of all matching facts for that lhs.
Is this approach the only way to prevent multiple rule firings for the same
proof, or is there a simpler way to achieve this?
Any advice greatly appreciated!
thanks
Tracey
14 years, 9 months
Deep Links in Guvnor
by Jörg Herbst
Hi,
I'm currently evaluating Guvnor. The application is really great for
managing rools for none developers. But I've got a special requirement.
Is it possible to provide deep links for editing assets or a list of
assets? I'm looking for a way to create something like a bookmarkable URL
when using the navigator which can be used in another web application.
The background is, I've got different usergroups editing different rules and
I'm looking for a way linking to guvnor and displaying "their" rules.
"Their" can be defined by a package or some naming convention.
Any ideas?
Joerg
14 years, 9 months