1 Reply Latest reply on Apr 19, 2007 8:37 AM by Tim Perrett

    Tomcat target for your use (almost done - need help with bug

    Michael Harrison Newbie

      Hey everyone,

      If you create a simple MySql database and then use the seam command-line tool to create a WAR using this database, then everything works fine on JBoss but not on Tomcat. The WAR file assumes you are deploying to JBoss, not Tomcat. So I've created an Ant target to deploy to Tomcat. However, I always get stuck on the DataSource. Can anyone lend a hand? Here are the instructions to recreate my mess:

      1) Create a simple MySql database
      2) Run the Seam command-line tool, and create a new WAR project.
      Let's call this project 'tomtom'.
      3) Generate the entities using seam generate-entities
      4) In the 'tomtom' root directory, create a file called 'tomcat.xml' with these contents:

      <?xml version="1.0"?>
      <project name="Tomcat Target" default="war.tomcat" basedir=".">
       <property name="tomcat.dir" value="${tomcat.home}/webapps/${project.name}" />
       <property name="tomcat.extra.files" value="${basedir}/tomcat-extra-files"/>
       <target name="war.tomcat" depends="compile,copyclasses"
       description="Build the distribution .war file for Tomcat">
       <delete dir="${tomcat.dir}"/>
       <mkdir dir="${tomcat.dir}"/>
       <copy todir="${tomcat.dir}/WEB-INF/classes">
       <fileset dir="${basedir}/resources">
       <include name="seam.properties" />
       <include name="security.drl" />
       <copy todir="${tomcat.dir}/WEB-INF/classes">
       <fileset dir="${tomcat.extra.files}"/>
       <copy tofile="${tomcat.dir}/WEB-INF/classes/META-INF/persistence.xml"
       <copy tofile="${tomcat.dir}/WEB-INF/classes/components.properties"
       <copy tofile="${tomcat.dir}/WEB-INF/classes/${project.name}-${profile}-ds.xml"
       file="${basedir}/resources/${project.name}-${profile}-ds.xml" />
       <copy tofile="${tomcat.dir}/WEB-INF/classes/META-INF/jboss-beans.xml"
       overwrite="true" />
       <copy tofile="${tomcat.dir}/WEB-INF/classes/import.sql"
       <copy todir="${tomcat.dir}">
       <fileset dir="${basedir}/view" />
       <copy todir="${tomcat.dir}/WEB-INF">
       <fileset dir="${basedir}/resources/WEB-INF">
       <include name="*.*"/>
       <include name="classes/**/*.*"/>
       <exclude name="jboss-web.xml" />
       <exclude name="classes/**/*.class"/>
       <filter token="jndiPattern" value="#{ejbName}/local"/>
       <filter token="embeddedEjb" value="true"/>
       <filter token="microcontainer" value="true"/>
       <copy todir="${tomcat.dir}/WEB-INF">
       <fileset dir="${basedir}/resources/WEB-INF">
       <include name="lib/*.*"/>
       <include name="classes/**/*.class"/>
       <copy todir="${tomcat.dir}/WEB-INF/lib">
       <fileset dir="${lib.dir}">
       <include name="antlr-*.jar"/>
       <include name="ajax4jsf.jar" />
       <include name="commons-*.jar"/>
       <include name="drools-*.jar"/>
       <include name="el-ri.jar" />
       <include name="hibernate*.jar" />
       <include name="janino-*.jar"/>
       <include name="jboss-*.jar" />
       <exclude name="jboss-seam-gen.jar" />
       <include name="jbpm*.jar" />
       <include name="jsf-facelets.jar" />
       <include name="myfaces-*.jar" />
       <include name="mysql*.jar" />
       <include name="oscache*.jar" />
       <include name="standard.jar" />
       <include name="stringtemplate-*.jar"/>
       <include name="thirdparty*.jar" />
       <copy todir="${tomcat.dir}/WEB-INF/classes">
       <fileset dir="${basedir}/resources">
       <include name="messages*.properties"/>
       <copy todir="${tomcat.dir}/WEB-INF/classes">
       <fileset dir="${basedir}/resources">
       <include name="*jpdl.xml" />
       <include name="hibernate.cfg.xml" />
       <include name="jbpm.cfg.xml" />
       <jar jarfile="${tomcat.dir}/WEB-INF/lib/mc-conf.jar">
       <fileset dir="${embedded-ejb3.dir}"/>
       <javac classpathref="build.classpath"
       <src path="${src.java.dir}" />

      Now, in the build.xml file, add this line to import the deploy.tomcat target:

      <import file="tomcat.xml"/>

      The seam wizard leaves out a couple of important files, so underneath the 'tomtom' directory, create a new folder called 'tomcat-extra-files'. Add these two files from the Seam distribution:
      i) hibernate.cfg.xml
      ii) jbpm.cfg.xml

      And finally, in the build.properties file, add a variable for tomcat.home with the location of your Tomcat 5.5+ installation.

      If you run the deploy.tomcat target, it will deploy an exploded directory in Tomcat. Whenever I start Tomcat, it craps out at the DataSource bit.

      Any clue as to how I could fix this?

      My apologies for the extra-long post...