我完全坚持这一点。我对冷聚变的了解不够,也找不到答案来知道出了什么问题。
这是我的coldfusion脚本的问题部分,在这里使用通用名称
<cfscript>
function run() {
var obj = createObject("java", "com.company.Run");
var variable1= "string1";
var variable2= "string2";
var variable3= "string3";
obj.init();
var success = obj.runThis(variable1, variable2, variable3); <-- failing here
return success;
}
</cfscript>
<cfset success = run()>
<cfoutput>SUCCESS? #success#</cfoutput>
此访问的 java 代码位于一个 jar 中,该 jar 已编译并适用于该类中的简单方法。例如,我可以做到这一点,使用coldfusion脚本下面的java代码,它没有一个问题:
<cfscript>
function run() {
var obj = createObject("java", "com.company.Run");
var variable= "string";
obj.init();
var success = obj.print(variable); <-- failing here
return success;
}
</cfscript>
<cfset success = run()>
<cfoutput>SUCCESS? #success#</cfoutput>
public static String print(String input) {
return input;
}
我想要运行的是我上面的第一个带有这种想法的冷融合脚本,在这个类中它正在运行“runThis”,它从另一个类构造一个对象,然后从该对象运行一个返回字符串的方法。它们都在同一个 jar 中,所以当我只针对完全相同的代码运行 junit 测试时,它们都应该可以访问并且运行良好。这里的问题是将其拉入冷融合并在那里运行:
public class Run {
public Run() {
}
public String runThis(String variable1, String variable1, String variable3) throws Exception {
try {
MyObject object= new MyObject (variable1, variable2, variable3);
return object.execute();
} catch (Exception e) {
return "error";
}
}
}
我收到的错误:
"Error","http-bio-8500-exec-7","10/08/14","10:47:13",,"javax/ws/rs/WebApplicationException The specific sequence of files included or processed is: C:\ColdFusion11\cfusion\wwwroot\company\response.cfm, line: 77 "
java.lang.NoClassDefFoundError: javax/ws/rs/WebApplicationException
at com.company.Run.runThis(Run.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at coldfusion.runtime.java.JavaProxy.invoke(JavaProxy.java:97)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2483)
at cfresponse2ecfm1522673216$funcRUN.runFunction(C:\ColdFusion11\cfusion\wwwroot\company\response.cfm:77)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:487)
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 cfresponse2ecfm1522673216.runPage(C:\ColdFusion11\cfusion\wwwroot\company\response.cfm:82)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:246)
at coldfusion.tagext.lang.IncludeTag.handlePageInvoke(IncludeTag.java:734)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:570)
at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
at coldfusion.filter.IpFilter.invoke(IpFilter.java:45)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:487)
at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:42)
at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:141)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94)
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 coldfusion.inspect.weinre.MobileDeviceDomInspectionFilter.doFilter(MobileDeviceDomInspectionFilter.java:121)
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:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:422)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.ws.rs.WebApplicationException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
... 56 more
我有一种感觉,我没有正确实例化 MyObject 对象,或者这是代码失败的地方。删除它似乎允许代码工作,但显然不会让我得到我想要的。