-
1. Re: How to add Java code to the jbpm process
baltajino Oct 10, 2011 5:45 AM (in response to jaiyachandhiran)Hi,
well if you are definig the proces through the diagram, you can do the following steps:
- Create a class under the following Package com.xxx.yyy.workflow.action. call it MyClassHandler
- MyClassHandler should implement org.jbpm.graph.def.ActionHandler.
- in execute Method you should implement what you like to do (call EJB, orsystem.out, call database, change process variables....)
- Go to your processdefinition.xml diagram
- Select the node to which you want to assign an action
- under Properties View, select Action tab
- select Configure Action
- go to Details and add the class name that implements your node action. For example : com.xxx.yyy.workflow.action.MyClassHandler
- choose "Field" as a Config Type
- select Handler in the dropdown list
- Save the process Definition
This description is for a simple node. Some changes mut be done for Decision nodes or other components.
Hopefully it helped
Regards
-
2. Re: How to add Java code to the jbpm process
jaiyachandhiran Oct 10, 2011 6:42 AM (in response to baltajino)Hi
Thanks for ur reply
I just wrote system.out.println for testing. I just used 2 activties one is start state and other is the node in which i have called the action handler.
i just deployed the process and when i start the process using jbpm console , i am unable to move too next node from start.
In jpmn console it asks for me to Choose Target Node but i am unable to choose? why
How to check the code written inside the action handler?
-
3. Re: How to add Java code to the jbpm process
jaiyachandhiran Oct 10, 2011 6:48 AM (in response to jaiyachandhiran)Hi
I am having another doubt. Where i will see the action output? For e.g, I have written system.out.println("Hello"), Where i will get this output
-
4. Re: How to add Java code to the jbpm process
baltajino Oct 10, 2011 7:04 AM (in response to jaiyachandhiran)Well i am not familiar with JBPM, but as a hint can you try to debug. Normally you should see sysout output in the run console.
Can you post more information about your process maybe the xml and a screenshot of the process definition.
Regards
-
5. Re: How to add Java code to the jbpm process
jaiyachandhiran Oct 10, 2011 7:39 AM (in response to baltajino)Hi
Thanks for ur reply. Now i have created a simple process and wrote a simple java code.
Java Code
public void execute(ExecutionContext executionContext) throws Exception {
// TODO Auto-generated method stub
String query = "SELECT login_name from rs_users";System.out.println("Testing JAVA Code");
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","resonancedev","resonancedev");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
String message = rs.getString("login_name");
System.out.println("name-->" +message);
}
con.close();//executionContext.getContextInstance().setVariable("message", message);
}I tried to start the process from console and i get the below error.
Failed to start process: class 'oracle.jdbc.driver.OracleDriver' could not be found by the process classloader
I have added the jar file to the project, I need to know where to add this jar file?
Please reply me
-
processimage.jpg 11.7 KB
-
-
6. Re: How to add Java code to the jbpm process
baltajino Oct 10, 2011 8:09 AM (in response to jaiyachandhiran)Well now you are jumping to another problem.
Try to add the jar file to the class path of your project.
If you are facing further problems which are not related ot jbpm, make sure to post a new thread and in the right place.
p.s.
- Try to add an end state to you process, cause you "may" face further problems.
- executionContext.leaveNode(); // to leave the node after action execution
Regards
-
7. Re: How to add Java code to the jbpm process
jaiyachandhiran Oct 11, 2011 12:13 AM (in response to baltajino)Hi
Sorry for the late reply, Sorry for jumping from one problem to another,
The Same Error Failed to start process: class 'oracle.jdbc.driver.OracleDriver' could not be found by the process classloader is coming
I added the appropriate jar in the classpath,
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/config"/>
<classpathentry kind="src" path="src/main/jpdl"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="JBPM/JBoss jBPM 3.2.GA"/>
<classpathentry exported="true" kind="lib" path="E:/Softwares/jbpm-jpdl-3.2.GA/ojdbc14.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
and also i have attached the screen shot of properties tab of that project. I have added the jar there also. But i don't know where i need to add these jar
Please help me out
-
Capture.JPG 77.1 KB
-
-
8. Re: How to add Java code to the jbpm process
baltajino Oct 11, 2011 3:06 AM (in response to jaiyachandhiran)1 of 1 people found this helpfultry to read this thread here: http://www.java-forums.org/new-java/2665-java-lang-classnotfoundexception-oracle-jdbc-driver-oracledriver.html
The last reply may help
-
9. Re: How to add Java code to the jbpm process
jaiyachandhiran Oct 13, 2011 5:27 AM (in response to baltajino)Hi
Thanks for ur reply
The problem is resolved. The solution is Put the ojdbc14.jar in jbpm-jpdl-3.2.GA\server\server\jbpm\deploy folder. Now it works
Thanks