[jBPM Users] - [jBPM4] Manually updating DB Entries
by freiburger
Hi,
I'm using jBPM 4.1 in a standalone application with the default setup, having switched to MySQL as DB. I need to update some values in the jBPM DB manually and was asking myself what the most convenient and conformant way would be. As I want to access the environment, I thought about doing so using a custom command like this:
| public class UpdateDbCmd implements Command<Object> {
|
| private Object _entry;
|
| public UpdateDbCmd(Object entry) {
| _entry = entry;
| }
|
| public Object execute(Environment environment) throws Exception {
| DbSession session = (DbSession) environment.get(DbSession.class);
| // [...]update the entry
| return null;
| }
|
| }
|
Then I try to execute the Command like this:
| ProcessEngine eng = new Configuration().buildProcessEngine();
| // [...]
| eng.execute(new UpdateDbCmd(someEntry));
|
This does result in a NullPointerException as the userCommandService is not defined in the configuration. Unfortunately I haven't found information about how to configure the wire bindings correctly. Could anyone please point me in the right direction or suggest another way how to update db entries manually.
Thanks
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4261011#4261011
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4261011
16 years, 5 months
[jBPM Users] - Re: Hibernate LazyInitializationException
by remiel512
"sebastian.s" wrote : Your process definition got lost. Can you repost it using the code-tags? Also please provide a unit test to show how you invoke the API.
Thanks Sebastian. Infos below:
process definition : (Same as examples/taskform)
| <?xml version="1.0" encoding="UTF-8"?>
|
| <process name="VacationRequest" xmlns="http://jbpm.org/4.0/jpdl">
| <start form="org/jbpm/examples/taskform/request_vacation.ftl" g="16,56,48,48" name="start">
| <transition to="verify_request"/>
| </start>
| <task candidate-users="mike,peter" form="org/jbpm/examples/taskform/verify_request.ftl" g="96,54,178,52" name="verify_request">
| <transition g="-34,9" name="reject" to="vacation_rejected"/>
| <transition g="-46,-26" name="accept" to="vacation_accepted"/>
| </task>
| <end g="306,16,48,48" name="vacation_accepted"/>
| <end g="306,96,48,48" name="vacation_rejected"/>
| </process>
|
I am trying to get all history information of an process instance using Servlet and JSP. Codes below :
ProcessManager:
| public ProcessInstaticeActivityInfo getActivityCoordinatesInfo(String processInstanceId) {
| ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) this
| .getProcessDefinitionByProcessInstanceId(processInstanceId);
| String pdId = processDefinition.getId();
| List<ActivityInfo> activeCoordinates = new ArrayList<ActivityInfo>();
|
| List<ActivityInfo> coordinateList = new ArrayList<ActivityInfo>();
| {
| ActivityInfo activityInfo = new ActivityInfo(processDefinition.getInitial().getCoordinates());
| coordinateList.add(activityInfo);
| List<HistoryActivityInstance> activities = historyService.createHistoryActivityInstanceQuery()
| .executionId(processInstanceId).list();
| for (HistoryActivityInstance activity : activities) {
| String activityName = activity.getActivityName();
| activityInfo = new ActivityInfo(repositoryService.getActivityCoordinates(pdId, activityName));
| activityInfo.setActivityInstance(activity);
| coordinateList.add(activityInfo);
| }
| }
|
| HistoryProcessInstance hpi = getHistoryProcessInstancByProcessInstanceId(processInstanceId);
| String endActivityName = ((HistoryProcessInstanceImpl) hpi).getEndActivityName();
|
| if (endActivityName != null) {
| ActivityCoordinates coordinates = repositoryService.getActivityCoordinates(pdId, endActivityName);
| activeCoordinates.add(new ActivityInfo(coordinates));
| } else {
| Set<String> activityNames = executionService.findExecutionById(processInstanceId)
| .findActiveActivityNames();
| for (String activityName : activityNames) {
| ActivityCoordinates coordinates = repositoryService.getActivityCoordinates(pdId, activityName);
| activeCoordinates.add(new ActivityInfo(coordinates));
| }
| }
| return new ProcessInstaticeActivityInfo(activeCoordinates, coordinateList);
| }
|
Servlet:
| public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
| {
| ProcessManager pm = new ProcessManager();
| String taskId =
| request.getParameter("taskid");
| String piId = request.getParameter("pid");
| ProcessInstaticeActivityInfo processInstaticeActivityInfo = pm.getActivityCoordinatesInfo(piId);
| request.setAttribute("activeActivityInfos", processInstaticeActivityInfo.getActiveActivityInfos());
| request.setAttribute("processedActivityInfos", processInstaticeActivityInfo.getProcessedActivityInfos());
| request.setAttribute("pm",pm);
| response.setContentType("text/html;charset=UTF-8");
| RequestDispatcher dispatcher = request.getRequestDispatcher("st_view.jsp");
| dispatcher.forward(request, response);
| }
|
jsp:
| ProcessManager pm = (ProcessManager)request.getAttribute("pm");
| int id = 0;
| List<ActivityInfo> processedActivityInfos = (List<ActivityInfo>)request.getAttribute("processedActivityInfos"); ;
| List<ActivityInfo> activeActivityInfos = (List<ActivityInfo>)request.getAttribute("activeActivityInfos");
| ActivityCoordinates coordinates;
| HistoryActivityInstance activityInstance;
| for(ActivityInfo info : processedActivityInfos){
| coordinates = info.getCoordinates();
| activityInstance = info.getActivityInstance();
| String elId = "_pai_" + (++id);
| String title = activityInstance==null?"":activityInstance.getActivityName();
| StringBuffer position = new StringBuffer();
| position.append("left:").append(coordinates.getX()+2).append("px;");
| position.append("top:").append(coordinates.getY()+2).append("px;");
| position.append("height:").append(coordinates.getHeight()-10).append("px;");
| position.append("width:").append(coordinates.getWidth()-10).append("px;");
| StringBuffer text = new StringBuffer();
|
| if (activityInstance instanceof HistoryDecisionInstanceImpl) {
| text.append("<b>CompleteTime:</b> ").append(activityInstance.getEndTime());
| String transitionName = ((HistoryActivityInstanceImpl) activityInstance).getTransitionName();
| if("completed".equals(transitionName)){
| ProcessDefinition pd = pm.getProcessDefinitionByProcessInstanceId(request.getParameter("piId"));
| if(pd!=null){
| Activity activity = ((ProcessDefinitionImpl)pd).getActivitiesMap().get(activityInstance.getActivityName());
| if(activity!=null){
| text.append("<br/><b>Transaction:</b> ").append(activity.getDefaultOutgoingTransition().getName());
| }
| }
| } else {
| text.append("<br/><b>Transaction:</b> ").append(transitionName);
| }
| } else if (activityInstance instanceof HistoryTaskInstanceImpl) {
| HistoryTaskInstanceImpl taskInstanceImpl = (HistoryTaskInstanceImpl) activityInstance;
|
|
| text.append("<b>Assignee</b>: ").append(taskInstanceImpl.getHistoryTask().getAssignee());
| text.append("<br/><b>Complete Time:</b> ").append(activityInstance.getEndTime());
| String transitionName = ((HistoryActivityInstanceImpl) activityInstance).getTransitionName();
| if("completed".equals(transitionName)){
| ProcessDefinition pd = pm.getProcessDefinitionByProcessInstanceId(request.getParameter("piId"));
| if(pd!=null){
| Activity activity = ((ProcessDefinitionImpl)pd).getActivitiesMap().get(activityInstance.getActivityName());
| if(activity!=null){
| text.append("<br/><b>Transaction:</b> ").append(activity.getDefaultOutgoingTransition().getName());
| }
| }
| } else {
| text.append("<br/><b>Transaction:</b> ").append(transitionName);
| }
|
| List<HistoryComment> comments = pm.getTaskComments(taskInstanceImpl.getHistoryTask().getId());
| if(comments.size()>0){ // è¡¨ç¤ºææ°çcomment
| text.append("<br/><br/><b>Comments:</b> ").append(comments.get(comments.size()-1).getMessage());
| }
| }
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4261004#4261004
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4261004
16 years, 5 months
[jBPM Users] - Hibernate LazyInitializationException
by remiel512
Hello all,
I have a question in setting Hibernate/jBPM. When I use the api [HistoryTaskInstanceImpl.getHistoryTask], it throws an exception [LazyInitializationException] and shows [could not initialize proxy - no Session]. Anyone knows how to fix it? Really thanks a lot!
=== Environment ==============================
- jBPM Version : 4.1
- Database : oracle
- JDK : 1.6
- Container : which Java version are you using? use 'java -version' to find out
- Configuration : using jbpm.cfg.xml only importing files from the jbpm.jar
lib itself.
- Libraries : no
=== Process ==================================
<?xml version="1.0" encoding="UTF-8"?>
<task candidate-users="mike,peter" form="org/jbpm/examples/taskform/verify_request.ftl" g="96,54,178,52" name="verify_request">
=== API ===================================
past the relevant code snippet that you use to invoke jBPM
=== Stacktrace ==============================
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:498)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.gaia.jbpm.action.GetActiveNodeInfo.execute(GetActiveNodeInfo.java:56)
com.gaia.jbpm.action.GetActiveNodeInfo.doGet(GetActiveNodeInfo.java:33)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
root cause
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:86)
org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:140)
org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
org.jbpm.pvm.internal.history.model.HistoryTaskImpl_$$_javassist_18.getId(HistoryTaskImpl_$$_javassist_18.java)
org.apache.jsp.st_005fview_jsp._jspService(st_005fview_jsp.java:162)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.gaia.jbpm.action.GetActiveNodeInfo.execute(GetActiveNodeInfo.java:56)
com.gaia.jbpm.action.GetActiveNodeInfo.doGet(GetActiveNodeInfo.java:33)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4260972#4260972
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4260972
16 years, 5 months