如何在ColdFusion 9中解决Java中的Null Pointers错误?

时间:2012-01-17 15:19:13

标签: coldfusion coldfusion-9

我正在使用ColdFusion 9.1.0。

我正在研究其他人开发的网站的一部分。有人走了,没有文件。我可以访问CF管理员,但我找不到任何可以帮助我解决特定问题的事情。

在下面的代码中,创建一个Java对象(auth),然后在下一行中引用该对象。两个变量传递给方法(runTransaction),属性文件(VARIABLES.PropsFile)和XML(VARIABLES.MyXML)。

<cfobject action="create" type="Java" class="CyberSource" name="auth">
<cfset VARIABLES.ResponseString = auth.runTransaction(VARIABLES.PropsFile,VARIABLES.MyXML)>

已成功创建对象。我知道这是因为当我改变对象的类时,它会爆炸!当我将其更改回“Cyber​​Source”时,它可以正常工作。

我知道属性文件存在。我知道XML存在。

我得到的错误是:

The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.

Null Pointers are another name for undefined values.

The error occurred in D:/inetpub/wwwroot/Watkins_OE-DEV/Test.cfm: line 63

61 : <!--- CREATE JAVA OBJECT --->
62 : <cfobject action="create" type="Java" class="CyberSource" name="auth">
63 : <cfset VARIABLES.ResponseString = auth.runTransaction(VARIABLES.PropsFile,VARIABLES.MyXML)>

你能否告诉我这个错误究竟意味着什么以及我接下来会在哪里看到的任何线索?

编辑:

我无法确定我的问题是什么,但我开始以不同的方式解决它。我找到了一个WAS正在工作并缓慢重建的文件,在此过程中对其进行了100次测试。

非常感谢提示和提示!

1 个答案:

答案 0 :(得分:0)

根据文档,使用try / catch包装auth.runTransaction()。

以下代码段来自Cyber​​Source java api附带的示例:

<!--- Change this to point to your property file --->
<cfset propsFile = "full_path_to/coldfusion/samples/cybs.properties">

<!--- Change this to point to your request file --->
<cffile action="Read" file="full_path_to/coldfusion/samples/xml/request.xml" variable="requestString">

<cfobject action="create" type="Java" class="CyberSource" name="auth">
<cfxml variable="requestDoc">
    <cfoutput>#requestString#</cfoutput>
</cfxml>
<cfdump label="Request" var="#requestDoc#">

<cftry>

<!--- make the call --->
<cfset responseString = auth.runTransaction(propsFile,requestString)>

<!--- cast the response to xml --->
<cfxml variable="responseDoc">
<cfoutput>#responseString#</cfoutput>
</cfxml>
<cfdump label="Response" var="#responseDoc#">

<!--- exception handling --->
<cfcatch type="com.cybersource.ws.client.ClientException">
    <cfoutput><b>Exception Message:</b> #cfcatch.message#</cfoutput><br><br>
    <cfdump label="com.cybersource.ws.client.ClientException" var=#cfcatch#>
</cfcatch>

<cfcatch type="com.cybersource.ws.client.FaultException">
    <cfoutput><b>Exception Message:</b> #cfcatch.message#</cfoutput><br><br>
    <cfdump label="com.cybersource.ws.client.FaultException" var=#cfcatch#>
</cfcatch>

</cftry>

在这里可以下载All Platforms Java zip中的一些coldfusion示例:

http://apps.cybersource.com/cgi-bin/pages/dev_kits.cgi?kit=Java/All_Platforms