[英]How do I keep CFEXECUTE from hanging after a PrintStackTrace
I'm using ColdFusion MX7 to perform a CFEXECUTE on some Java 6 code.我正在使用 ColdFusion MX7 对某些 Java 6 代码执行 CFEXECUTE。
Unfortunately, since CF7 does not work under JDK 6 I must do it this way.不幸的是,由于 CF7 不能在 JDK 6 下工作,我必须这样做。
My problem is that when an exception happens in the Java code if I call a printStackTrace
on the exception the CFEXECUTE command hangs.我的问题是,当 Java 代码中发生异常时,如果我对异常调用
printStackTrace
,CFEXECUTE 命令将挂起。 ColdFusion eventually times out but the Java process continues to hang in the background. ColdFusion 最终超时,但 Java 进程继续在后台挂起。
I'm guessing there is some blocking going on but I can't seem to figure out why.我猜有一些阻塞正在进行,但我似乎无法弄清楚为什么。
If I don't do a printStackTrace
then everything works fine.如果我不执行
printStackTrace
,那么一切正常。
The exceptions are WebService exceptions generated with JAXWS from the Oracle Information Rights Management wsdl.异常是使用 JAXWS 从 Oracle 信息权限管理 wsdl 生成的 WebService 异常。
EDIT
编辑
I noticed that I am able to call the printStackTrace
with a file PrintStream
as a parameter and it works fine.我注意到我可以使用文件
PrintStream
作为参数调用printStackTrace
,它工作正常。 So, it looks like the error stream is having troubles.所以,看起来错误 stream 有问题。
Here is the Java Code:这是 Java 代码:
public void Execute(){
AdminUtils AU = AdminUtils.GetInstance();
AccountServicesPort AA = AU.GetAccountServicesPort();
LicenseServerRef LicSerRef = AU.GetLicenseServerRef();
User UserToSave = new User();
UserToSave.setUserName(UserName);
UserToSave.setFirstName(FirstName);
UserToSave.setLastName(LastName);
UserToSave.setEmailAddress(EmailAddress);
UserToSave.setServer(LicSerRef);
try{
AU.LogMessage("Change User: " + UserName + " " + FirstName + " " + LastName + " " + EmailAddress);
AA.saveChangesToUser(UserToSave);
}catch(Exception e){
e.printStackTrace();
}
}
Here is the ColdFusion call:这是 ColdFusion 电话:
<!--- Update the IRM User. --->
<CFEXECUTE name="c:\Program Files\Java\jdk1.6.0_14\bin\javaw.exe"
arguments="-cp C:\CFusionMX7\Externals\IRM.jar;C:\CFusionMX7\Externals\Config IRMWebServices.UpdateUser #LoginID# #NewFname# #NewLname#"
timeout="15"
variable="OUTPUT">
</CFEXECUTE>
Yes, e.printStackTrace();
是的,
e.printStackTrace();
writes to stderr (standard error stream).写入 stderr(标准错误流)。 Since
cfexecute
does not capture stderr, that is probably what is causing cfexecute to hang.由于
cfexecute
不捕获 stderr,这可能是导致 cfexecute 挂起的原因。 There was a patch to fix this behavior in CF8. CF8 中有修复此行为的补丁。
Since you are using 7, try Ben Forta's tips about:由于您使用的是 7,请尝试 Ben Forta 的提示:
Using both /c
and 2>&1
should get rid of the hanging problem.同时使用
/c
和2>&1
应该可以解决挂起问题。
Update: Added Example更新:添加示例
ColdFusion Code: ColdFusion 代码:
<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: 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();
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.