如何解决 ColdFusion 9 中的 Java 空指针错误?

发布于 2024-12-27 14:45:00 字数 1260 浏览 1 评论 0原文

我正在使用 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)>

您能否向我提供有关此错误的真正含义以及我下一步可能要查看的位置的任何线索?

编辑:

我无法确定我的问题是什么,但我开始以不同的方式解决它。我找到了一个可以正常工作的文件,然后慢慢地重建它,一路上对其进行了 100 次测试。

非常感谢您的提示和提示!

I am using ColdFusion 9.1.0.

I am working on part of a site that someone else developed a while back. That someone is gone and there is no documentation. I can access the CF Administrator, but I can't find anything that helps me with a specific problem.

In the code below, a Java object is created (auth) and then in the next line, the object is referenced. Two variables are passed to the method (runTransaction), the properties file (VARIABLES.PropsFile) and the XML (VARIABLES.MyXML).

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

The object is successfully created. I know this because when I change the class of the object, it blows up! When I change it back to "CyberSource", it works.

I know that the properties file exists. I know that the XML exists.

The error I get is this:

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)>

Can you provide me with any clues as to what this error really means and where I might look next?

EDIT:

I can't pinpoint what my problem WAS, but I went about solving it a different way. I found a file that WAS working and slowly rebuilt it, testing it 100 times along the way.

Many thanks for the tips and hints!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南冥有猫 2025-01-03 14:45:00

根据文档,用 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>

所有平台 Java zip 中都有一些 Coldfusion 示例,可在此处下载:

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

As per the documentation, wrap your auth.runTransaction() with a try/catch.

The following snippet comes from the samples included with the CyberSource 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>

There are some coldfusion samples inside the All Platforms Java zip downloadable here:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文