开发者

Ant build denied permission to copy .war file

I have a packaged app.war file that I am trying to copy to the webapps folder and I am getting an error:

BUILD FAILED Failed to copy mywar.war to /usr/local/t开发者_开发百科omcat/webapps/mywar.war due to java.io.FileNotFoundException /usr/local/tomcat/webapps/mywar.war (Permission denied)

Here is the ant code for this:

<target name="install" depends="package">
      <copy file="mywar.war" tofile="${webapp.dir}/mywar.war" overwrite="true" />
</target>

It is obviously a permissions thing. I can not really solve it by chmod 777 the .war file because the myapp.war will get erased every time, and the new files will have the restrictive permissions applied again.

What if I make the whole webapps dir permissions 777 or something? That seems like bad practice in terms of security, right? Or is there an ant command to give the script root permission? I am using ubuntu if it matters.

thanks!


Personally, I build the WAR file with Ant, and then su to root and copy it to the webapps folder by hand.

However, you could make the webapps folder writable by a particular group, and run Ant as a member of that group.


Try using the scp task. You'll need to make sure jsch is on the Ant classpath for it to work. There's documentation from the Ant folks about it.

<scp file="mywar.war" todir="root:password@localhost:${webapp.dir}"/>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜