我在没有使用jboss的情况下在eclipse中测试了一个简单的工作流示例(当然是通过在Eclipse中配置jbpm5使其支持jbpm5)
现在我想测试在服务器 jboss 5.1 中运行的 JEE 应用程序(Web 应用程序)中的示例工作流
我在 web 应用程序的源文件夹下制作了这个文件:sample.bpmn,我在下制作了 ProcessMain.java
src\com\sample
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 文件中设置)
但是当我在使用来自java类ProcessMain.java的方法验证的网页(jsp页面)中制作了一个按钮时
显示此错误
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],