Author |
Message
|
raghav |
Posted: Wed Jun 15, 2005 5:58 am Post subject: Need info on calling a java prog from an automatic activity |
|
|
Novice
Joined: 15 Apr 2005 Posts: 24
|
Hi,
Below is the fdl which iam referring to
############################
CREATE STRUCTURE 'DS_TestWF2'
'blnIsProgram2': STRING;
END 'DS_TestWF2'
/*
* PROGRAMs
*/
CREATE PROGRAM 'Dummy_TestWF2' ( 'DS_TestWF2', 'DS_TestWF2' )
DESCRIPTION ""
NO STRUCTURES_FROM_ACTIVITY
NOT UNATTENDED
AIX EXE PATH_AND_FILENAME "/projects/users/wftest/dummy_wf2.sh"
INHERIT ENVIRONMENT
DO NOT RUN_IN_XTERM
WINNT EXE PATH_AND_FILENAME "java.exe"
PARAMETER ""
INHERIT ENVIRONMENT
STYLE VISIBLE
START FOREGROUND
END 'Dummy_TestWF2'
/*
* PROCESSes
*/
/*
* PROCESS TESTWF2
*/
CREATE PROCESS 'TESTWF2' ( 'DS_TestWF2', 'DS_TestWF2' )
DO NOT PROMPT_AT_PROCESS_START
WINDOW VIEW_REFERENCE_POINT XPOS 0 YPOS 270
WINDOW SHOW ALL CONNECTORS
WINDOW SHOW NO CONDITIONS
SOURCE 1 XPOS -700 YPOS 300
SINK 1 XPOS 600 YPOS -200
PROGRAM_ACTIVITY 'Program1' ( 'DS_TestWF2', 'DS_TestWF2' )
DESCRIPTION "Program1"
START MANUAL WHEN AT_LEAST_ONE CONNECTOR TRUE
EXIT AUTOMATIC
LAYOUT XPOS -100 YPOS 300
NAME_POSITION XPOS -100 YPOS 225
PRIORITY DEFINED_IN INPUT_CONTAINER
DONE_BY PERSON 'ADMIN'
PROGRAM 'Dummy'
SYNCHRONIZATION NESTED
END 'Program1'
PROGRAM_ACTIVITY 'Program2' ( 'DS_TestWF2', 'DS_TestWF2' )
DESCRIPTION "Program2"
START AUTOMATIC WHEN AT_LEAST_ONE CONNECTOR TRUE
EXIT AUTOMATIC WHEN "_RC=0" XPOS -100 YPOS -450
LAYOUT XPOS -100 YPOS -300
NAME_POSITION XPOS -100 YPOS -375
PRIORITY DEFINED_IN INPUT_CONTAINER
DONE_BY PERSON 'ADMIN'
PROGRAM 'Dummy_TestWF2'
SYNCHRONIZATION NESTED
END 'Program2'
CONTROL
FROM 'Program1' TO 'Program2'
WHEN "blnIsProgram2 = ""true"""
XPOS 300 YPOS -25
LAYOUT
XPOS 300 YPOS 0
DATA
FROM SOURCE 1 TO 'Program1'
MAP '_STRUCT' TO '_STRUCT'
DATA
FROM 'Program1' TO 'Program2'
MAP '_STRUCT' TO '_STRUCT'
DATA
FROM 'Program2' TO SINK 1
MAP '_STRUCT' TO '_STRUCT'
END 'TESTWF2'[/size]
##############################
Now, in this process, there are 2 Program Activities.
1) Program1:- This is a Manual Activity and the associated Program for this is "Dummy". Control will move from program1 to program2 when the field 'blnIsProgram2' is set to true.
2) Program2 :- This is an Automatic Activity. Associated program is 'Dummy_TestWF2'. This calls a shell script 'dummy_wf2.sh', if environment is AIX.
Content of the shell script is
****************************************
# Set the Environment
echo 'Calling the java pgm' >> test_dummy.out
echo "Begin Execution"
echo "inside dummy_wf2.sh"
# Call the Interface Program
java CreateDummyFile
echo "End Execution"
****************************************
Problem:- Iam trying to call a class file 'CreateDummyFile', but not able to do the same.
Observation:- Once control moves from Program1 to Program2, work item is getting terminated without the class file 'CreateDummyFile' getting called.
Point to be noted:- Version of MQ in AIX is
mqver
Version: 530.6 CSD06
Please help me in this and give your inputs in how to call a java program from
i) an automatic activity and
ii) a manual activity.
exclusively in AIX.
Thanks & Regards,
Raghav. |
|
Back to top |
|
 |
jmac |
Posted: Wed Jun 15, 2005 7:00 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Jun 2001 Posts: 3081 Location: EmeriCon, LLC
|
You have in your program the following:
Code: |
WINNT EXE PATH_AND_FILENAME "java.exe"
PARAMETER "" |
You need to add the classname is as the parameter, also make sure java.exe is in the path.
However, I would not be having an automatic activity that is nonUPES today. I would say that is a mistake. _________________ John McDonald
RETIRED |
|
Back to top |
|
 |
raghav |
Posted: Wed Jun 15, 2005 3:44 pm Post subject: |
|
|
Novice
Joined: 15 Apr 2005 Posts: 24
|
Is it advisible to remove the portion:
Code: |
WINNT EXE PATH_AND_FILENAME "java.exe"
PARAMETER ""
INHERIT ENVIRONMENT
STYLE VISIBLE
START FOREGROUND |
Usage of nonUPES - is due to the simplicity in our application architecture |
|
Back to top |
|
 |
jmac |
Posted: Wed Jun 15, 2005 3:55 pm Post subject: |
|
|
 Jedi Knight
Joined: 27 Jun 2001 Posts: 3081 Location: EmeriCon, LLC
|
OK.... I missed the exclusively in AIX part The whole Windows portion of the program object is moot if you are running on AIX
What state is the previous activity in?
Can you run your java program from a command prompt? _________________ John McDonald
RETIRED |
|
Back to top |
|
 |
raghav |
Posted: Wed Jun 15, 2005 4:13 pm Post subject: |
|
|
Novice
Joined: 15 Apr 2005 Posts: 24
|
Yes, I can run the Java program from the command prompt.
I start a shell script first that calls a java program.
This program creates a process instance and starts it.
Control is then transferred to the next activity which is manual.
Here, the workitem gets created and is visible on the client.
I further run another shell script that again calls a java program to trigger the manual activity.
This activity gets completed successfully (A log file is updated as a result).
The next activity is an automatic activity that is not getting executed...
The shell script, which calls a java pgm is not getting called from workflow...
Inside this script, we have a statement that writes to a file like:
Code: |
echo testing >> test.txt |
Referring to the above code, test.txt is not getting created. The workitem disappears as soon as the manual activity is completed... |
|
Back to top |
|
 |
jmac |
Posted: Wed Jun 15, 2005 4:30 pm Post subject: |
|
|
 Jedi Knight
Joined: 27 Jun 2001 Posts: 3081 Location: EmeriCon, LLC
|
What state are both activities in? I take it from your last reply that the first activity is in a finished state. _________________ John McDonald
RETIRED |
|
Back to top |
|
 |
raghav |
Posted: Wed Jun 15, 2005 4:42 pm Post subject: |
|
|
Novice
Joined: 15 Apr 2005 Posts: 24
|
The first activity is in a finished state.
Then there is no workitem visible for the second activity...
Process instance also gets deleted from the client... |
|
Back to top |
|
 |
jmac |
Posted: Wed Jun 15, 2005 5:01 pm Post subject: |
|
|
 Jedi Knight
Joined: 27 Jun 2001 Posts: 3081 Location: EmeriCon, LLC
|
If there is no ProcessInstance then the 2nd activity has completed.
My guess is that your transition condition is not met, so the instance is complete after the first activity.
Your transition condition is blnIsProgram2 = "true"
I bet you that the value of this memeber is NOT the string "true". _________________ John McDonald
RETIRED |
|
Back to top |
|
 |
raghav |
Posted: Thu Jun 16, 2005 4:40 am Post subject: |
|
|
Novice
Joined: 15 Apr 2005 Posts: 24
|
Hi,
There are two ways which says Iam setting String "true" only.
1) I rechecked the code. Iam updating a string "true" only. Below is the line of java code used to set the value.
Code: |
outContainer.setString("blnIsProgram2", "true"); |
2) I had changed the 2nd activity from automatic to manual. And created one more (3rd one) manual activity, connected to 1st activity such that,
control will move from
1st Activity to 2nd Activity if "blnIsProgram2 = ""true"""
and
1st Activity to 3rd Activity if "blnIsProgram2 <> ""true"""
#######################
CONTROL
FROM 'Program1' TO 'Program3'
WHEN "blnIsProgram2 <> ""true"""
XPOS 256 YPOS 181
LAYOUT
XPOS 300 YPOS 200
#######################
and observed that control is moving to Program2 only. That means blnIsProgram2 is set to string "true" only.
So, please let me know what else could be the reason for this problem.
Thanks & Regards,
Raghav. |
|
Back to top |
|
 |
mqmhr |
Posted: Thu Jun 16, 2005 5:11 am Post subject: |
|
|
Centurion
Joined: 28 Dec 2004 Posts: 105
|
Quote: |
and observed that control is moving to Program2 only |
How did you verify this Raghav?
And how do you verify that the CreateDummyFile class is not getting called? |
|
Back to top |
|
 |
jmac |
Posted: Thu Jun 16, 2005 5:20 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Jun 2001 Posts: 3081 Location: EmeriCon, LLC
|
raghav wrote: |
Hi,
There are two ways which says Iam setting String "true" only.
1) I rechecked the code. Iam updating a string "true" only. Below is the line of java code used to set the value.
Code: |
outContainer.setString("blnIsProgram2", "true"); |
|
How are you accessing the output container. Please show ALL the code.
You keep giving more information a little bit at a time. Please give me everything this time.
I could take another guess, but I would rather wait until I see all the code. _________________ John McDonald
RETIRED |
|
Back to top |
|
 |
raghav |
Posted: Thu Jun 16, 2005 5:33 am Post subject: |
|
|
Novice
Joined: 15 Apr 2005 Posts: 24
|
Following is the java code for the manual activity:
Code: |
public class ProcessTestWF2 {
public static void main(String[] args) {
WFManager wfm = new WFManager();
try {
System.out.println("inside ProcessTestWF2");
wfm.login("ADMIN", "password");
System.out.println("logged in");
WorkItem wkItem[] = wfm.getWorkItems(null, "Program1");
System.out.println("got work item");
// Input Container
ReadOnlyContainer inContainer = wfm.getInputContainer(wkItem[0]);
// Initiate the Work Item - to be used with manual activities
wfm.startWork(wkItem[0]);
System.out.println("checked out work item");
// Output Container
ReadWriteContainer outContainer =
inContainer.asReadWriteContainer();
// Set Output Container values
outContainer.setString("blnIsProgram2", "true");
System.out.println("blnIsProgram2 is set to true");
// Finish the work Item - to be used with manual activities
wfm.finishWork(wkItem[0], outContainer);
System.out.println("checked in work item");
System.out.println("Logoff");
wfm.logoff();
} catch (PropertyVetoException e) {
} catch (FmcException e) {
}
}
} |
And following is the code for the automatic activity:
Code: |
public class CreateDummyFile {
public static void main(String[] args) {
System.out.println("inside CreateDummyFile ");
try {
Agent wfAgent = new Agent();
wfAgent.setLocator(Agent.LOC_LOCATOR);
wfAgent.setName("LOCAL");
System.out.println("after setting the name");
ExecutionAgent pea = wfAgent.getExecutionAgent( );
if (pea != null) {
// get the input- and output container
ReadOnlyContainer input = pea.inContainer();
ReadWriteContainer output = pea.outContainer();
// display all input container members
System.out.println("Input Container:");
// copy the data members from the input- to the output container
output.setLong("_RC", 0);
// display all output container members
System.out.println("Output Container:");
// return the output container to the PEA
pea.setOutContainer(output);
}
// Logout of Workflow
System.out.println("Logoff");
} catch (FmcException fmc) {
fmc.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
try {
File file = null;
Writer fileWriter = null;
file =
new File("/projects/temp/wftest/NewFile.txt");
fileWriter = new BufferedWriter(new FileWriter(file));
fileWriter.write("Hi. Success");
System.out.println("after writing success ");
fileWriter.flush();
fileWriter.close();
Thread.sleep(1000);
System.out.println("end ");
} catch (Exception e) {
e.printStackTrace();
try {
Thread.sleep(1000);
} catch (InterruptedException ie2) {
ie2.printStackTrace();
}
}
}
} |
|
|
Back to top |
|
 |
jmac |
Posted: Thu Jun 16, 2005 6:00 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Jun 2001 Posts: 3081 Location: EmeriCon, LLC
|
There is nothing I see in the code that looks suspicious.
WHAT state is the "Program2" activity in? You indicated that you added a third step and that you know that activity 2 got control, but I want to know what state it is in?
How are you looking at things? Are you using the IBM Windows fat client? _________________ John McDonald
RETIRED |
|
Back to top |
|
 |
raghav |
Posted: Mon Jun 20, 2005 5:42 am Post subject: |
|
|
Novice
Joined: 15 Apr 2005 Posts: 24
|
Hi,
State of program2 is "Ready". And we are using Workflow V3.4 runtime client to view the status of work items.
Last edited by raghav on Mon Jun 20, 2005 5:56 am; edited 1 time in total |
|
Back to top |
|
 |
jmac |
Posted: Mon Jun 20, 2005 5:52 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Jun 2001 Posts: 3081 Location: EmeriCon, LLC
|
If the state is ready, and the activity is automatic using PEA, it means that there is no user eligible to run the activity currently logged in with a "Present" session. _________________ John McDonald
RETIRED |
|
Back to top |
|
 |
|