2013-09-21 31 views
4

我一直對此感興趣一段時間,似乎無法找到任何像樣的答案或對這些錯誤的解釋。我正在使用第三方JAR「PropHandler.jar」 我想調用getMessageList方法,它接受3個參數,並需要一個配置文件。ColdFusion初始化一個需要外部配置文件的Java對象方法

<cfset configFile = 'C:\data\getMsgListCONFIG.xml'> 
<cfset Obj = createObject("java","client.PropHandler") /> 
<cfdump var="#Obj#"> 


這裏都好,我轉儲返回的方法列表。現在,我需要讓我的配置文件的方法,並通過在我指定參數時,這裏沒有愛情,我已經試過這樣:

<cfset x = Obj.getMessageList.init(configFile)> 

而且

<cfset x = Obj.getMessageList().init(configFile)> 

而且

<cfset x = Obj.getMessageList('identifier', 'greaterthan', '2012-05-18T12:00:00-04:00').init(configFile)> 

甚至嘗試通過創建對象初始化:

<cfset Obj = createObject("java","client.PropHandler").getMessageList('identifier', 'greaterthan', '2012-05-18T12:00:00-04:00').init(configFile)> 

都返回相同的錯誤:

Object Instantiation Exception

An exception occurred while instantiating a Java object. The class must not be an interface or an abstract class. If the class has a constructor that accepts an argument, you must call the constructor explicitly using the init(args) method. Error : client.PropertyHandler

當我不送3個ARGS我得到一個方法未找到錯誤,如果我不發送init我得到同樣的錯誤。

所以,我沒有很多JAVA的經驗,我不明白錯誤消息。從命令行調用時,或者甚至在執行BAT文件時,我都可以使用JAR,但是當我這樣做時,我無法將XML SOAP數組返回給我...

從Java文件:

PropertyHandler

public PropertyHandler(java.lang.String propFile) throws java.lang.Exception

Uses a Property File to set up all program variables. This Property File refers to a second Property File that identifies user Id and security file data.

Parameters:

  • propFile - XML file of Properties

Throws:

  • java.lang.Exception

getMessageList

public services.[...].GetResponseTypeDef getMessageList(java.lang.String par1, 
        java.lang.String comp_Op1, 
        java.lang.String parValue1) 

Overrides X_Properties to returns a list of metadata about each message that meets the query defined by the function parameters.

Parameters:

  • par1 - One of Parameter enum
  • comp_Op1 - One of CompOp enum
  • parValue1 - a value for comparison

Returns:

metadata message list meeting query criteria Returns null if an exception is encountered instead of throwing an exception.

+1

嘗試調用的init()的Java對象,然後調用其參數的方法。 Obj.init(...)。getMessageList(...) – imthepitts

+0

Obj.init(configfile).getMessageList('identifier','greaterthan','2012-05-18T12:00:00-04:00') 相同的錯誤:對象實例化異常。 實例化Java對象時發生異常。該類不能是接口或抽象類。錯誤:''。 – Wes

+1

這只是一個你用java對象得到的樣板消息,你能否更新你的問題來包含* full * stack trace?(這是真正的錯誤信息所在)。另外,'#configFile#'的實際值是多少? – Leigh

回答

2

呼叫的結構的工作原理爲:

<cfset Obj = createObject("java","client.PropHandler") /> 
<cfset Meth = Obj.init(argfile).getMessageList(arg1,arg2,arg3)> 

argfile變量是路徑的XML配置文件,並且它也引用使用相對路徑另一個配置文件。我發現這個錯誤來自棧跟蹤(下面),一旦路徑被改爲絕對內部argfile錯誤得到解決。

Stack Trace at cf_getMsgs2ecfm497532872.runPage(E:\Inetpub\wwwroot_getMsgs.cfm:24) at cf_getMsgs2ecfm497532872.runPage(E:\Inetpub\wwwroot_getMsgs.cfm:24)

java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at coldfusion.runtime.java.JavaProxy.CreateObject(JavaProxy.java:156) at coldfusion.runtime.java.JavaProxy.invoke(JavaProxy.java:63) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2272) at cf_getMsgs2ecfm497532872.runPage(E:\Inetpub\wwwroot_getMsgs.cfm:24) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:370) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:279) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:86) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:74) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.CfmServlet.service(CfmServlet.java:175) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at jrun.servlet.FilterChain.service(FilterChain.java:101) at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203) at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428) at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266) at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66) Caused by: java.io.FileNotFoundException: ..\data\APIproperties.xml (The system cannot find the path specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.(FileInputStream.java:106) at java.io.FileInputStream.(FileInputStream.java:66) at client.PropertyHandler.(PropertyHandler.java:133)

感謝@Leigh和@imthepitts