我正在开发一个部署从GWT界面中选择的应用程序的系统。我写了build.xml;
<target
name="deploywar"
description="Varolan WAR dosyasını yayınlar." >
<echo level="info" >
Proje sunucuda yayinlaniyor...
</echo>
<exec
executable="cmd"
failonerror="true" >
<arg value="/c" />
<arg value="D:/enlil/glassfish3/bin/asadmin --passwordfile D:/stajyer/password.txt deploy --contextroot /GlassfishDeployment dist/MobilHis.war" />
</exec>
</target>
并从Java调用这个目标;
buildfile = new java.io.File("build.xml");
p = new Project();
p.setUserProperty("ant.file", buildfile.getAbsolutePath());
p.init();
helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildfile);
p.executeTarget("deploywar");
当我从test(main)类调用这个过程时,我的意思不是从web界面调用,它执行部署过程。但是当我通过RPC回调从web界面调用这个方法时,我得到了这个错误。
exec returned: 1
D:stajyerGlassfish Deploymentwarbuild.xml:83: exec returned: 1
at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:591)
at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:617)
at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:452)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at com.enlil.source.server.RunAntXmlFile.deployWar(RunAntXmlFile.java:58)
at com.enlil.source.server.FTPProcessImpl.deployFiles(FTPProcessImpl.java:120)
at com.enlil.source.server.FTPProcessImpl.updateFiles(FTPProcessImpl.java:350)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
我找不到问题在哪里。谢谢你的帮助。 尝试以下操作
<exec executable="D:/enlil/glassfish3/bin/asadmin" failonerror="true">
<arg value="--passwordfile"/>
<arg value="D:/stajyer/password.txt"/>
<arg value="deploy"/>
<arg value="--contextroot"/>
<arg value="/GlassfishDeployment"/>
<arg value="dist/MobilHis.war"/>
</exec>
在单独的<arg/>
元素中保留参数。
这可能是因为glassfish无法打开命令提示符
我发现在我的项目文件夹中有2个build.xml文件和我的类引用另一个,我不知道为什么我有两个,但是当我将代码粘贴到其他build.xml中时,所有问题都解决了。