我在eclipse中测试了一个简单的工作流示例 不使用jboss(当然通过将配置jbpm5放入Eclipse中,因此它支持jbpm5)
现在我想测试在服务器jboss 5.1中运行的JEE应用程序(Web应用程序)中的示例工作流程
我在web应用程序的源文件夹下创建了这个文件:sample.bpmn,我在
下创建了ProcessMain.javaSRC \ COM \样品
ProcessMain.java的源代码
package com.sample;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.naming.Context;
import javax.naming.InitialContext;
import org.apache.commons.collections.map.HashedMap;
import org.drools.KnowledgeBase;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import com.esprit.ConsoftEJB.daos.RequestDaoRemote;
import com.esprit.ConsoftEJB.daos.UserDaoRemote;
import com.esprit.ConsoftEJB.persistence.Request;
/**
* This is a sample file to launch a process.
*/
public class ProcessMain {
private RequestDaoRemote reqService ;
private List<Request> requests=new ArrayList<Request>();
public ProcessMain() {
// TODO Auto-generated constructor stub
}
public List<Request> getAllRequest()
{
try {
Context context=new InitialContext();
setReqService((RequestDaoRemote) context.lookup("erq"));
} catch (Exception e) {
e.printStackTrace();
}
return requests=reqService.lisAll();
}
public static final void main(String[] args) throws Exception {
validation();
}
public static void validation()
{
int state=0;
KnowledgeBase kbase = null;
try {
kbase = readKnowledgeBase();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
// start a new process instance
ProcessMain p=new ProcessMain();
List<Request> listreq= p.getAllRequest();
for (int i = 0; i < listreq.size(); i++) {
state=Integer.parseInt(listreq.get(i).getState());
System.err.println(listreq.get(i).getState());
Map<String,Object> param=new HashMap<String,Object>();
param.put("etat",state);
ksession.startProcess("com.sample.bpmn.hello",param);
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn"), ResourceType.BPMN2);
return kbuilder.newKnowledgeBase();
}
public RequestDaoRemote getReqService() {
return reqService;
}
public void setReqService(RequestDaoRemote reqService) {
this.reqService = reqService;
}
public List<Request> getRequests() {
return requests;
}
public void setRequests(List<Request> requests) {
this.requests = requests;
}
}
我测试了这个类,她在控制台模式下显示了正确的结果
(在sample.bpmn文件中设置)
但是当我在网页(jsp页面)中创建一个按钮时,它使用java类ProcessMain.java中的方法验证
显示此错误
java.lang.ClassNotFoundException: org.drools.builder.KnowledgeBuilderFactory from BaseClassLoader@2cfe4f04{VFSClassLoaderPolicy@6bf5a6af{name=vfsfile:/C:/serveur/jboss-5.1.0.GA/jboss-5.1.0.GA/server/default/deploy/ProjetVrai.war/ domain=ClassLoaderDomain@1cd0437b{name=vfsfile:/C:/serveur/jboss-5.1.0.GA/jboss-5.1.0.GA/server/default/deploy/ProjetVrai.war/ parentPolicy=AFTER_BUT_JAVA_BEFORE parent=ClassLoaderDomain@23b87cc4{DefaultDomain}} roots=[MemoryContextHandler@1284661896[path= context=vfsmemory://5hs4j5g-ahljra-h4wsmcy7-1-h4wsw19q-9y real=vfsmemory://5hs4j5g-ahljra-h4wsmcy7-1-h4wsw19q-9y], FileHandler@367317037[path=ProjetVrai.war/WEB-INF/classes context=file:/C:/serveur/jboss-5.1.0.GA/jboss-5.1.0.GA/server/default/deploy/ real=file:/C:/serveur/jboss-5.1.0.GA/jboss-5.1.0.GA/server/default/deploy/ProjetVrai.war/WEB-INF/classes/], DelegatingHandler@511899134[path=ProjetVrai.war/WEB-INF/lib/commons-beanutils.jar context=file:/C:/serveur/jboss-5.1.0.GA/jboss-5.1.0.GA/server/default/deploy/ real=file:/C:/serveur/jboss-5.1.0.GA/jboss-5.1.0.GA/server/default/deploy/ProjetVrai.war/WEB-INF/lib/commons-beanutils.jar], DelegatingHandler@669255256[path=ProjetVrai.war/WEB-INF/lib/commons-collections.jar context=file:/C:/serveur/jboss-5.1.0.GA/jboss-5.1.0.GA/server/default/deploy/ real=file:/C:/serveur/jboss-5.1.0.GA/jboss-5.1.0.GA/server/default/deploy/ProjetVrai.war/WEB-INF/lib/commons-collections.jar],
答案 0 :(得分:0)
所以,显然你的EE环境中缺少一个类。确保在战争中你有drools-compiler- .jar和jbpm-flow .jar 你能否提一下你使用的是哪个版本的JBPM?