Skip to content

AppFuse automatic build with eclipse

for appfuse 2.x do this:

Download JavaRebel

  • Download JavaRebel
  • place javarebel.jar in your home directory
  • If you are using the demo license, i.e. no license, it will expire after 21 days – if you want to continue using JavaRebel with your Scala projects, get the free JavaRebel for Scala license and put it into the directory which contains javarebel.jar.

Jetty

You can also use JavaRebel with Jetty.

Edit your pom.xml file and set the scanIntervalSeconds param to 0, this will turn off Jetty’s internal reloading. Jetty’s internal reloading won’t keep your session after reloading changed classes. <scanIntervalSeconds>0</scanIntervalSeconds>

Start jetty with the maven jetty plugin and the MAVEN_OPTS parameter set

MAVEN_OPTS="-noverify -javaagent:~/javarebel.jar" mvn jetty:run

Run mvn compile in another terminal and JavaRebel will reload your changed classes.

Or to incrementally compile your Scala source files as they change run mvn scala:cc

this is a copy from http://wiki.liftweb.net/index.php?title=JavaRebel

for old appfuse 1.x do the following:

this here is my way of working with appfuse in eclipse, i choosed the appfuse-basic-spring.
The Build and compile process took me to much time so i took advantage of the eclipse autobuild function!
If you change a controller for example, save it than you have the changes by reloading the website in notime. not everything gets changed by reloading the site but most of it. Sometimes you have to restart tomcat to apply major changes but this is a question of like 10 seconds. This setup saved me so much time and energy. The dev process speeded up by like 10 times ;)

  1. first update or install Maven
    1. by downloading it from here, then unpack it into /Applications
    2. view your ~/.profile file and add this:
      export M2_HOME=/Applications/apache-maven-x.x.x/
      export M2=$M2_HOME/bin
      export PATH=$M2:$PATH
            
  2. now open a new terminal to apply the system parameter settings and start installing appfuse
    1. change the -DgroupId and the -DartifactId value and enter the complete command
      mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes \
      -DarchetypeArtifactId=appfuse-basic-spring \
      -DremoteRepositories=http://static.appfuse.org/releases \
      -DarchetypeVersion=2.0.2 -DgroupId=org.mydomain -DartifactId=myapp 
    2. go to the directory ‘myapp’ and apply the settings for your local database user at the bottom of pom.xml
    3. run ‘mvn war:inplace’ and ‘mvn appfuse:full-source’ and ‘mvn install eclipse:eclipse’
    4. if all maven builds were sucsessfull than you are ready
  3. to download the sysdeo tomcat plugin from here and unpack it to the eclipse plugin folder
  4. open eclipse and
    1. go to file -> import and select ‘exsiting projects into workspace’ than point to your myapp path and hit ‘finish’
    2. than press ^H for a projectwide search. search for ‘org.appfuse’ replace everything interesting with ‘my.org’ from the -DgroupId
    3. go to the projects properties and select the ‘java build path’ there click on ‘source’ and delete everything!!!
    4. click on ‘add folder’, check /src/main and hit enter now select the build path again to edit, click next to enter the excluded parameter: ‘webapp/’
    5. add another source folder the same way for ‘/srv/main/webapp’ and check if the Default output folder is ‘myapp/target/classes’
    6. click on the ‘Libraries’ tab and add the variable ‘M2_REPO’ which has the value ~/.m2/repository/
    7. open the file web.xml in the WEB-INF dir and set the ‘contextConfigLocation’ to:
    8. <context-param>
      	<param-name>contextConfigLocation</param-name>
      	<param-value>
             classpath*:/applicationContext.xml
             /WEB-INF/applicationContext*.xml
             /WEB-INF/xfire-servlet.xml
             /WEB-INF/security.xml
      	</param-value>
      </context-param>
    9. after this you need to copy the 3 applicationContext files from the resources dir to the WEB-INF dir.
  5. go to the eclipse properties and select tomcat
    1. set the version and the path and the declaration mode. i still use the server.xml style which is old i think.
    2. apply the settings and go to the subcat ‘JVM Settings’ there change the JRE to 1.6.0 and click on ‘Directory’ at the Classpath field.
    3. Here point to the default output folder and add it ‘/abosolute/path/to/myapp/target/classes’
    4. ok, now add these jars from your tomcat lib folder to the classpath: jsp-api, servlet-api and jasper-*
    5. for the last time click on the add ‘jar/zip’ button and point to ‘…/target/classes/WEB-INF/lib’ and add every jar in there by selecting all with the ^a combination
    6. hit apply
  6. view the /tomcat/conf/server.xml and add the context like this before the closing ‘Host’ tag at the bottom:
    <Context path="myapp" reloadable="true" docBase="/absolute/path/to/myapp/target/classes" />
  7. so now you are good to go by checkin Project -> Build Automatically is enabled
  8. if you click the little tomcat icon and the context is starting up everyting is ok.
  9. now please go to localhost:8080/myapp and check if its running.

When you like to copy the contents of the classes folder to the production tomcat than you can use my little batch file: here

the usage is really easy:

transferMyapp.sh -e system -l "/absolute/path/to/myapp/target/classes" \
-r /srv/tomcat_prod/webapps/ -app myapp1 -t "/srv/tomcat_prod" -srv user@mydomain.org

for vista if not jet done please install the following apps:

for maven open the powershell and enter line by line the following commands to set the environment vars JAVA_HOME, M2, M2_HOME and to update the path for the user:

$env:M2_HOME = 'C:\Program Files (x86)\apache-maven-2.0.9'
$env:M2 =$env:M2_HOME + '\bin'
[System.Environment]::SetEnvironmentVariable("M2_HOME", $env:M2_HOME , "User")[System.Environment]::SetEnvironmentVariable("M2", $env:M2 , "User")
$env:Path = $env:Path + ';' +$env:M2
$env:JAVA_HOME = 'C:\Program Files (x86)\Java\jdk1.6.0_10'
[System.Environment]::SetEnvironmentVariable("JAVA_HOME", $env:JAVA_HOME, "User")
[System.Environment]::SetEnvironmentVariable("PATH", $env:Path, "User")

well thats all for the powershell :(  i thought it would work to execute the mvn project build but nope.
going on in dos (cmd.exe):
execute: mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes \
-DarchetypeArtifactId=appfuse-basic-spring -DremoteRepositories=http://static.appfuse.org/releases \
-DarchetypeVersion=2.0.2 -DgroupId=org.mydomain -DartifactId=myapp 

Categories: AppFuse, Uncategorized, mac.

Tags: , , , , , , , , , ,

Comment Feed

One Response

  1. I was good up until I tried to get it to work in websphere. Jetty works fine… but I still for the life of me can’t get it working with Tomcat in Eclipse through either this plugin or WPT



Some HTML is OK

or, reply to this post via trackback.