10 Replies Latest reply on Apr 21, 2007 2:41 PM by pmuir

    Building the correct WARs for Tomcat

    tim_perrett

      Hey 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>
      
      



        • 1. Re: Building the correct WARs for Tomcat
          pmuir

          Not that I know anything about tomcat, but what is the previous error?

          • 2. Re: Building the correct WARs for Tomcat
            tim_perrett

            From what i can find out it seams to be a generic error that tomcat produces when it cant do somthing. Which is, well, not very helpfull to be honest!

            There looks to be an active seam comunity but i guess your all using JBoss AS? I am running OSX and linux, so perhaps I might change development platform perhaps... what do people suggest, as i am wholy flexible at this point in time.

            I am only trying to do a simple hello world app at the moment yet there do not seem to be any basic basic tutorials on first getting running, especially when using tomcat! lol

            All the best

            Tim

            • 3. Re: Building the correct WARs for Tomcat
              pmuir

              Platform wise theres a complete mix, but I think most of us use JBoss AS on a day-to-day basis. Thats not to say it doesn't work on Tomcat (I just never use Tomcat). Chapters 1 and 2 of the reference manual should give you a good intro to Seam and to starting a project (Seam-gen really is the way to go)

              It may be the case you need Tomcat 5.5...

              • 4. Re: Building the correct WARs for Tomcat
                tim_perrett

                For sure, i have the examples working on tomcat no problem at all. Thats the ironic thing.... The examples worked out of the box, it just did what it said on the tin! lol

                I have been using seam-gen to build my projects so far with no problems. I just thought that i would keep it 100% simple, with a good old hello world example!

                I get errors when i try to deploy the examples into my JBoss install however. Is there any additional config i would need to do from an out of the box install of JBoss on OSX?

                Cheers

                Tim

                • 5. Re: Building the correct WARs for Tomcat
                  tim_perrett

                  I get the following error when deploying to Jboss

                  org.jboss.deployment.DeploymentInfo@37464ce7 { url=file:/Applications/jboss-4.0.5.GA/server/default/deploy/jboss-seam-contactlist.ear }
                  deployer: org.jboss.deployment.EARDeployer@c311d5
                  status: Deployment FAILED reason: ejb-jar.xml must either obey the right xml schema or define a valid DOCTYPE!
                  state: FAILED
                  watch: file:/Applications/jboss-4.0.5.GA/server/default/deploy/jboss-seam-contactlist.ear
                  altDD: null
                  lastDeployed: 1177158542986
                  lastModified: 1177158542000
                  mbeans:

                  Please if anyone has any ideas that would be splendid!

                  Cheers

                  Tim

                  • 6. Re: Building the correct WARs for Tomcat
                    pmuir

                    Install the AS using the JEMS installer, make sure to choose EJB3, as described in the getting started guide.

                    • 7. Re: Building the correct WARs for Tomcat
                      tim_perrett

                      lol excellent - its working, the examples anyway!

                      JBoss gives me better errors than tomcat and seems to work just as well so all good. Just a quick one about seam...

                      After creating a new project using seam gen, would you expect that to just work or does it *always* require extra config to start off with?

                      Cheers

                      Tim

                      • 8. Re: Building the correct WARs for Tomcat
                        pmuir

                        Well, if you generated an empty project then it should work ootb. If it's got some reverse engineering in it from an existing database schema it may need some tweaking.

                        • 9. Re: Building the correct WARs for Tomcat
                          tim_perrett

                          oh ok cool.

                          The thing is it keep generating Authenticator.java..... which looks to be a method for loggin in, wont this cause errors ootb?

                          I have the examples all working both tomcat and JBoss AS now, but i'll be dammed if i can make an seam-gen one work correctly lol

                          Even with a basic helloworld class it complains there is no table called "Greeter" - why would it need a table to say helloworld? is this some kind of built in default?

                          
                          package com.timperrett.seam.helloworld;
                          
                          import java.io.Serializable;
                          import javax.persistence.Entity;
                          import javax.persistence.GeneratedValue;
                          import javax.persistence.Id;
                          import org.jboss.seam.annotations.Name;
                          
                          @Entity
                          @Name("greeter")
                          public class Greeter implements Serializable {
                          
                           private static final long serialVersionUID = 1L;
                          
                           Long id;
                          
                           String message = "Hello world!";
                          
                           @Id @GeneratedValue
                           public Long getId() {
                           return id;
                           }
                          
                           public void setId(Long id) {
                           this.id = id;
                           }
                          
                          
                           public String getMessage() {
                           return message;
                           }
                          
                           public void setMessage(String message) {
                           this.message = message;
                           }
                          }
                          
                          
                          


                          Cheers, appologies for these dumb questions, im very new to seam!

                          Tim

                          • 10. Re: Building the correct WARs for Tomcat
                            pmuir

                            The authenticator is indeed for security, but the authenticate method just returns true (i.e. you have passed authentication) by default.

                            You've made your class below an @Entity - so it's backed by the database. Set hibernate.hbm2ddl.auto to true in persistence.xml for Hibernate to autonmatically create the schema. Also, to start, its best to use the HSQL defaults suggested by seam-gen as then you don't have to worry about problems connecting to the database.