简体   繁体   English

如何防止 CFEXECUTE 在 PrintStackTrace 之后挂起

[英]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.同时使用/c2>&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.

相关问题 如何将printStackTrace()中的异常写入Java中的文本文件? - How do I write the exception from printStackTrace() into a text file in Java? 在执行试图中断线程(并失败)并继续执行的Java程序后,如何停止Ant挂起? - How do I stop Ant from hanging after executing a java program that attempted to interrupt a thread (and failed) and continued? 如何防止 Eclipse 在启动时挂起? - How do I prevent Eclipse from hanging on startup? 如何从没有printStackTrace的异常中获取stackTrace? - How to get the stackTrace from an exception without printStackTrace? 如何确定挂起的是哪个测试? - How do I determine which test is hanging? 如何调试JVM中的挂起线程? - How do I debug hanging threads in the JVM? 如何解决通过错误消息进行的信息暴露以删除所有e.printstacktrace并将错误记录为自定义消息? - How do i resolve Information Exposure Through an Error Message to remove all the e.printstacktrace and log the error as custom message? 在 animation 之后,如何防止动画组件“弹回”到其原始位置? - How do I keep animated components from “bouncing back” to their original positions after animation? 如何更改Exception的printStacktrace()函数? - How can I change what printStacktrace() does for Exception? 我从CDT项目中获得了IConfiguration,从项目中删除后如何保存它的副本以供使用? - I have IConfiguration obtained from a CDT project, how do I keep a copy of it for use after deleting it from project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM