Integrating AppFuse and NetBeans 5.0

This entry has been updated from it original form. Folks had run into an issue that I thought was an "only on my machine...' thing.

I have been experimenting with AppFuse and the various builds from the GlassFish project. Since NetBeans works well with GlassFish (and here, too), I wanted to create a integrated environment for it.

I created a "free form web-app project" that lets users perform many of the steps outlined in the AppFuse QuickStart from inside NetBeans.

The project also helps users extend the skeleton application that is created when they "execute" step 9 from the Quick Start. This project.xml only supports the "default" AppFuse skeleton (that uses Struts, Spring and Hibernate) today. I will update it to support some of the other supported configurations as I find time.

Here are some details about how you can create a nicely integrated environment for your AppFuse development, too.

  1. Download AppFuse 1.9.
  2. Unzip it someplace...
  3. cd into the appfuse directory that was created when you unzipped the archive.
  4. Create a directory named nbproject.
  5. Put a copy of my project.xml file into the nbproject directory.
  6. Start NetBeans 5.0 (if it isn't already)
  7. Use File->Open Project to open the appfuse project.
  8. Use Tools->Options to set add an ant property, env.CATALINA_HOME, with the value <NetBeansInstallDir>/enterprise2/jakarta-tomcat-5.5.9.

    Mac users will use NetBeans->Preferences to open the Options dialog. The path to the embedded Tomcat server is a bit more complex, too. For example, the value for env.CATALINA_HOME on my system is: /Users/vbk/Desktop/NetBeans.app/Contents/Resources/NetBeans/enterprise2/jakarta-tomcat-5.5.9

  9. NEW STEP::: open the build.xml in the editor, by double clicking on the build.xml icon.
  10. NEW STEP::: Replace:
      <attribute name="src.base.dir" default="../${app.name}"/>
      
      with
      <attribute name="src.base.dir" default="${basedir}/../${app.name}"/>
      
    It is line 1337 in the build.xml file for AppFuse 1.9.
  11. To execute step 8 from the Quick Start, you can use F6 or Run->Run Main Project.

    Answer the three questions that appear as dialogs.

  12. Use File->Open Project to open the new project created when the prior step executed.

    You will notice that the new directory already has the files necessary for it to be considered a NetBeans project. That is pretty cool.

  13. Since the builds from the GlassFish Project include Derby, you may want to use it (instead of MySQL). You need to make a couple changes to the project that you just opened.
    1. Edit properties.xml (which you can find in the Files view). Change
      <property name="database.url"
                value="jdbc:${database.type}://${database.host}/${database.name}?useUnicode=true&amp;characterEncoding=utf-8"/>
      
      to
      <property name="database.url_attributes" 
                value="?useUnicode=true&amp;characterEncoding=utf-8"/>
      <property name="database.url" 
                value="jdbc:${database.type}://${database.host}/${database.name}${database.url_attributes}"/>
      
    2. Add the following to the end of your build.properties file. Be SURE to replace the text '/Volumes/300gb/glassfish' with a the path to YOUR "GlassFish install".
      database.jar=/Volumes/300gb/glassfish/derby/lib/derbyclient.jar
      database.type=derby
      database.host=localhost
      hibernate.dialect=org.hibernate.dialect.DerbyDialect
      database.driver_class=org.apache.derby.jdbc.ClientDriver
      database.url_attributes=
      
    3. Use Tools->Derby Database->Start Derby Server to start up a Derby instance. If the Tools menu doesn't have a Derby Database item, you should register Sun Java System Application Server PE 9 Beta or a GlassFish Project build. The registration process does double duty. Use the Create Derby Database item to create the database which will host the data associated with the application that you are going to develop. NOTE: you may be able to use the URL Attribute create=true. I haven't tested that though.
  14. You can use the NetBeans' Ant integration to trigger the targets discussed in step 9 of the Quick Start. Unfortunately, the AppFuse scripts treat CATALINA_HOME as CATALINA_BASE (or vice-a-versa [perspective]). This means that you need to execute the setup-db and deploy targets seperately.
  15. At this point, you can start a registered GlassFish instance.
  16. Use the View Admin Console, item to open up the admin console.
  17. Select the Web Applications node from the navigation bar.
  18. Use the deploy button on the page that appears in the main window.
  19. Enter the path to the "deployed" AppFuse based application. It will be in <env.CATALINA_HOME>/webapps/<YOUR_APPLICATION_NAME_HERE>
  20. You should be able to access the "starter app" that AppFuse creates for you at this point with your browser
Hopefully, this entry has been enough to get you started. I will come expand on this in the next few days.
Comments:

Firstly, many thanks for this, I'm quite new to appfuse so having a project which works automatically in netbeans is just great. I'm having one problem though, when doing ant new, the name of the package is ignored, so my apps always use the default org.appfuse for the package base. This is odd, because the other input vars such as databasename and web app name work fine. This happens in both NetBeans 5.0 and 5.5Preview. Any ideas on what's wrong?

Posted by Stephen de Vries on March 17, 2006 at 11:32 PM PST #

I will check in to it. Have you tried running ant new "outside" NetBeans? Do you see anything unusual in the ant output when you run 'ant new' from inside NetBeans...

Posted by vince kraemer on March 18, 2006 at 03:55 AM PST #

Post a Comment:
Comments are closed for this entry.
About


Vince Kraemer writes the entries in this blog.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
News
Blogroll

No bookmarks in folder

automarks