Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
AppFuseDebug
AppFuseSupport
Articles
Articles_cn
Articles_de
Articles_ko
Articles_pt
Articles_zh
DevelopmentEnvironme...
DevelopmentEnvironme...
...and 1 more




JSPWiki v2.2.33

[RSS]


Hide Menu

AppFuseEclipse


Difference between version 65 and version 43:

At line 1 changed 1 line.
[AppFuse], by default, is configured to be an [Eclipse|http://www.eclipse.org] project. When you run __ant new -Dapp.name=''yourApp'' -Ddb.name=''yourDatabase''__ you will get the .project and .classpath files to start your project with. However, you will need to make a few easy setting changes in Eclipse (particularly to run [Ant|http://jakarta.apache.org/ant]). This tutorial shows you how to setup Eclipse to develop your AppFuse project.
[AppFuse], by default, is configured to be an [Eclipse|http://www.eclipse.org] project. When you run __ant new__ to create a new project, you will get the .project and .classpath files to start your project with. However, you will need to make a few easy setting changes in Eclipse (particularly to run [Ant|http://jakarta.apache.org/ant]). This tutorial shows you how to setup Eclipse to develop your AppFuse project.
At line 5 changed 1 line.
This tutorial is based on Windows XP and Eclipse 3.0 and should work on any platform.
This tutorial is based on Windows XP and Eclipse 3.0.1 and should work on any platform. You can [download Eclipse 3.0.1|http://cudlug.cudenver.edu/eclipse/eclipse/downloads/drops/R-3.0.1-200409161125/] if you don't already have it installed. I also recommend downloading [my Eclipse plugins bundle|http://www.raibledesigns.com/page/rd/?anchor=eclipse_plugins_updated_for_31] or purchasing [MyEclipse|http://www.myeclipseide.com]. A pipe dream of mine is to be able to use create a MyEclipse/AppFuse project - but that would likely require an entire rewrite of AppFuse's directory structure and build file and I just don't have the time or energy. Besides, the current system works pretty well if you don't mind using Ant.
At line 10 changed 5 lines.
* [3] Add junit.jar to Ant's classpath
* [4] Add build.xml to Ant View
* [5] Run Ant
* [6] Run JUnit Tests in Eclipse
* [7] Tips for Debugging and UI Editing
* [3] Add build.xml to Ant View
* [4] Run Ant
* [5] Run JUnit Tests in Eclipse
* [6] Tips for Debugging and UI Editing
At line 17 changed 1 line.
Open Eclipse (either with an existing or a new workspace) and to go File → New → Project. Then select "Java Project" and hit the Next button. In the Project Name field, enter the name of the directory that your project lives (i.e. c:\source\appfuse).
Open Eclipse (either with an existing or a new workspace) and to go File → New → Project. Then select "Java Project" and hit the Next button. In the Project Name field, enter the name of your project (i.e. appfuse) and the directory that your project lives (i.e. c:\source\appfuse) in the box below. If you're prompted to switch the Java Perspective, choose Yes.
At line 25 changed 1 line.
!!Add J2EE_HOME to Classpath Variables [#2]
!!Configuring Ant in Eclipse [#2]
At line 27 changed 1 line.
Go to Window → Preferences. Navigate to Java → Classpath Variables. Click the New... button and enter J2EE_HOME for the name field. In the path field enter the pathname to the directory of your J2EE JDK or click the Folder.. button and select the directory. Click on OK one or more times to return to the main Eclipse window. Eclipse will now rebuild your project and the Unbound class variable problem should be gone.
The easiest way to configure Eclipse for AppFuse is to install Ant on your hard drive (i.e. c:\Tools\apache-ant-1.6.2) and then point Eclipse's ANT_HOME to this directory. To do this, go to Window → Preferences → Ant → Runtime. Then click the "Ant Home" button and select the installation folder on your hard drive.
At line 29 changed 2 lines.
!!Add JUnit to Ant's classpath [#3]
Adding junit.jar to Ant's classpath is pretty easy. Open Eclipse and go to Window → Preferences. Navigate to Ant → Runtime and you should a window similar to the one below.
If you'd rather use Eclipse's built-in Ant, you'll need to add junit.jar to its classpath. To do this, go to Window → Preferences → Ant → Runtime. Then click the "Add JARs" button and select junit.jar from appfuse/lib/junit3.8.1/lib/junit.jar. Click OK until you arrive back at the workbench view.
At line 32 changed 1 line.
Note - in Eclipse 3.0 the dialog has changed. I found you had to add junit.jar to the "Ant Home Entries" as it didn't work under "Global Entries".
Next, add the __catalina-ant.jar__ (from $CATALINA_HOME/server/lib) to the ant classpath. Then in the property tab, add __tomcatTasks.properties__ (in lib/ant-contrib) file as a global properties file.
At line 34 changed 1 line.
[ant-runtime.png]
Lastly, still in Ant - Runtime - Properties tab, add the global property "tomcat.home" with a value of your CATALINA_HOME environment variable.
At line 36 changed 1 line.
You will need to add junit.jar to the __additional classpath entry__ in the bottom pane. If you have Ant installed, and junit.jar in it's ''lib'' directory, I'd use that. Otherwise, you can use the junit.jar file in the lib/junit3.8.1 directory.
Below is a screenshot of what your Ant Runtime classpath should look like after the above modifications:
At line 38 changed 1 line.
__Note:__ Sometime between M4 and M7, the layout of the Runtime properties page has changed. Be sure to add junit.jar to the __Ant Home Entries__ rather than the ''Global Entries''.
[ant-runtime.png]
At line 40 changed 1 line.
!!Add build.xml to Ant View [#4]
!!Add build.xml to Ant View [#3]
At line 45 changed 2 lines.
!!Run Ant [#5]
After adding the build.xml, you should be able to expand it in the Ant View and execute any of the targets. You should make sure that your $J2EE_HOME environment variable is set (not just the Classpath Variables you configured above), since AppFuse relies on this. At this point, you should see something similar to the screenshot below.
!!Run Ant [#4]
After adding the build.xml, you should be able to expand it in the Ant View and execute any of the targets. I usually do "test-all" to verify all the tests pass in my initial project. For a list of targets I use most often, see [AppFuse Ant Targets|AppFuseAntTasks].
At line 46 added 13 lines.
Now if you run the "compile" target and then refresh the project (right-click on project → Refresh) you shouldn't see any errors in the "Problems" pane. You should now be able to compile and create classes as you normally would. Sometimes when my imports aren't resolving correctly in Eclipse, I do have to run Project → Clean in Eclipse.
%%note __NOTE:__ If you're using the internal version of Ant, you may get an error message like the one below:
{{{
BUILD FAILED: C:\source\appfuse\build.xml:802: The following error occurred while executing this line:
C:\source\appfuse\build.xml:780: The following error occurred while executing this line:
java.lang.NoClassDefFoundError: org/apache/xml/serialize/OutputFormat
}}}%%
This is because there are tasks that require Xerces to be in your Ant classpath [[<a href="http://wiki.apache.org/jakarta-cactus/FrequentlyAskedQuestions">reference</a>]. I added xercesImpl.jar and xml-apis.jar (from my self-installed version of Ant) to Eclipse's Ant classpath to solve this.
At this point, you should see something similar to the screenshot below.
At line 50 changed 2 lines.
!!Run JUnit Tests in Eclipse [#6]
It's also possible to run your JUnit tests in Eclipse. I should note that if you're running an ActionTest, you'll need to execute "ant deploy-test-war" and then start Tomcat before running them. To configure Eclipse to run AppFuse's JUnit Tests, all you need to do is define a J2EE_HOME variable. To do this, go to Window &rarr; Preferences &rarr; Java &rarr; Classpath Variables. Add a new variable called J2EE_HOME and point it to the location where you have the [J2EE SDK|http://java.sun.com/j2ee/download.html#sdk] installed. AppFuse already has its classpath configured (in the .classpath file) to include J2EE_HOME/lib/j2ee.jar.
!!Run JUnit Tests in Eclipse [#5]
It's also possible to run your JUnit tests in Eclipse. But before running them, you need to run the "war" target. After this target completes, refresh your project.
At line 53 changed 1 line.
Also, before running any JUnit Tests in Eclipse, you need to run "ant test-all" from the command line. After you have successfully done so, in Eclipse open a test you'd like to run (i.e. UserDaoTest) and go to Run &rarr; Debug As &rarr; JUnit Test. If this doesn't work, make sure you have AppFuse 1.0.1+
After you have successfully done so, in Eclipse open a test you'd like to run (i.e. UserDaoTest) and go to Run &rarr; Debug As &rarr; JUnit Test. Note that you may have to run the "db-load" target before you run your tests every so often. I did have the following method in the Base*TestCase class for each layer, but this caused DBUnit to reload the database before every test in a Test class. Removing it reduces the execution time of "test-all" by more than 30 seconds.
At line 55 changed 2 lines.
!!Tips for Debugging and UI Editing [#7]
For debugging, I use the [Tomcat Plugin|http://www.sysdeo.com/eclipse/tomcatPlugin.html] in Eclipse and set breakpoints. For little changes, I use "ant deploy-web" which only takes a couple of seconds. For truly minor tweaks, it's sometimes easier to edit the file in Tomcat's webapps folder. For major design changes, I usually run the app, view source on a page and save it to a "sandbox" folder in the same directory as my project. Then I do a find/replace and change all "/appfuse/" references to "../web/". This allows me to change CSS and JS files and just refresh the file in the sandbox.
[{Java2HtmlPlugin
At line 68 added 10 lines.
protected void setUp() throws Exception {
DataSource ds = (DataSource) ctx.getBean("dataSource");
IDatabaseConnection conn = new DatabaseConnection(ds.getConnection());
IDataSet dataSet =
new XmlDataSet(new FileInputStream("metadata/sql/sample-data.xml"));
// clear table and insert only sample data
DatabaseOperation.CLEAN_INSERT.execute(conn, dataSet);
conn.close();
}
}]
At line 79 added 8 lines.
If the instructions above don't work for running JUnit tests in Eclipse, I suggest just using the command line - i.e. __ant test-dao -Dtestcase=UserDAO__. Running tests from the command line ''always'' works. ;-)
!!Tips for Debugging and UI Editing [#6]
For debugging, I use the [Tomcat Plugin|http://www.sysdeo.com/eclipse/tomcatplugin] in Eclipse and set breakpoints. To make the breakpoints work you will need to indicate your source-path using the Eclipse menu {{Window->Preferences}}, select {{Tomcat}}, then {{Source Path}}.
For little changes, I use "ant deploy-web" which only takes a couple of seconds. For truly minor tweaks, it's sometimes easier to edit the file in Tomcat's webapps folder. For major design changes, I usually run the app, view source on a page and save it to a "sandbox" folder in the same directory as my project. Then I do a find/replace and change all "/appfuse/" references to "../web/". This allows me to change CSS and JS files and just refresh the file in the sandbox.

Back to AppFuseEclipse, or to the Page History.