tags:

views:

20

answers:

1

I've been following along the very good Tomcat6 Application Developers Guide. I've grabbed their build.xml which contains the handy ant task called install that uses the catalina-ant.jar task deploy.

<target name="install" depends="compile"
   description="Install application to servlet container">

    <deploy url="${manager.url}"
       username="${manager.username}"
       password="${manager.password}"
           path="${app.path}"
       localWar="file://${build.home}"/>

</target>

My project sits currently in /home/leif/test/mytomcatapp/.

My build.properties looks like:

manager.username=admin
manager.password=admin
manager.url=http://localhost:8080/manager/
cataline.home=/usr/share/tomcat6/

And my /etc/tomcat6/tomcat-users.xml looks like:

<role rolename="admin"/>
<role rolename="manager"/>
<user name="admin" password="admin" roles="admin,manager" />

But, when I do my ant install to test out my webapp I get an error deploying it:

$ ant install
Buildfile: build.xml
Trying to override old definition of datatype resources

prepare:

compile:

install:
   [deploy] FAIL - Failed to deploy application at context path /mytomcatapp

BUILD FAILED
FAIL - Failed to deploy application at context path /mytomcatapp

And in /var/log/tomcat/catalina.out it says:

java.io.FileNotFoundException: /home/leif/test/mytomcatapp/build (Permission denied)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:137)
    at org.apache.catalina.manager.ManagerServlet.copyInternal(ManagerServlet.java:1644)
    at org.apache.catalina.manager.ManagerServlet.copy(ManagerServlet.java:1605)
    at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:819)
    at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:350)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    at java.lang.Thread.run(Thread.java:636)

So Tomcat manager can't access the files in my home dir. Nothing shocking there. But how is the ant install task ever expected to work? This is of course presuming people keep the source code for their project in their home dir and excute ant install from that location. I'd rather not crank open the permissions on my home dir, there must be a better way?

A: 

You need package up your webapp in a .war file, and have ant upload it to Tomcat. If you're using the sample build.xml , just have the install target depend on the dist target, and change

localWar="file://${build.home}"

to

war="${dist.home}/${app.name}-${app.version}.war"`

Alternativly, change your build.xml to output the war to a directory that you can share with tomcat - e.g. somewhere under /tmp

nos
Thanks, this gave me the idea to define `build.home=/tmp/public/build/` in my `build.properties`. The Tomcat manager can no happily grab my files to deploy.
leif81