通过部署在Tomcat服务器中的Java类运行build.xml时出错

时间:2014-08-06 15:21:55

标签: java ant tomcat7

我在以下代码的帮助下通过Java类运行ant构建文件:

p.setUserProperty("ant.file", buildFile.getAbsolutePath());
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());

当我部署WAR文件并调用同一个类时,我收到以下错误:

org.apache.cxf.interceptor.Fault: org/apache/tools/ant/BuildListener
        at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractIn
voker.java:170)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker
.java:136)
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:204)
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:101)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInv
okerInterceptor.java:58)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(Se
rviceInvokerInterceptor.java:94)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
orChain.java:272)
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIniti
ationObserver.java:121)
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(Abstract
HTTPDestination.java:241)
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(
ServletController.java:248)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletCont
roller.java:222)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletCont
roller.java:153)
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpr
ingServlet.java:171)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Ab
stractHTTPServlet.java:286)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHT
TPServlet.java:211)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(Abstract
HTTPServlet.java:262)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:222)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:123)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:99)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
953)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp
11Processor.java:1023)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
AbstractProtocol.java:589)
        at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoin
t.java:1852)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildListener
        at com.hemant.rest.OrderInfoImpl.getAllOrders(OrderInfoImpl.java:62)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(Abst
ractInvoker.java:188)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker
.java:104)
        ... 31 more
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.BuildListener
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1714)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1559)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        ... 38 more
Aug 6, 2014 8:23:00 PM org.apache.cxf.phase.PhaseInterceptorChain unwind
WARNING: Exception in handleFault on interceptor org.apache.cxf.binding.xml.inte
rceptor.XMLFaultOutInterceptor@f38b42
org.apache.cxf.interceptor.Fault: org/apache/tools/ant/BuildListener
        at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractIn
voker.java:170)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker
.java:136)
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:204)
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:101)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInv
okerInterceptor.java:58)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(Se
rviceInvokerInterceptor.java:94)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
orChain.java:272)
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIniti
ationObserver.java:121)
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(Abstract
HTTPDestination.java:241)
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(
ServletController.java:248)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletCont
roller.java:222)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletCont
roller.java:153)
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpr
ingServlet.java:171)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Ab
stractHTTPServlet.java:286)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHT
TPServlet.java:211)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(Abstract
HTTPServlet.java:262)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:222)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:123)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:99)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
953)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp
11Processor.java:1023)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
AbstractProtocol.java:589)
        at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoin
t.java:1852)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildListener
        at com.hemant.rest.OrderInfoImpl.getAllOrders(OrderInfoImpl.java:62)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(Abst
ractInvoker.java:188)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker
.java:104)
        ... 31 more
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.BuildListener
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1714)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1559)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        ... 38 more
Aug 6, 2014 8:23:00 PM org.apache.cxf.interceptor.AbstractFaultChainInitiatorObs
erver onMessage
SEVERE: Error occurred during error handling, give up!
org.apache.cxf.interceptor.Fault: org/apache/tools/ant/BuildListener
        at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractIn
voker.java:170)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker
.java:136)
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:204)
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:101)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInv
okerInterceptor.java:58)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(Se
rviceInvokerInterceptor.java:94)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
orChain.java:272)
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIniti
ationObserver.java:121)
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(Abstract
HTTPDestination.java:241)
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(
ServletController.java:248)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletCont
roller.java:222)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletCont
roller.java:153)
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpr
ingServlet.java:171)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Ab
stractHTTPServlet.java:286)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHT
TPServlet.java:211)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(Abstract
HTTPServlet.java:262)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:222)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:123)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:99)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
953)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp
11Processor.java:1023)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
AbstractProtocol.java:589)
        at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoin
t.java:1852)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildListener
        at com.hemant.rest.OrderInfoImpl.getAllOrders(OrderInfoImpl.java:62)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(Abst
ractInvoker.java:188)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker
.java:104)
        ... 31 more
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.BuildListener
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1714)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1559)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        ... 38 more

Ant文件存在于WAR文件中。如果它在主程序中运行,则相同的代码可以工作。 如何删除此错误?

0 个答案:

没有答案