<!-- start tomcat -->
<target name="tomcat.start">
<mkdir dir="${tomcat}/temp" />
<mkdir dir="${tomcat}/logs" />
<echo message="starting tomcat" level="info" />
<java classname="org.apache.catalina.startup.Bootstrap"
fork="true"
failonError="false"
dir="${tomcat}/bin"
spawn="true">
<classpath location="${env.JAVA_HOME}/lib/tools.jar" />
<classpath location="${tomcat}/bin/bootstrap.jar" />
<classpath location="${tomcat}/bin/commons-logging.api.jar" />
<jvmarg value="-Dprocess.name=tomcat" />
<jvmarg value="-Xmx800m" />
<jvmarg value="-XX:MaxPermSize=350m" />
<jvmarg value="-Dcom.sun.management.jmxremote.port=9003" />
<jvmarg value="-Dcom.sun.management.jmxremote.ssl=false" />
<jvmarg value="-Dcom.sun.management.jmxremote.authenticate=false" />
<jvmarg value="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" />
<jvmarg value="-Djava.util.logging.config.file=${tomcat}/conf/logging.properties" />
<jvmarg value="-Djava.endorsed.dirs=${tomcat}/endorsed" />
<jvmarg value="-Dcatalina.base=${tomcat}" />
<jvmarg value="-Dcatalina.home=${tomcat}" />
<jvmarg value="-Djava.io.tmpdir=${tomcat}/temp" />
<arg value="start" />
</java>
</target>
Friday, January 18, 2008
Start Tomcat using an Ant target
I like using a direct call to the tomcat startup class so I can avoid shell scripts:
How to deploy a Web Service to Tomcat 5.5 or 6.0
This example uses JDK6.
Adapted from http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=51&t=004355:
Download the latest JAXWS Release Implementation (RI) from https://jax-ws.dev.java.net/ri-download.html. Unpack its jars as per instructions.
Tomcat 5.5
In the war, we update the web.xml to use a special listener that enables the web service. The web.xml should look like this:
Adapted from http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=51&t=004355:
Download the latest JAXWS Release Implementation (RI) from https://jax-ws.dev.java.net/ri-download.html. Unpack its jars as per instructions.
Tomcat 5.5
- copy the jaxws jars to the shared/lib directory in tomcat.
- move the jaxb-api.jar in shared/lib to common/endorsed.
- start tomcat
- create a shared directory in tomcat.
- copy the jaxws jars to that directory.
- create an endorsed directory in tomcat. If you are running tomcat using an ant task make sure you include the option
-Djava.endorsed.dirs=${catalina}/endorsed
- Move jaxb-api.jar from shared to endorsed.
- Edit conf/catalina.properties and set the shared.loader property as follows:
shared.loader=${catalina.home}/shared/*.jarWar
In the war, we update the web.xml to use a special listener that enables the web service. The web.xml should look like this:
<listener>Create a sun-jaxws.xml file in WEB-INF directory which the listener uses to configure itself with the web service you want to expose:
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>MyExampleService</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MyExampleService</servlet-name>
<url-pattern>/example</url-pattern>
</servlet-mapping>
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">After starting tomcat you can access the service by:
<endpoint name="MyExampleService" implementation="moten.david.example.ws.MyExample" pattern="/example"/>
</endpoints>
http://localhost:8080/{war-name}/example
Subscribe to:
Posts (Atom)