[JBoss jBPM] - Re: is it possible to force the token jump from one node to
by dleerob
Here is a method I use (in my own framework), to re-route a token.
It may be simpler for you, but the way we do things in our app, this worked for us. Hopefully you can use it or get some ideas:
private void rerouteToken (HttpServletRequest request, ActionErrors errors, ActionMessages messages, ProcessInstance processInstance) {
| User currentUser = getUser(request);
| String tokenId = request.getParameter(Constants.PROCESS_ADMIN_ACTION_TOKEN_ID);
| String nodeName = request.getParameter(Constants.PROCESS_ADMIN_ACTION_NODE_NAME);
| log.info("A token re-route was requested by user '"+currentUser.getUsername()+"' for tokenId '"+tokenId+"' to node '"+nodeName+"'");
| if (tokenId == null || tokenId.equals("")) {
| String errorMsg = "Cannot reroute token, as no tokenId was specified.";
| log.error(errorMsg);
| errors.add(ActionMessages.GLOBAL_MESSAGE,
| new ActionMessage("errors.customMessage",errorMsg));
| return;
| }
| if (nodeName == null || nodeName.equals("")) {
| String errorMsg = "Cannot reroute token, as no node name was specified.";
| log.error(errorMsg);
| errors.add(ActionMessages.GLOBAL_MESSAGE,
| new ActionMessage("errors.customMessage",errorMsg));
| return;
| }
| Token token = jbpmContext.getToken(Long.parseLong(tokenId));
| if (token == null) {
| String errorMsg = "Cannot reroute token, as token with ID '"+tokenId+"' was not found.";
| log.error(errorMsg);
| errors.add(ActionMessages.GLOBAL_MESSAGE,
| new ActionMessage("errors.customMessage",errorMsg));
| return;
| }
|
| Node newNode = processInstance.getProcessDefinition().getNode(nodeName);
| //don't allow re-route if Start Node was selected.
| if (newNode.getId() == newNode.getProcessDefinition().getStartState().getId()) { //if new node is start node
| String errorMsg = "Cannot re-route token to a Start State. You should rather start a new process.";
| log.error(errorMsg);
| errors.add(ActionMessages.GLOBAL_MESSAGE,
| new ActionMessage("errors.customMessage",errorMsg));
| }
| else {
| //---process reroute---
| //Cancel current incomplete task instances-------------------------------------------------------------
| log.info("Removing task instances found at token with ID '"+tokenId+"'");
| List deleteTaskInstanceList = new ArrayList();
| //create a seperate list of those task instances to delete. If deleting them
| //straight from iterator, a ConcurrentModificationException will occur when calling it.next();
| for(Iterator it = processInstance.getTaskMgmtInstance().getTaskInstances().iterator();it.hasNext();) {
| TaskInstance taskInstance = (TaskInstance)it.next();
| if(tokenId.equals(taskInstance.getToken().getId()+"")) {
| if (taskInstance.getEnd() == null) { //not complete task
| deleteTaskInstanceList.add(taskInstance);
| }
| }
| }
| for (int x = 0; x < deleteTaskInstanceList.size(); x++) {
| TaskInstance taskInstance = (TaskInstance)deleteTaskInstanceList.get(x);
| //Clear local variables-----------------------------------------------
| //We must clear local variables, or task instance will save variables
| //from previous instance. We must not delete them, but rather set them
| //to blank, or an exception will be thrown if the variables were
| //set to 'required' in the process definition.
| Map localVariables = taskInstance.getVariablesLocally();
| for (Iterator it = localVariables.keySet().iterator();it.hasNext();) {
| String variableName = (String)it.next();
| taskInstance.setVariableLocally(variableName, "");
| }
| //--------------------------------------------------------------------
| log.info("Cancelling task instance with ID '"+taskInstance.getId()+"'");
| boolean overwriteSwimlane = false; //don't overwrite swimlane actor
| taskInstance.setActorId("[rerouted by "+currentUser.getUsername()+"]", overwriteSwimlane);
| taskInstance.setSignalling(false);
| //Workaround to stop task-end event from firing when we cancel a task instance.
| //Remove event, cancel task instance, add event again-----------------
| Task task = taskInstance.getTask();
| Event endTaskEvent = task.getEvent(Event.EVENTTYPE_TASK_END);
| if (endTaskEvent != null) {
| task.removeEvent(endTaskEvent);
| }
| taskInstance.cancel();
| if (endTaskEvent != null) {
| task.addEvent(endTaskEvent);
| }
| //-------------------------------------------------------------------
| }
| //-----------------------------------------------------------------------------------------------------
| newNode.enter(new ExecutionContext(token));
| //log info
| String msg = "Token with ID '"+token.getId()+"' was rerouted to node '"+nodeName+"'";
| log.info(msg);
| messages.add(ActionMessages.GLOBAL_MESSAGE,
| new ActionMessage("messages.customMessage", msg));
| }
|
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4145737#4145737
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4145737
18 years
[Installation, Configuration & DEPLOYMENT] - Re: Persistence config with mysql.
by 2lopez
Argggg what a stupid error... Thank you (A LOT) for your help, jairikan. Persistence errors seem gone on the log. I have just another problem, Although persistence seems ok, the war doesn't deploy...
=========================================================================
|
| JBoss Bootstrap Environment
|
| JBOSS_HOME: /home/encore/jboss-4.0.4.GA
|
| JAVA: /usr/local/jdk1.5/bin/java
|
| JAVA_OPTS: -server -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dprogram.name=run.sh
|
| CLASSPATH: /home/encore/jboss-4.0.4.GA/bin/run.jar:/usr/local/jdk1.5/lib/tools.jar
|
| =========================================================================
|
| 11:01:16,206 INFO [Server] Starting JBoss (MX MicroKernel)...
| 11:01:16,207 INFO [Server] Release ID: JBoss [Zion] 4.0.4.GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000)
| 11:01:16,209 INFO [Server] Home Dir: /home/encore/jboss-4.0.4.GA
| 11:01:16,209 INFO [Server] Home URL: file:/home/encore/jboss-4.0.4.GA/
| 11:01:16,210 INFO [Server] Patch URL: null
| 11:01:16,210 INFO [Server] Server Name: default
| 11:01:16,210 INFO [Server] Server Home Dir: /home/encore/jboss-4.0.4.GA/server/default
| 11:01:16,210 INFO [Server] Server Home URL: file:/home/encore/jboss-4.0.4.GA/server/default/
| 11:01:16,210 INFO [Server] Server Log Dir: /home/encore/jboss-4.0.4.GA/server/default/log
| 11:01:16,210 INFO [Server] Server Temp Dir: /home/encore/jboss-4.0.4.GA/server/default/tmp
| 11:01:16,229 INFO [Server] Root Deployment Filename: jboss-service.xml
| 11:01:16,727 INFO [ServerInfo] Java version: 1.5.0_15,Sun Microsystems Inc.
| 11:01:16,727 INFO [ServerInfo] Java VM: Java HotSpot(TM) Server VM 1.5.0_15-b04,Sun Microsystems Inc.
| 11:01:16,727 INFO [ServerInfo] OS-System: Linux 2.6.22-14-generic,i386
| 11:01:17,581 INFO [Server] Core system initialized
| 11:01:28,844 INFO [WebService] Using RMI server codebase: http://encore-portatil:8083/
| 11:01:28,868 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resource:log4j.xml
| 11:01:29,349 INFO [NamingService] JNDI bootstrap JNP=/0.0.0.0:1099, RMI=/0.0.0.0:1098, backlog=50, no client SocketFactory, Server SocketFactory=class org.jboss.net.sockets.DefaultSocketFactory
| 11:01:34,862 INFO [MailService] Mail Service bound to java:/Mail
| 11:01:35,132 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-ha-local-jdbc.rar
| 11:01:35,167 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-ha-xa-jdbc.rar
| 11:01:35,267 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-local-jdbc.rar
| 11:01:35,356 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-xa-jdbc.rar
| 11:01:35,384 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/mail-ra.rar
| 11:01:36,309 INFO [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'DefaultDS'
| 11:01:37,135 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
|
| --- Packages waiting for a deployer ---
| org.jboss.deployment.DeploymentInfo@fef83e5 { url=file:/home/encore/jboss-4.0.4.GA/server/default/deploy/CAC.war }
| deployer: null
| status: null
| state: INIT_WAITING_DEPLOYER
| watch: file:/home/encore/jboss-4.0.4.GA/server/default/deploy/CAC.war
| altDD: null
| lastDeployed: 1208854897134
| lastModified: 1208854896000
| mbeans:
|
| --- Incompletely deployed packages ---
| org.jboss.deployment.DeploymentInfo@fef83e5 { url=file:/home/encore/jboss-4.0.4.GA/server/default/deploy/CAC.war }
| deployer: null
| status: null
| state: INIT_WAITING_DEPLOYER
| watch: file:/home/encore/jboss-4.0.4.GA/server/default/deploy/CAC.war
| altDD: null
| lastDeployed: 1208854897134
| lastModified: 1208854896000
| mbeans:
|
|
| 11:01:37,685 INFO [Server] JBoss (MX MicroKernel) [4.0.4.GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000)] Started in 21s:454ms
| 11:05:13,992 INFO [Server] Runtime shutdown hook called, forceHalt: true
| 11:05:13,992 INFO [Server] JBoss SHUTDOWN: Undeploying all packages
| 11:05:13,996 INFO [ConnectionFactoryBindingService] Unbound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' from JNDI name 'DefaultDS'
| 11:05:14,035 INFO [MailService] Mail service 'java:/Mail' removed from JNDI
| 11:05:17,504 INFO [Server] Shutdown complete
| Shutdown complete
| Halting VM
I have to confess I'm an "almost novice" at JBoss... The same source is working OK at the production and pre-production machines. Any suggestions?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4145733#4145733
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4145733
18 years
[Installation, Configuration & DEPLOYMENT] - Re: Persistence config with mysql.
by 2lopez
First of all, thanks for your interest and support.
/home/encore/jboss-4.0.4.GA/server/default/deploy/mysql-ds.xml :
<!-- $Id: mysql-ds.xml,v 1.1 2006/07/20 15:05:48 fran Exp $ -->
| <!-- Datasource config for MySQL using 3.0.9 available from:
| http://www.mysql.com/downloads/api-jdbc-stable.html
| -->
|
| <datasources>
|
| <local-tx-datasource>
| <jndi-name>cacv2</jndi-name>
| <connection-url>jdbc:mysql://127.0.0.1:3306/jbossdb</connection-url>
| <driver-class>com.mysql.jdbc.Driver</driver-class>
| <user-name>roberto</user-name>
| <password></password>
| <max-pool-size>200</max-pool-size>
| <blocking-timeout-millis>5000</blocking-timeout-millis>
| <idle-timeout-minutes>1</idle-timeout-minutes>
| <use-java-context>false</use-java-context>
| <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter </exception-sorter-class-name>
| <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
| <metadata>
| <type-mapping>mySQL</type-mapping>
| </metadata>
| </local-tx-datasource>
|
| </datasources>
${JBOSS_HOME}/server/default/conf/standardjaws.xml :
<?xml version="1.0" encoding="UTF-8"?>
|
| <!DOCTYPE jbosscmp-jdbc PUBLIC
| "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN"
| "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">
|
| <!-- ===================================================================== -->
| <!-- -->
| <!-- Standard Jaws Configuration -->
| <!-- -->
| <!-- ===================================================================== -->
|
| <!-- $Id: standardjaws.xml,v 1.30 2002/06/27 19:26:28 dsundstrom Exp $ -->
|
| <jaws>
| <datasource>java:/DefaultDS</datasource>
| <type-mapping>mySQL</type-mapping>
| <debug>false</debug>
| [... standard config copied from the examples ...]
| </jaws>
|
These are the only files modified, if I remember well.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4145725#4145725
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4145725
18 years