Hi,

I fiddled a bit with it. I havn't found the time to play around more with it since a couple of weeks ago. So my memory might fail me on some of the more subtle points.

Anyways I managed to configure eclipse with the sysdeo tomcat plugin so I could debug the application directly from eclipse.

My goal was to be able to use the hot code replace feature in java 1.4 to shorten compile/test cycles dramatically. Just fix bugs in the debugger, ctrl+s, test. Instead of stop tomcat, fix bug, deploy, restart tomcat, test. I didn't find much time to play with it. But I suspect the CGLib that hibernate is using to cause a bigger reload of classes than I expected. I don't know. Bottom line is that it doesn't work for me yet.

Instead of creating a WAR file every time and deploy that to the tomcat install dir, I focused on generating a WAR file structure within the eclipse project.

I changed the build output folder to:
appfuse/web/WEB-INF/classes

Then I added the contents attached (very very hacky) file. This adds a target local-deploy. Which will copy the generated files into the local web dir.

I used the WinMerge tool to compare with the generated deploy WAR to figure out which files should go where.

To make it all play nicely I also had to move the web/pages folder to web/WEB-INF/pages. The build script should of course be updated accordingly to work. But then again, adapting the WAR like file structure makes it a lot simpler to generate the WAR since all the contents are already in the right spots.

Finally I added the server.local.xml contents to my tomcat server.xml file so tomcat can see that I want to use a different location that tomcats default for my application. My appfuse is installed in d:\java\appfuse.

I hope this will help. I am sure there are much better and cleaner ways to achive all what I am trying to do.
I look forward to be educated!


/Lasse



    <target name="local-deploy" 
    	depends="init"
    	description="Copy resources and jars into the local web dir">

        <!-- Copies necessary web JAR, XML and TLD files -->
        <echo>Copying web JAR, XML and TLD files</echo>
        <mkdir dir="${local.target}/WEB-INF"/>
        <copy todir="${local.target}/WEB-INF">
            <fileset dir="${struts.dir}" includes="*.xml"/>
            <fileset dir="${strutsmenu.dir}/lib" includes="*.tld,*.xml"/>
        </copy>

        <mkdir dir="${local.target}/WEB-INF/lib"/>
        <!-- Copy struts jars -->
        <copy todir="${local.target}/WEB-INF/lib">
            <fileset dir="${struts.dir}">
                <include name="*.jar"/>
            </fileset>
            <fileset dir="${jstl.dir}/lib">
                <include name="jstl.jar"/>
                <include name="standard.jar"/>
            </fileset>
        </copy>
        <!-- copy log4j jar -->
        <copy todir="${local.target}/WEB-INF/lib" file="${log4j.jar}"/>        
        <!-- copy struts-menu -->
        <copy todir="${local.target}/WEB-INF/lib" file="${strutsmenu.jar}"/>
        <copy todir="${local.target}/WEB-INF/lib" file="${display.jar}"/>
        <!-- copy hibernate -->
        <copy todir="${local.target}/WEB-INF/lib" file="${hibernate.jar}"/>
        <copy todir="${local.target}/WEB-INF/lib">
            <fileset dir="${hibernate.dir}/lib">
                <include name="odmg.jar" />
                <include name="dom4j.jar" />
                <include name="cglib*.jar" />
            </fileset>
        </copy>
        <!-- copy state tag -->
        <copy todir="${local.target}/WEB-INF/lib" file="${statetag.jar}"/> 
        <!-- copy country tag -->
        <copy todir="${local.target}/WEB-INF/lib" file="${countrytag.jar}"/> 

        <!-- Copy .properties and .xml files from source directory -->
        <copy todir="${local.target}/WEB-INF/classes" includeEmptyDirs="no">
            <fileset dir="web/WEB-INF/classes">
            <patternset>
                <include name="**/*.properties"/>
                <include name="**/*.xml"/>
                <include name="**/*.ccf"/>
            </patternset>
            </fileset>
            <filterset>
                <filter token="HTTP-PORT" value="${http.port}"/>
                <filter token="HTTPS-PORT" value="${https.port}"/>
                <filter token="TOMCAT-SERVER" value="${tomcat.server}"/>
                <filter token="APPNAME" value="${webapp.name}"/>
                <filter token="ERROR-MAILTO" value="${error.mailTo}"/>
                <filter token="ERROR-MAILHOST" value="${error.mailHost}"/>
                <filter token="ERROR-SERVER" value="${error.server}"/>
            </filterset>
            <fileset dir="src/web">
            <patternset>
                <exclude name="**/*.xml"/>
                <include name="**/*.properties"/>
            </patternset>
            </fileset>
        </copy>
<!-- not in the WAR       
        <copy tofile="${local.target}/WEB-INF/classes/hibernate.properties" 
            file="database.properties" />
        <copy todir="${local.target}/WEB-INF/classes" 
            file="mail.properties" />
-->            
        <!-- Copy *.txt files so they can be included in release notes -->
        <copy todir="${local.target}">
            <fileset dir="${basedir}">
                <include name="*.txt"/>
            </fileset>
        </copy>

		<!-- Used WinMerge to 'patch' the local web directory so it matched the files in the unpacked WAR -->
		<!-- other files that seems to 'live' in the build dir are copied here -->
        <copy todir="${local.target}/WEB-INF">
            <fileset dir="${build.dir}/appfuse/WEB-INF" includes="appfuse.tld"/>
        </copy>
        <copy todir="${local.target}/WEB-INF">
            <fileset dir="${build.dir}/appfuse/WEB-INF" includes="struts-config.xml"/>
        </copy>
        <copy todir="${local.target}/WEB-INF">
            <fileset dir="${build.dir}/appfuse/WEB-INF" includes="validation.xml"/>
        </copy>
		
        <copy todir="${local.target}/WEB-INF/classes">
            <fileset dir="${build.dir}/appfuse/WEB-INF/classes">
            <patternset>
                <include name="ApplicationResources.properties"/>
                <include name="cactus.properties"/>
                <include name="build.properties"/>
                <include name="hibernate.cfg.xml"/>
                <include name="log4j.properties"/>
                <include name="UploadResources.properties"/>
                                
            </patternset>
            </fileset>
        </copy>
		
		<copy todir="${local.target}/WEB-INF/classes">
			<fileset dir="${build.dir}/ejb/gen/" includes="**/*.xml"/>
		</copy>
		
        <copy todir="${local.target}/WEB-INF">
            <fileset dir="${build.dir}/web/WEB-INF" includes="web.xml"/>
        </copy>
    </target>
        <!-- AppFuse Application Context -->
        <Context 
            path="/appfuse" 
            docBase="D:\java\appfuse\web" 
            workDir="D:\java\appfuse\web\WEB-INF\jsp" 
            debug="99" 
            reloadable="true"
        >
            <Logger className="org.apache.catalina.logger.FileLogger" 
                prefix="appfuse_log." suffix=".txt" timestamp="true"/>
        
            <!--
            <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
                  driverName="com.mysql.jdbc.Driver"
               connectionURL="jdbc:mysql://localhost:3306/appfuse?autoReconnect=true"
              connectionName="test" connectionPassword="test"
                   userTable="users" userNameCol="username" userCredCol="password"
               userRoleTable="user_roles" roleNameCol="role_name" />
            
            <Realm className="org.apache.catalina.realm.JNDIRealm" debug="99"
              connectionName="cn=Manager,dc=raibledesigns,dc=com"
          connectionPassword="secret"
               connectionURL="ldap://drevil:389";
                userPassword="userPassword"
                 userPattern="uid={0},ou=people,dc=raibledesigns,dc=com"
                    roleBase="ou=groups,dc=raibledesigns,dc=com"
                    roleName="cn"
                  roleSearch="(uniqueMember={0})" />
        
            <Realm className="org.apache.catalina.realm.JAASRealm" debug="99"
                   appName="NTLogin"
                   userClassNames="com.tagish.auth.win32.NTPrincipal"
                   roleClassNames="com.tagish.auth.win32.NTPrincipal" />
           -->
        
            <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
                  driverName="com.mysql.jdbc.Driver" digest="SHA"
               connectionURL="jdbc:mysql://localhost:3306/appfuse?autoReconnect=true"
              connectionName="test" connectionPassword="test"
                   userTable="app_user" userNameCol="username" userCredCol="password"
               userRoleTable="user_role" roleNameCol="role_name" />
            <Resource name="jdbc/appfuse" auth="Container" type="javax.sql.DataSource"/>
            <ResourceParams name="jdbc/appfuse">
                <parameter>
                    <name>factory</name>
                    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
                </parameter>
                <!-- Maximum number of dB connections in pool. Make sure you
                     configure your mysqld max_connections large enough to handle
                     all of your db connections. Set to 0 for no limit.
                     -->
                <parameter>
                    <name>maxActive</name>
                    <value>100</value>
                </parameter>
                <!-- Maximum number of idle dB connections to retain in pool.
                     Set to 0 for no limit.
                     -->
                <parameter>
                    <name>maxIdle</name>
                    <value>30</value>
                </parameter>
                <!-- Maximum time to wait for a dB connection to become available
                     in ms, in this example 10 seconds. An Exception is thrown if
                     this timeout is exceeded.  Set to -1 to wait indefinitely.
                     -->
                <parameter>
                    <name>maxWait</name>
                    <value>10000</value>
                </parameter>
                <!-- MySQL dB username and password for dB connections  -->
                <parameter>
                    <name>username</name>
                    <value>test</value>
                </parameter>
                <parameter>
                    <name>password</name>
                    <value>test</value>
                </parameter>
                <!-- Class name for mm.mysql JDBC driver -->
                <parameter>
                    <name>driverClassName</name>
                    <value>com.mysql.jdbc.Driver</value>
                </parameter>
                <!-- Autocommit setting.  This setting is required to make
                     Hibernate work.  Or you can remove calls to commit(). -->
                <parameter>
                    <name>defaultAutoCommit</name>
                    <value>false</value>
                </parameter>
                <!-- The JDBC connection url for connecting to your MySQL dB.
                     The autoReconnect=true argument to the url makes sure that the
                     mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
                     connection.  mysqld by default closes idle connections after 8 hours.
                     -->
                <parameter>
                    <name>url</name>
                    <value>jdbc:mysql://localhost:3306/appfuse?autoReconnect=true</value>
                </parameter>
                <!-- Recover abandoned connections -->
                <parameter>
                    <name>removeAbandoned</name>
                    <value>true</value>
                </parameter>
                <!-- Set the number of seconds a dB connection has been idle 
                     before it is considered abandoned. 
                     -->
                <parameter>
                    <name>removeAbandonedTimeout</name>
                    <value>60</value>
                </parameter>
                <!-- Log a stack trace of the code which abandoned the dB 
                     connection resources. 
                     -->
                <parameter>
                    <name>logAbandoned</name>
                    <value>true</value>
                </parameter>
            </ResourceParams>
            <!-- This is not used at this time, but may be in the future -->
            <Resource name="mail/Session" auth="Container" type="javax.mail.Session"/>
            <ResourceParams name="mail/Session">
                <parameter>
                    <name>mail.smtp.host</name>
                    <value>localhost</value>
                </parameter>
            </ResourceParams>
        </Context>        

Reply via email to