Building the correct WARs for Tomcat
tim_perrett Apr 21, 2007 7:47 AMHey all
I have constucted an Ant script that *looks* to build the correct type of WAR file for deployment in tomcat. However, and im not sure if i think this is a tomcat issue or one related to seam but it doesnt actually deploy in tomcat. I have set it up so that it includes the correct JARs... here is my ant script (below)
Im using tomcat 6, and i recive the following error:
SEVERE: Error listenerStart
Apr 21, 2007 12:43:19 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/seam-hello] startup failed due to previous errors
The seam app i am trying to deploy only has one class, that is a simple hello world example!! lol I dont belive it cant be this difficult to deploy surly?
Any help would be appreciated guys
All the best
Tim
<?xml version="1.0"?>
<project name="SeamHello" default="deploy" basedir=".">
<property file="build.properties" />
<property name="name" value="seam-hello" />
<property name="deploy.dir" value="${tomcat.home}/webapps" />
<property name="deploy.file" value="${name}.war" />
<property name="build.dir" value="./build" />
<property name="classes.dir" value="${build.dir}/classes" />
<property name="deploy.file.path" value="${build.dir}/${deploy.file}" />
<property name="tomcat.conf" value="eejb.conf"/>
<property name="eejb.conf.dir" value="../../Frameworks/jboss-seam/embedded-ejb/conf"/>
<property name="lib.dir" value="./lib"/>
<property name="docroot.dir" value="view"/>
<property name="resources.dir" value="resources"/>
<property name="webinf.lib.dir" value="${resources.dir}/WEB-INF/lib"/>
<path id="project.path" />
<path id="build.classpath">
<path refid="project.path"/>
<fileset refid="lib" />
</path>
<fileset id="local.jar" dir=".">
<exclude name="**/*" />
</fileset>
<fileset id="lib" dir="${lib.dir}">
<include name="*.jar" />
<exclude name="jsf-facelets*.jar"/>
<exclude name="jboss-*-jdk50.jar"/>
<exclude name="jgroups*.jar"/>
<exclude name="jbpm*.jar"/>
<exclude name="servlet-api.jar"/>
<exclude name="ant*.jar"/>
<exclude name="javax.servlet.jsp.jar"/>
<exclude name="testng-*.jar"/>
</fileset>
<fileset id="eejb.conf" dir="${eejb.conf.dir}">
<include name="ejb3-interceptors-aop.xml"/>
<include name="embedded-jboss-beans.xml"/>
<include name="jboss-jms-beans.xml"/>
<include name="security-beans.xml"/>
<include name="login-config.xml"/>
<include name="default.persistence.properties"/>
<include name="log4j.xml"/>
<include name="jndi.properties"/>
</fileset>
<fileset id="project.classes" dir="${classes.dir}">
<include name="**/*.class"/>
<include name="**/*.component.xml"/>
<include name="**/components.xml"/>
<exclude name="**/test/*.class"/>
</fileset>
<zipfileset id="seam.main.jar"
dir="${lib.dir}"
description="the main Seam jar">
<include name="jboss-seam.jar"/>
</zipfileset>
<zipfileset id="tomcat.war.webinf"
prefix="WEB-INF"
dir="resources/WEB-INF" >
<include name="**/*.*"/>
</zipfileset>
<fileset id="tomcat.resources"
dir="resources">
<include name="**/*.*"/>
<exclude name="WEB-INF/**/*.*"/>
</fileset>
<zipfileset id="tomcat.lib"
prefix="WEB-INF/lib"
dir="${lib.dir}"
description="run-time dependencies for tomcat deployment">
<include name="*.jar"/>
<exclude name="jsf-facelets*.jar"/>
<exclude name="jboss-*-jdk50.jar"/>
<exclude name="jgroups*.jar"/>
<exclude name="jbpm*.jar"/>
<exclude name="servlet-api.jar"/>
<exclude name="ant*.jar"/>
<exclude name="javax.servlet.jsp.jar"/>
<exclude name="testng-*.jar"/>
</zipfileset>
<zipfileset id="tomcat.seam.jar" prefix="WEB-INF/lib" dir="${lib.dir}">
<include name="${name}.jar"/>
<include name="jboss-seam-debug.jar" />
<include name="jboss-seam-ui.jar" />
<include name="jboss-seam-pdf.jar" />
<include name="jboss-seam-ioc.jar" />
<include name="jboss-seam-remoting.jar" />
</zipfileset>
<zipfileset id="tomcat.drools.jar"
prefix="WEB-INF/lib"
dir="${lib.dir}">
<include name="drools-compiler-3.0.5.jar" />
<include name="drools-core-3.0.5.jar" />
<!-- <include name="*.jar" /> -->
</zipfileset>
<zipfileset id="tomcat.extra.jar"
prefix="WEB-INF/lib"
dir="${lib.dir}">
<include name="jsf-facelets.jar" />
<include name="jboss-cache-jdk50.jar" />
<include name="jboss-aop-jdk50.jar" />
<include name="jgroups.jar" />
<include name="jbpm*.jar" />
<include name="spring*.jar" />
</zipfileset>
<zipfileset id="war.docroot"
dir="${docroot.dir}">
<include name="**/*"/>
</zipfileset>
<zipfileset id="war.webinf.lib"
prefix="WEB-INF/lib"
dir="${webinf.lib.dir}">
<include name="*.jar"/>
<exclude name="jsf-facelets*.jar"/>
<exclude name="jboss-*-jdk50.jar"/>
<exclude name="jgroups*.jar"/>
<exclude name="jbpm*.jar"/>
<exclude name="servlet-api.jar"/>
<exclude name="ant*.jar"/>
<exclude name="javax.servlet.jsp.jar"/>
<exclude name="testng-*.jar"/>
</zipfileset>
<!-- <path id="compile.classpath"> -->
<!-- <fileset dir="lib" includes="*.jar" /> -->
<!-- <fileset dir="lib/seam" includes="jboss-seam.jar" /> -->
<!-- </path> -->
<target name="clean" description="Cleans up the build directory">
<delete dir="${classes.dir}" failonerror="false" />
<delete dir="${build.dir}" failonerror="false" />
</target>
<target name="init" depends="clean" description="Initialize the build">
<echo message="Building ${ant.project.name}" />
<mkdir dir="${classes.dir}" />
<mkdir dir="${build.dir}" />
</target>
<target name="compile" depends="init" description="Compile the security Java source code">
<javac destdir="${classes.dir}" classpathref="build.classpath" debug="false" deprecation="false" nowarn="on">
<src path="src" />
</javac>
</target>
<target name="war" depends="compile">
<mkdir dir="${build.dir}/WEB-INF/lib"/>
<jar jarfile="${build.dir}/${name}.jar">
<fileset refid="project.classes"/>
<fileset refid="tomcat.resources"/>
</jar>
<jar jarfile="${build.dir}/mc-conf.jar">
<fileset refid="${tomcat.conf}"/>
</jar>
<copy todir="${build.dir}/resources/WEB-INF">
<fileset refid="tomcat.war.webinf"/>
<filterset>
<filter token="jndiPattern" value="#{ejbName}/local"/>
<filter token="embeddedEjb" value="true"/>
<filter token="microcontainer" value="true"/>
</filterset>
</copy>
<jar destfile="${build.dir}/${name}.war" duplicate="preserve">
<zipfileset refid="tomcat.lib"/>
<zipfileset refid="tomcat.seam.jar"/>
<zipfileset refid="tomcat.drools.jar"/>
<zipfileset refid="tomcat.extra.jar"/>
<zipfileset refid="war.docroot"/>
<zipfileset refid="war.webinf.lib"/>
<zipfileset dir="${build.dir}/resources">
<include name="WEB-INF/**/*.*"/>
<exclude name="WEB-INF/lib/*.jar"/>
</zipfileset>
<zipfileset dir="${build.dir}" prefix="WEB-INF/lib">
<include name="${name}.jar"/>
<include name="mc-conf.jar"/>
</zipfileset>
</jar>
</target>
<target name="deploy" depends="war">
<echo message="Deploying WAR to tomcat" level="info" />
<copy file="${deploy.file.path}" todir="${deploy.dir}" />
</target>
<target name="undeploy">
<echo message="undeploy ${deploy.file} from ${deploy.dir}" level="info" />
<delete file="${deploy.dir}/${deploy.file}" />
</target>
</project>