I\'m using ColdFusion MX7 to perform a CFEXECUTE on some Java 6 code.
Unfortunately, since CF7 does not work under JDK 6 I must do it this way.
My problem
Yes, e.printStackTrace();
writes to stderr (standard error stream). Since cfexecute
does not capture stderr, that is probably what is causing cfexecute to hang. There was a patch to fix this behavior in CF8.
Since you are using 7, try Ben Forta's tips about:
Using both /c
and 2>&1
should get rid of the hanging problem.
Update: Added Example
ColdFusion Code:
<cftry>
<cfset argString = '/c "C:\Program Files\Java\jdk1.6.0_13\bin\java.exe" -cp c:\myJar.jar TestStdErr 2>&1' >
<cfexecute name="c:\windows\system32\cmd.exe"
arguments="#argString#"
outputFile="c:\cfexcuteResults.log"
timeout="5" />
<cfcatch>
<cfdump var="#cfcatch#">
</cfcatch>
</cftry>
Java Class:
public class TestStdErr {
public static void main(String[] args) {
try {
// cause a divide by zero exception
int a = 0;
int b = 2 /a;
}
catch(Exception e){
e.printStackTrace();
}
}
}