如何在ColdFusion 11中调用java类

时间:2015-01-06 22:34:20

标签: coldfusion opennlp coldfusion-11

我正在尝试使用名为Open_NLP的java类文件,但我遇到了问题。

这是我到目前为止所做的

•在C:\ColdFusion11\cfusion\wwwroot\WEB-INF\classes中添加了班级文件 •重新启动CF服务

这就是我的称呼方式

<cfset myObj = CreateObject("java", "Open_NLP")>

这就是我得到的错误

Object instantiation exception.

    An exception occurred while instantiating a Java object. The class must not be an interface or an abstract class. Error: opennlp/tools/util/ObjectStream.

我打电话给错了吗?在我打电话给班级之前,我是否需要采取更多步骤?

Stack Trace
at cfwordcloud2ecfm316238315.runPage(Z:/Sites/xamplifier/views/surveyreporting/wordcloud.cfm:91) at cfcfml2ecfm1851198363$func$INCLUDEANDRETURNOUTPUT.runFunction(Z:/Sites/xamplifier/wheels/global/cfml.cfm:138) at cfrendering2ecfm1331024027$func$INCLUDEFILE.runFunction(Z:/Sites/xamplifier/wheels/controller/rendering.cfm:498) at cfrendering2ecfm1331024027$func$RENDERPAGE.runFunction(Z:/Sites/xamplifier/wheels/controller/rendering.cfm:257) at cfrendering2ecfm1331024027$funcRENDERPAGE.runFunction(Z:/Sites/xamplifier/wheels/controller/rendering.cfm:68) at cfprocessing2ecfm608176556$func$CALLACTION.runFunction(Z:/Sites/xamplifier/wheels/controller/processing.cfm:99) at cfprocessing2ecfm608176556$func$PROCESSACTION.runFunction(Z:/Sites/xamplifier/wheels/controller/processing.cfm:60) at cfrequest2ecfm2131921479$func$REQUEST.runFunction(Z:/Sites/xamplifier/wheels/dispatch/request.cfm:167) at cfindex2ecfm2029461072.runPage(Z:/Sites/xamplifier/wheels/index.cfm:1) at cfindex2ecfm1778521657.runPage(Z:/Sites/xamplifier/index.cfm:1) at cfonrequest2ecfm1108885784$funcONREQUEST.runFunction(Z:/Sites/xamplifier/wheels/events/onrequest.cfm:1) 
 at cfwordcloud2ecfm316238315.runPage(Z:/Sites/xamplifier/views/surveyreporting/wordcloud.cfm:91) at cfcfml2ecfm1851198363$func$INCLUDEANDRETURNOUTPUT.runFunction(Z:/Sites/xamplifier/wheels/global/cfml.cfm:138) at cfrendering2ecfm1331024027$func$INCLUDEFILE.runFunction(Z:/Sites/xamplifier/wheels/controller/rendering.cfm:498) at cfrendering2ecfm1331024027$func$RENDERPAGE.runFunction(Z:/Sites/xamplifier/wheels/controller/rendering.cfm:257) at cfrendering2ecfm1331024027$funcRENDERPAGE.runFunction(Z:/Sites/xamplifier/wheels/controller/rendering.cfm:68) at cfprocessing2ecfm608176556$func$CALLACTION.runFunction(Z:/Sites/xamplifier/wheels/controller/processing.cfm:99) at cfprocessing2ecfm608176556$func$PROCESSACTION.runFunction(Z:/Sites/xamplifier/wheels/controller/processing.cfm:60) at cfrequest2ecfm2131921479$func$REQUEST.runFunction(Z:/Sites/xamplifier/wheels/dispatch/request.cfm:167) at cfindex2ecfm2029461072.runPage(Z:/Sites/xamplifier/wheels/index.cfm:1) at cfindex2ecfm1778521657.runPage(Z:/Sites/xamplifier/index.cfm:1) at cfonrequest2ecfm1108885784$funcONREQUEST.runFunction(Z:/Sites/xamplifier/wheels/events/onrequest.cfm:1) 

java.lang.NoClassDefFoundError: opennlp/tools/util/ObjectStream
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Unknown Source)
    at java.lang.Class.privateGetPublicFields(Unknown Source)
    at java.lang.Class.getFields(Unknown Source)
    at coldfusion.runtime.java.ObjectHandler.Initialize(ObjectHandler.java:35)
    at coldfusion.runtime.java.ObjectHandler.<init>(ObjectHandler.java:30)
    at coldfusion.runtime.java.ReflectionCache.get(ReflectionCache.java:38)
    at coldfusion.runtime.java.JavaProxy.<init>(JavaProxy.java:35)
    at coldfusion.runtime.java.JavaProxyFactory.getProxy(JavaProxyFactory.java:121)
    at coldfusion.runtime.ProxyFactory.getProxy(ProxyFactory.java:65)
    at coldfusion.runtime.CFPage.createObjectProxy(CFPage.java:6168)
    at coldfusion.runtime.CFPage.CreateObject(CFPage.java:6131)
    at coldfusion.runtime.CFPage.CreateObject(CFPage.java:6065)
    at coldfusion.runtime.CFPage.CreateObject(CFPage.java:6040)
    at coldfusion.runtime.CFPage.CreateObject(CFPage.java:5987)
    at cfwordcloud2ecfm316238315.runPage(Z:\Sites\xamplifier\views\surveyreporting\wordcloud.cfm:91)
    at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:246)
    at coldfusion.tagext.lang.IncludeTag.handlePageInvoke(IncludeTag.java:736)
    at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:572)
    at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2986)
    at cfcfml2ecfm1851198363$func$INCLUDEANDRETURNOUTPUT.runFunction(Z:\Sites\xamplifier\wheels\global\cfml.cfm:138)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:487)
    at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
    at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:420)
    at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:383)
    at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:334)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:533)
    at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2805)
    at cfrendering2ecfm1331024027$func$INCLUDEFILE.runFunction(Z:\Sites\xamplifier\wheels\controller\rendering.cfm:498)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:487)
    at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
    at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:420)
    at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:383)
    at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:334)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:533)
    at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2805)
    at cfrendering2ecfm1331024027$func$RENDERPAGE.runFunction(Z:\Sites\xamplifier\wheels\controller\rendering.cfm:257)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:487)
    at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
    at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:420)
    at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:383)
    at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:334)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:533)
    at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2805)
    at cfrendering2ecfm1331024027$funcRENDERPAGE.runFunction(Z:\Sites\xamplifier\wheels\controller\rendering.cfm:68)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:487)
    at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
    at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:420)
    at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:383)
    at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:334)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:231)
    at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2840)
    at cfprocessing2ecfm608176556$func$CALLACTION.runFunction(Z:\Sites\xamplifier\wheels\controller\processing.cfm:99)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:487)
    at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
    at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:420)
    at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:383)
    at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:334)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:533)
    at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2805)
    at cfprocessing2ecfm608176556$func$PROCESSACTION.runFunction(Z:\Sites\xamplifier\wheels\controller\processing.cfm:60)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:487)
    at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
    at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:420)
    at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:383)
    at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:334)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:231)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:643)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:432)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:402)
    at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2483)
    at cfrequest2ecfm2131921479$func$REQUEST.runFunction(Z:\Sites\xamplifier\wheels\dispatch\request.cfm:167)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:487)
    at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
    at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:420)
    at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:383)
    at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:334)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:231)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:643)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:432)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:402)
    at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2483)
    at cfindex2ecfm2029461072.runPage(Z:\Sites\xamplifier\wheels\index.cfm:1)
    at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:246)
    at coldfusion.tagext.lang.IncludeTag.handlePageInvoke(IncludeTag.java:736)
    at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:572)
    at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2986)
    at cfindex2ecfm1778521657.runPage(Z:\Sites\xamplifier\index.cfm:1)
    at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:246)
    at coldfusion.tagext.lang.IncludeTag.handlePageInvoke(IncludeTag.java:736)
    at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:572)
    at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2986)
    at cfonrequest2ecfm1108885784$funcONREQUEST.runFunction(Z:\Sites\xamplifier\wheels\events\onrequest.cfm:1)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:487)
    at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:420)
    at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:383)
    at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:334)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:231)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:643)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:432)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:402)
    at coldfusion.runtime.AppEventInvoker.invoke(AppEventInvoker.java:108)
    at coldfusion.runtime.AppEventInvoker.onRequest(AppEventInvoker.java:301)
    at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:462)
    at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:42)
    at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
    at coldfusion.filter.PathFilter.invoke(PathFilter.java:142)
    at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94)
    at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:78)
    at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
    at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
    at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:58)
    at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
    at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
    at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62)
    at coldfusion.CfmServlet.service(CfmServlet.java:219)
    at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
    at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:422)
    at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:199)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: opennlp.tools.util.ObjectStream
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    ... 145 more

1 个答案:

答案 0 :(得分:3)

如果这是一个jar文件,则需要进入特定ColdFusion实例的/ lib目录。位置取决于您的安装类型和平台。但它包含其他CF特定罐子的相同/ lib - 查看&#34;系统信息下的CF管理员设置&#34;或&#34;设置摘要&#34; - 您将看到一个很长的jar文件列表,这些文件在启动时被加载。在我目前正在查看的那个(这是一个多实例cf 9)中,它位于 instancename /cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/下,但是在CF 11上它应该只是 ../ WEB-INF / lib。

您还可以将放在服务器上的任何位置,并通过编辑jvm.config文件将该位置添加到类路径文件中。

将其添加到/ lib或类路径后,您需要重新启动ColdFusion。祝你好运!

-Mark