2

How do you deploy a Java web app to Tomcat server, on another computer on network(or internet) , through an IDE like Netbeans for development/testing & production purposes ?

Any feature in Netbeans that makes this simpler ?

2 Answers 2

1

You can do this by modifying your build.xml. You'll need catalina-ant.jar from the Tomcat distribution. I throw it in my build-jars directory - you can also place it in ANT_HOME/lib. Here's what I have in my build.xml to deploy to a remote Tomcat:

<property name="build-jars" location="build-jars" />
<property name="deploy" location="deploy" />
<property name="target.name" value="myapp" />
<property name="tomcat.manager.url" value="http://server.com:8080/manager/text"/>
<property name="tomcat.manager.username" value="user" />
<property name="tomcat.manager.password" value="pass" />

<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask">
  <classpath>
    <path location="${build-jars}"/catalina-ant.jar" />
  </classpath>
</taskdef>

<target name="deploy-war" depends="war" description="Deploy to Tomcat">
  <deploy url="${tomcat.manager.url}"
          username="${tomcat.manager.username}"
          password="${tomcat.manager.password}"
          path="/${target.name}"
          update="true"
          war="file:${deploy}/${target.name}.war" />
</target>

Note that in Tomcat 7 the user will need to have the manager-script role set in tomcat-users.xml.

Sign up to request clarification or add additional context in comments.

Comments

0

Use the tomcat-maven-plugin. An in-IDE support is intended for localhost dev purposes only.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.