[JBoss jBPM] - jbpm jrules Rule Compilation error
by shoba
Hi All,
Im working on jbpm jrule sample. I'm getting this error while running jbpm application in jbpm-console.
Error completing task: An exception of type "org.jbpm.graph.def.DelegationException" was thrown. The message is: Rule Compilation error : [Rule name=Your First Rule, agendaGroup=MAIN, salience=0, no-loop=false] login/Rule_Your_First_Rule_0.java (2:23) : Only a type can be imported. com.sample.action.LoginBean resolves to a package login/Rule_Your_First_Rule_0.java (8:285) : l cannot be resolved login/Rule_Your_First_Rule_0.java (9:326) : l cannot be resolved com.sample.action.LoginBean
Please help me to get through this error.
Here is my files:
-----------------------------------------------------
loginrule.drl
-----------
package login
import com.sample.action.LoginBean;
#list any import classes here.
#declare any global variables here
rule "Your First Rule"
when
exists LoginBean
LoginBean(username == "XXX")
then
System.out.println("first rule");
end
----------------------------------------------------------
RulesActionHandler.java
-----------------------
package com.sample.action;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import org.drools.RuleBase;
import org.drools.compiler.PackageBuilder;
import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
public class RulesActionHandler implements ActionHandler {
String RuleFile = "/loginrule.drl";
public void execute(ExecutionContext executionContext) throws Exception {
// TODO Auto-generated method stub
String username = (String)executionContext.getContextInstance().getVariable("u1");
String department = (String)executionContext.getContextInstance().getVariable("u2");
com.sample.action.LoginBean bean = new com.sample.action.LoginBean();
bean.setUsername(username);
bean.setDepartment(department);
bean.print();
RuleBase ruless = readRule(RuleFile);
WorkingMemory memory = ruless.newStatefulSession();
memory.insert((LoginBean)bean);
org.jbpm.context.exe.ContextInstance ci = executionContext.getContextInstance();
memory.setGlobal("ci", ci);
executionContext.getToken().signal();
}
private RuleBase readRule(String filename) throws java.io.IOException,Exception{
RuleBase rulebase = null;
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(new java.io.InputStreamReader(RulesActionHandler.class.getResourceAsStream(filename)));
rulebase = RuleBaseFactory.newRuleBase();
rulebase.addPackage(builder.getPackage());
return rulebase;
}
}
---------------------------------------------------------------------
LoginBean.java
--------------
package com.sample.action;
public class LoginBean {
public LoginBean() {
super();
// TODO Auto-generated constructor stub
}
private String username;
private String department;
public String getUsername() {
return username;
}
public LoginBean(String username) {
super();
this.username = username;
}
public LoginBean(String username, String department) {
super();
this.username = username;
this.department = department;
}
public void setUsername(String username) {
this.username = username;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public void print(){
System.out.println("User Namev : "+username);
System.out.println("Department : "+department);
}
}
---------------------------------------------------------------------
processdefinition.xml
-------------------
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="loginprocess">
<start-state name="enterlogin">
</start-state>
/loginrule.drl
<end-state name="finish">
</end-state>
</process-definition>
Thanking You,
Shoba
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4172739#4172739
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4172739
16 years, 3 months