3 Replies Latest reply on Jul 18, 2009 12:08 AM by Arbi Sookazian

    converting EAR to WAR and achieving incremental hot deploy for POJOs

    Arbi Sookazian Master

      Converted all SLSB/SFSB classes to JavaBeans.  made changes to persistence.xml and components.xml.  App deploys fine now as a WAR.


      Am I supposed to see activity in the console when I run 'ant explode' for my newly converted WAR which was an EAR?  Apparently, the app is being undeployed then re-deployed by JBoss when I run explode target.


      I just cleared the console and ran 'ant explode' and I see this:


      14:19:20,393 INFO  [TomcatDeployer] undeploy, ctxPath=/ERS, warUrl=.../deploy/ERS.war/
      14:19:20,393 INFO  [SessionFactoryImpl] closing
      14:19:20,393 INFO  [SessionFactoryImpl] closing
      14:19:20,596 INFO  [StaleObjectLogConfigurer] stale object exceptions will be hidden from logging
      14:19:20,612 INFO  [TomcatDeployer] deploy, ctxPath=/ERS, warUrl=.../deploy/ERS.war/
      14:19:23,392 INFO  [ServletContextListener] Welcome to Seam 2.0.2-FP
      ...
      14:19:34,218 INFO  [SeamFilter] Initializing filter: org.jboss.seam.web.redirectFilter
      14:19:34,218 INFO  [SeamFilter] Initializing filter: org.jboss.seam.web.exceptionFilter
      14:19:34,218 INFO  [SeamFilter] Initializing filter: org.jboss.seam.web.multipartFilter
      14:19:34,218 INFO  [SeamFilter] Initializing filter: org.jboss.seam.debug.hotDeployFilter
      



      Is this correct or should the incremental hot deploy behave the same as it did for facelets in my EAR project?


      Here is my customized build.xml:


      <target name="explode" depends="war,datasource,appconfig" 
                  description="Deploy the exploded archive">
              <fail unless="jboss.home">jboss.home not set</fail>
              
              <echo message="war.action.dir = ${war.action.dir}"/>
              <mkdir dir="${war.deploy.dir}"/>
              <copy todir="${war.deploy.dir}">
                  <fileset dir="${war.dir}"/>
              </copy>
          </target>



      <target name="war" depends="compilemodel,compileutil,compilews-client,compiledao,compileactions,copyclasses" description="Build the distribution .war file">
              
              <copy todir="${war.dir}/WEB-INF/classes">
                  <fileset dir="${basedir}/resources">
                      <include name="seam.properties" />
                      <include name="*.drl" />
                  </fileset>
              </copy>
              
              <!-- using example from section 12.4.1 of Manning Ant book to copy and filter for param-value in web.xml: facelets.DEVELOPMENT=[true/false]  -->                          
                      <copy todir="${war.dir}/WEB-INF"
                                file="${basedir}/resources/WEB-INF/web.xml"
                                overwrite="yes">
                                <!-- filter token replace @facelets-debug@ in web.xml -->
                    <filterset>    
                                              <filter token="facelets-debug" value="${debug}"/>                       
                    </filterset>
                  </copy>
              
              <echo message="in debug/jndiPattern filterset: debug = ${debug}"/>
              
              <!-- asookazi: renaming persistence-${profile}-war.xml to persistence-${profile}.xml -->
              <copy tofile="${war.dir}/WEB-INF/classes/META-INF/persistence.xml" 
                    file="${basedir}/resources/META-INF/persistence-${profile}.xml"
                    overwrite="true"/>
              <!--
              <copy tofile="${war.dir}/WEB-INF/classes/import.sql" 
                    file="${basedir}/resources/import-${profile}.sql"
                    overwrite="true"/>
              -->
              
              <copy todir="${war.dir}">
                  <fileset dir="${basedir}/view" />
              </copy>
              
              <copy todir="${war.dir}/WEB-INF">
                  <fileset dir="${basedir}/resources/WEB-INF">
                      <include name="*.*"/>
                      <include name="classes/**/*.*"/>
                      <exclude name="classes/**/*.class"/>
                      <exclude name="classes/**/*.groovy"/>
                  </fileset>
                  <filterset>
                      <filter token="debug"       value="${debug}" />
                      <filter token="jndiPattern" value="${project.name}/#{ejbName}/local"/>
                  </filterset>
              </copy>
              
              <copy todir="${war.dir}/WEB-INF">
                  <fileset dir="${basedir}/resources/WEB-INF">
                      <include name="lib/*.*"/>
                      <include name="classes/**/*.class"/>
                  </fileset>
              </copy>
              
              <copy todir="${war.dir}/WEB-INF/lib">
                  <fileset dir="${lib.dir}">
                      <includesfile name="deployed-jars.list"/>
                      <exclude name="jboss-seam-gen.jar"/>
                      <include name="groovy-*.jar" if="groovy.present"/>
                  </fileset>
              </copy>
              
              <copy todir="${war.dir}/WEB-INF/classes">
                  <fileset dir="${basedir}/resources"> 
                      <include name="messages*.properties"/>
                  </fileset>
              </copy>
              
              <copy todir="${war.dir}/WEB-INF/classes">
                  <fileset dir="${basedir}/resources">
                      <include name="*jpdl.xml" />
                      <include name="*hibernate.cfg.xml" />
                      <include name="jbpm.cfg.xml" />
                  </fileset>
              </copy>
              
          </target>



      <!-- customized -->
              <target name="compilews-client" depends="init"
                  description="Compile the Java source code for ws-client"
                  unless="eclipse.running">
              <javac classpathref="build.classpath" 
                     destdir="${classes.model.dir}" 
                     debug="${javac.debug}" 
                     deprecation="${javac.deprecation}" 
                     nowarn="on">
                  <src path="${src.ws-client.dir}" />
              </javac>
          </target>
              
              <!-- customized -->
              <target name="compileutil" depends="init"
                  description="Compile the Java source code for utility classes"
                  unless="eclipse.running">
              <javac classpathref="build.classpath" 
                     destdir="${classes.model.dir}" 
                     debug="${javac.debug}" 
                     deprecation="${javac.deprecation}" 
                     nowarn="on">
                  <src path="${src.util.dir}" />
              </javac>
          </target>
              
              <!-- customized -->
              <target name="compiledao" depends="init"
                  description="Compile the Java source code for DAO classes"
                  unless="eclipse.running">
              <javac classpathref="build.classpath" 
                     destdir="${classes.model.dir}" 
                     debug="${javac.debug}" 
                     deprecation="${javac.deprecation}" 
                     nowarn="on">
                  <src path="${src.dao.dir}" />
              </javac>
          </target>
          
          <target name="compilemodel" depends="init,groovy.compilemodel"
                  description="Compile the Java source code"
                  unless="eclipse.running">
              <javac classpathref="build.classpath" 
                     destdir="${classes.model.dir}" 
                     debug="${javac.debug}" 
                     deprecation="${javac.deprecation}" 
                     nowarn="on">
                  <src path="${src.model.dir}" />
              </javac>
          </target>
      
          <target name="groovy.compilemodel" if="groovy.present">
              <!-- model is always compiled -->
              <groovyc classpathref="build.classpath"
                     destdir="${classes.model.dir}"
                     srcdir="${src.model.dir}" >
              </groovyc>
          </target>
          
          <target name="compileactions" depends="init,groovy.compileactions,groovy.copyactions"
                  description="Compile the Java source code"
                  unless="eclipse.running">
              <echo message="src.action.dir = ${src.action.dir}"/>
              <echo message="classes.model.dir = ${classes.model.dir}"/>
              <javac classpathref="build.classpath" 
                     destdir="${classes.action.dir}"
                     debug="${javac.debug}" 
                     deprecation="${javac.deprecation}" 
                     nowarn="on">
                  <classpath path="${classes.model.dir}"/>              
                  <src path="${src.action.dir}" />
              </javac>
          </target>



      I know that the restart target forces JBoss to undeploy/deploy the WAR/EAR but I am running explode target in this case, not restart.


      Anybody know what I can do to fix this?

        • 1. Re: converting EAR to WAR and achieving incremental hot deploy for POJOs
          Arbi Sookazian Master

          Here is the original explode target descriptor:


          <target name="explode" depends="jar,war,ear,datasource,appconfig" 
                                  description="Deploy the exploded archive">
                          <fail unless="jboss.home">jboss.home not set</fail>
                          
                          <mkdir dir="${jar.deploy.dir}"/>
                          <mkdir dir="${war.deploy.dir}"/>                
                          
                          <copy todir="${jar.deploy.dir}">
                                  <fileset dir="${jar.dir}"/>
                          </copy>
                          <copy todir="${war.deploy.dir}">
                                  <fileset dir="${war.dir}"/>
                          </copy>
                          <copy todir="${ear.deploy.dir}">
                                  <fileset dir="${ear.dir}"/>
                          </copy>
                  </target>



          This one does not have the auto-redeploy problem that the current build.xml's explode target does have.


          I ran the dependency targets in the correct order one by one (first war, then datasource, then appconfig) with no problems and no auto-redeploy.  So perhaps it's something in the code for the target that is causing the auto-redeploy?  The code is very similar except for an <echo> message in the WAR build.xml:


          <target name="explode" depends="war,datasource,appconfig" 
                      description="Deploy the exploded archive">
                  <fail unless="jboss.home">jboss.home not set</fail>
                  
                   <echo message="war.action.dir = ${war.action.dir}"/>
                  <mkdir dir="${war.deploy.dir}"/>
                  <copy todir="${war.deploy.dir}">
                      <fileset dir="${war.dir}"/>
                  </copy>
              </target>



          There are no references to <touch> except for the restart target....


          This behavior is totally killing the whole purpose of my day's effort to convert my project from EAR to WAR...

          • 2. Re: converting EAR to WAR and achieving incremental hot deploy for POJOs
            Arbi Sookazian Master

            ok it looks like web.xml if being touched as the timestamp on that file is more recent than other files in this directory:


            C:\java\jboss-eap-4.3\jboss-as\server\default\deploy\ERS.war\WEB-INF



            I'm seeing 2:58PM for web.xml and the others are 2:54PM (same day - today).


            ran 'ant explode' again and now the timestamp for web.xml is 3:01PM.


            so the question now is why is that file being touched?  I did not alter the contents of that file manually for Ant to copy that file over to the destination directory in JBoss...

            • 3. Re: converting EAR to WAR and achieving incremental hot deploy for POJOs
              Arbi Sookazian Master

              Root cause identified:


              <!-- using example from section 12.4.1 of Manning Ant book to copy and filter for param-value in web.xml: facelets.DEVELOPMENT=[true/false]  -->
                       
                        <copy todir="${war.dir}/WEB-INF"
                               file="${basedir}/resources/WEB-INF/web.xml"
                               overwrite="yes">                 
                            <filterset>    
                                       <filter token="facelets-debug" value="${debug}"/>                       
                            </filterset>
                       </copy>
                       



              By commenting that <copy> snippet, web.xml is no longer being modified and thus it's not being copied by Ant and thus not triggering a auto-redeploy.


              Now.  This code worked fine when my project was an EAR because the auto-redeploy in the case of an EAR is triggered by the application.xml, not web.xml.


              So this means if I continue with a WAR for hot incremental hot deployment of POJOs, I lose this functionality.


              Any workaround to solve this?  Otherwise I must hard-code the facelets-debug value (not a big deal I guess but it would be nice if there was some fix/workaround for this problem).