问题创建war文件 [英] problems creating war file
问题描述
我有以下错误部署我的春节应用到Tomcat 7的问题:
C:\\用户\\ XXXXXX \\工作\\在线赛车
联赛\\的build.xml:61:问题创造
战争:C:\\ Program Files文件\\ Apache软件
基金会\\ Tomcat的7.0 \\的webapps \\在线
赛车League.war(访问被拒绝)
(和归档可能已损坏
但我不能删除)
块引用>下面是我的build.properties是什么样子:
#Ant属性为建设springappappserver.home = C:/ Program Files文件/阿帕奇软件基金会/ Tomcat的7.0
#为Tomcat 5使用$ appserver.home} /服务器/ lib目录
#为Tomcat 6使用$ appserver.home} / lib目录
appserver.lib = $ {} appserver.home / lib目录/deploy.path = $ {} appserver.home / webapps中tomcat.manager.url = HTTP://本地主机:8080 /经理
tomcat.manager.username =
tomcat.manager.password =构建文件:
<?XML版本=1.0&GT?;<项目名称=在线赛车联盟的basedir =。默认为使用>
<物业档案=build.properties/> <属性名=对于src.dirVALUE =SRC/>
<属性名=web.dirVALUE =战争/>
<属性名=build.dir值=$ {} web.dir / WEB-INF / classes中/>
<属性名=名字值=在线赛车联盟/> <路径ID =主类路径>
<文件集DIR =$ {} web.dir / WEB-INF / lib目录>
<包括姓名=*罐子。/>
< /文件集>
!< - 我们需要的servlet API类: - >
<! - *为Tomcat 5/6使用servlet的api.jar文件 - >
<! - *为其他应用服务器 - 检查文档 - >
<文件集DIR =$ {} appserver.lib>
<包括姓名=的servlet的* .jar/>
< /文件集>
< pathelement PATH =$ {} build.dir/>
< /路径> <目标名称=用法>
<回声消息=/>
<回声消息=$ {name}的构建文件/>
<回声消息=-----------------------------------/>
<回声消息=/>
<回声消息=可用的目标是:/>
<回声消息=/>
<回声消息=建造 - >构建应用程序/>
<回声消息=部署 - >部署应用程序目录/>
<回声消息=deploywar - >部署应用程序作为WAR文件/>
<回声消息=安装 - >在Tomcat的安装应用程序/>
<回声消息=重装 - >在Tomcat的重新装载应用程序/>
<回声消息=启动 - >启动Tomcat应用程序/>
<回声消息=停止 - >停止Tomcat应用程序/>
<回声消息=列表 - >名单Java应用程序/>
<回声消息=/>
< /目标与GT; <目标名称=构建描述=编译主代码树java文件>
< MKDIR DIR =$ {} build.dir/>
< javac的DESTDIR =$ {} build.dir来源=1.5目标=1.5调试=真
德precation =假优化=假failonerror =真>
< SRC PATH =$ {}对于src.dir/>
<类路径REFID =主类路径/>
< / javac的>
< /目标与GT; <目标名称=部署取决于=构建描述=部署应用程序>
<复制todir =$ {deploy.path} / $ {name}的preservelastmodified =真正的>
<文件集DIR =$ {} web.dir>
<包括姓名= /&GT** / *。*;
< /文件集>
< /复制>
< /目标与GT; <目标名称=deploywar依赖=编译描述=部署应用程序作为一个WAR文件>
<战争destfile =$ {deploy.path} / $ {name}的的.war
webxml =$ {web.dir} /WEB-INF/web.xml>
<文件集DIR =$ {} web.dir>
<包括姓名= /&GT** / *。*;
< /文件集>
< /战争>
<副本todir =$ {} deploy.pathpreservelastmodified =真正的>
<文件集DIR =>
<包括姓名=*战争。/>
< /文件集>
< /复制>
< /目标与GT; &所述;! - ============================================= ================= - >
<! - Tomcat的任务 - 删除这些,如果你没有安装Tomcat的 - >
&所述;! - ============================================= ================= - > <路径ID =卡特琳娜 - 蚂蚁类路径>
<! - 我们需要卡塔利娜罐子为Tomcat - >
<! - *为其他应用服务器 - 检查文档 - >
<文件集DIR =$ {} appserver.lib>
<包括姓名=卡塔利娜-的ant.jar/>
< /文件集>
< /路径> <的taskdef NAME =安装类名=org.apache.catalina.ant.DeployTask>
<类路径REFID =卡特琳娜 - 蚂蚁类路径/>
< /&的taskdef GT;
<的taskdef NAME =重载类名=org.apache.catalina.ant.ReloadTask>
<类路径REFID =卡特琳娜 - 蚂蚁类路径/>
< /&的taskdef GT;
<的taskdef NAME =清单类名=org.apache.catalina.ant.ListTask>
<类路径REFID =卡特琳娜 - 蚂蚁类路径/>
< /&的taskdef GT;
<的taskdef NAME =启动类名=org.apache.catalina.ant.StartTask>
<类路径REFID =卡特琳娜 - 蚂蚁类路径/>
< /&的taskdef GT;
<的taskdef NAME =停止类名=org.apache.catalina.ant.StopTask>
<类路径REFID =卡特琳娜 - 蚂蚁类路径/>
< /&的taskdef GT; <目标名称=安装描述=&GT在Tomcat中安装应用程序;
<安装URL =$ {} tomcat.manager.url
用户名=$ {} tomcat.manager.username
密码=$ {} tomcat.manager.password
PATH =/ $ {name}的
战争=$ {}名/>
< /目标与GT; <目标名称=重装描述=刷新在Tomcat应用程序>
<重装URL =$ {} tomcat.manager.url
用户名=$ {} tomcat.manager.username
密码=$ {} tomcat.manager.password
PATH =/ $ {}名/>
< /目标与GT; <目标名称=开始描述=启动Tomcat应用程序>
<起始URL =$ {} tomcat.manager.url
用户名=$ {} tomcat.manager.username
密码=$ {} tomcat.manager.password
PATH =/ $ {}名/>
< /目标与GT; <目标名称=停止描述=停止Tomcat应用程序>
<停止URL =$ {} tomcat.manager.url
用户名=$ {} tomcat.manager.username
密码=$ {} tomcat.manager.password
PATH =/ $ {}名/>
< /目标与GT; <目标名称=清单说明=列出Java应用程序>
<名单URL =$ {} tomcat.manager.url
用户名=$ {} tomcat.manager.username
密码=$ {} tomcat.manager.password/>
< /目标与GT; <! - 结束Tomcat的任务 - > < /项目>servlett:
<?XML版本=1.0编码=UTF-8&GT?;<豆的xmlns =http://www.springframework.org/schema/beans
XMLNS:XSI =http://www.w3.org/2001/XMLSchema-instance的xmlns:上下文=http://www.springframework.org/schema/context
的xmlns:MVC =http://www.springframework.org/schema/mvc
XSI:的schemaLocation =http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd\"> < MVC:注解驱动/> <豆
类=org.springframework.web.servlet.view.InternalResourceViewResolver>
<属性名=preFIXVALUE =/ WEB-INF / JSP //>
<JSP属性名=后缀值= />
< /豆> <背景:组件扫描基包=com.jr/>
< /豆>最后在web.xml
<?XML版本=1.0编码=UTF-8&GT?;< web应用程序的xmlns =http://java.sun.com/xml/ns/javaee的xmlns:XSI =http://www.w3.org/2001/XMLSchema-instance
XSI:的schemaLocation =http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
版本=2.5>
<的context-param>
<参数-名称>&contextConfigLocation的LT; /参数 - 名称>
<参数值> < /参数值>
< /的context-param> <听者GT;
<监听级> org.springframework.web.context.ContextLoaderListener< /监听级>
< /听者GT;
<! - index.htm的网页 - >
<欢迎-文件列表>
<欢迎-文件>
的index.jsp
< /欢迎-文件>
< /欢迎-文件列表> <! - 注册和设置我的servlet的XML文件在这里 - > <&servlet的GT;
< servlet的名称>&raceLeague LT; / servlet的名称>
<的servlet类> org.springframework.web.servlet.DispatcherServlet< / servlet的类>
< / servlet的> < Servlet映射>
< servlet的名称>&raceLeague LT; / servlet的名称>
< URL模式> * HTM< / URL模式>
< / Servlet映射>< / web-app的>
解决方案看起来你使用的是Windows Vista或Windows 7的用户帐户控制(的 UAC )启用。
i am having issues deploying my spring app to tomcat 7 with the following error:
C:\Users\xxxxxx\Work\Online Racing League\build.xml:61: Problem creating war: C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\Online Racing League.war (Access is denied) (and the archive is probably corrupt but I could not delete it)
Here is what my build.properties looks like:
# Ant properties for building the springapp appserver.home=C:/Program Files/Apache Software Foundation/Tomcat 7.0 # for Tomcat 5 use $appserver.home}/server/lib # for Tomcat 6 use $appserver.home}/lib appserver.lib=${appserver.home}/lib/ deploy.path=${appserver.home}/webapps tomcat.manager.url=http://localhost:8080/manager tomcat.manager.username= tomcat.manager.password=
Build file:
<?xml version="1.0"?> <project name="Online Racing League" basedir="." default="usage"> <property file="build.properties"/> <property name="src.dir" value="src"/> <property name="web.dir" value="war"/> <property name="build.dir" value="${web.dir}/WEB-INF/classes"/> <property name="name" value="Online Racing League"/> <path id="master-classpath"> <fileset dir="${web.dir}/WEB-INF/lib"> <include name="*.jar"/> </fileset> <!-- We need the servlet API classes: --> <!-- * for Tomcat 5/6 use servlet-api.jar --> <!-- * for other app servers - check the docs --> <fileset dir="${appserver.lib}"> <include name="servlet*.jar"/> </fileset> <pathelement path="${build.dir}"/> </path> <target name="usage"> <echo message=""/> <echo message="${name} build file"/> <echo message="-----------------------------------"/> <echo message=""/> <echo message="Available targets are:"/> <echo message=""/> <echo message="build --> Build the application"/> <echo message="deploy --> Deploy application as directory"/> <echo message="deploywar --> Deploy application as a WAR file"/> <echo message="install --> Install application in Tomcat"/> <echo message="reload --> Reload application in Tomcat"/> <echo message="start --> Start Tomcat application"/> <echo message="stop --> Stop Tomcat application"/> <echo message="list --> List Tomcat applications"/> <echo message=""/> </target> <target name="build" description="Compile main source tree java files"> <mkdir dir="${build.dir}"/> <javac destdir="${build.dir}" source="1.5" target="1.5" debug="true" deprecation="false" optimize="false" failonerror="true"> <src path="${src.dir}"/> <classpath refid="master-classpath"/> </javac> </target> <target name="deploy" depends="build" description="Deploy application"> <copy todir="${deploy.path}/${name}" preservelastmodified="true"> <fileset dir="${web.dir}"> <include name="**/*.*"/> </fileset> </copy> </target> <target name="deploywar" depends="build" description="Deploy application as a WAR file"> <war destfile="${deploy.path}/${name}.war" webxml="${web.dir}/WEB-INF/web.xml"> <fileset dir="${web.dir}"> <include name="**/*.*"/> </fileset> </war> <copy todir="${deploy.path}" preservelastmodified="true"> <fileset dir="."> <include name="*.war"/> </fileset> </copy> </target> <!-- ============================================================== --> <!-- Tomcat tasks - remove these if you don't have Tomcat installed --> <!-- ============================================================== --> <path id="catalina-ant-classpath"> <!-- We need the Catalina jars for Tomcat --> <!-- * for other app servers - check the docs --> <fileset dir="${appserver.lib}"> <include name="catalina-ant.jar"/> </fileset> </path> <taskdef name="install" classname="org.apache.catalina.ant.DeployTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <taskdef name="list" classname="org.apache.catalina.ant.ListTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <taskdef name="start" classname="org.apache.catalina.ant.StartTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <taskdef name="stop" classname="org.apache.catalina.ant.StopTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <target name="install" description="Install application in Tomcat"> <install url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}" war="${name}"/> </target> <target name="reload" description="Reload application in Tomcat"> <reload url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}"/> </target> <target name="start" description="Start Tomcat application"> <start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}"/> </target> <target name="stop" description="Stop Tomcat application"> <stop url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}"/> </target> <target name="list" description="List Tomcat applications"> <list url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}"/> </target> <!-- End Tomcat tasks --> </project>
servlett:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> <context:component-scan base-package="com.jr" /> </beans>
and finally the web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <context-param> <param-name>contextConfigLocation</param-name> <param-value> </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- index.htm web page --> <welcome-file-list> <welcome-file> index.jsp </welcome-file> </welcome-file-list> <!-- Register and setup my servlet xml files here --> <servlet> <servlet-name>raceLeague</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>raceLeague</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> </web-app>
解决方案It looks like you are on Windows Vista or Windows 7 with User Account Control (UAC) enabled.
这篇关于问题创建war文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!