Matt RaibleMatt Raible is a writer with a passion for software. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.
You searched this site for "ant". 338 entries found.

You can also try this same search on Google.

DbUnit Tip: Turn off foreign key constraints when importing into MySQL

One of the issues I've had with using DbUnit is getting tables to load in the proper order from XML. The XML datasets I use to load table data are flat and don't really have any notion of foreign keys and such. Therefore, when you get into a situation where tables have a circular reference, using DbUnit can be a real bitch. I ran into this situation yesterday.

Luckily, I was able to figure out a solution thanks to the help of Mark Matthews. Just add "sessionVariables=FOREIGN_KEY_CHECKS=0" to your JDBC URL. Here's how the "db-load" target in AppFuse looks with this in place:

    <target name="db-load" depends="prepare"
        description="Loads the database with sample data">
        <property name="operation" value="CLEAN_INSERT"/>
        <property name="file" value="metadata/sql/sample-data.xml"/>
        <dbunit driver="${database.driver_class}"
            supportBatchStatement="false" 
            url="${database.url}&amp;sessionVariables=FOREIGN_KEY_CHECKS=0"
            userid="${database.username}" password="${database.password}">
            <operation type="${operation}" src="${file}" format="xml" transaction="true"/>
        </dbunit>

    </target>

Does your preferred database have a similar mechanism for turning off foreign key checks using the connection URL?

Posted in Java at Mar 01 2006, 04:16:48 PM MST 25 Comments

Why I like Tomcat 5.5.12 better than Tomcat 5.5.15

Here's what happens with Tomcat 5.5.15:

alotta:~/dev/appfuse mraible$ export CATALINA_HOME=$TOOLS_HOME/apache-tomcat-5.5.15
alotta:~/dev/appfuse mraible$ ant deploy;tstart
Buildfile: build.xml

...

deploy:
    [unwar] Expanding: /Users/mraible/Work/appfuse/dist/webapps/appfuse.war into
 /opt/dev/tools/apache-tomcat-5.5.15/webapps/appfuse

BUILD SUCCESSFUL
Total time: 3 seconds
Using CATALINA_BASE:   /opt/dev/tools/apache-tomcat-5.5.15
Using CATALINA_HOME:   /opt/dev/tools/apache-tomcat-5.5.15
Using CATALINA_TMPDIR: /opt/dev/tools/apache-tomcat-5.5.15/temp
Using JRE_HOME:       /Library/Java/Home
alotta:~/dev/appfuse mraible$ ant reload
Buildfile: build.xml

reload:
   [reload] FAIL - Encountered exception java.lang.NoClassDefFoundError: 
org/apache/log4j/spi/VectorWriter

BUILD FAILED
/Users/mraible/Work/appfuse/build.xml:1063: FAIL - Encountered exception 
java.lang.NoClassDefFoundError: org/apache/log4j/spi/VectorWriter

Total time: 1 second
alotta:~/dev/appfuse mraible$ 

Here's what happens with Tomcat 5.5.12:

alotta:~/dev/appfuse mraible$ export CATALINA_HOME=$TOOLS_HOME/apache-tomcat-5.5.12
alotta:~/dev/appfuse mraible$ ant deploy;tstart

...

BUILD SUCCESSFUL
Total time: 4 seconds
Using CATALINA_BASE:   /opt/dev/tools/apache-tomcat-5.5.12
Using CATALINA_HOME:   /opt/dev/tools/apache-tomcat-5.5.12
Using CATALINA_TMPDIR: /opt/dev/tools/apache-tomcat-5.5.12/temp
Using JRE_HOME:       /Library/Java/Home
alotta:~/dev/appfuse mraible$ ant reload
Buildfile: build.xml

reload:
   [reload] OK - Reloaded application at context path /appfuse

BUILD SUCCESSFUL
Total time: 3 seconds
alotta:~/dev/appfuse mraible$ 

Looks like I'll be sticking with 5.5.12 for the foreseeable future.

Posted in Java at Mar 01 2006, 12:17:13 PM MST 10 Comments

OpenLaszlo Tutorial and AppFuse with DWR

A few web development nuggets:

I also noticed a recently updated howto on the AppFuse wiki: Spring Rich Client with AppFuse by Radim Burget. The amount of documentation being produced by the AppFuse community is truly awesome. Thanks everyone!

Update: XFire is crazy fast. If you like, you can see for yourself in AppFuse using OpenLaszlo as a client. Hopefully we can include XFire in a coming release, along with Maven 2 integration.

Posted in Java at Feb 25 2006, 03:52:23 PM MST 4 Comments

MacBook Pro: Kicking ass and taking names

I received my MacBook Pro this morning, and I've spent the day setting it up, doing some development and running some performance comparisons. The setup was easy: I just booted my PowerBook into Firewire mode and copied over all the files I needed. Everything works for the most part. I did have some issues with IDEA and Eclipse, but got both working after doing a few try and try-again shenanigans. Eclipse was crashing when I'd browse to set my workspace; typing it in manually fixed the problem. IDEA hung the first time I opened it; killing it and restarting fixed the problem.

As far as performance, this thing fricken' rocks! Safari launches in under a second and you're browsing before the dock icons hits the top of its first bounce. Firefox is a different story (likely b/c it hasn't been compiled for x86) - it takes 10 seconds to launch. The good news is once it's up, there doesn't seem to be any performance issues. Safari is amazing though - the speed does wonders for GMail and it actually feels like a desktop application.

When I mentioned yesterday that I was going to compare the MacBook to my desktop, Rob Williams said it wasn't a fair comparison. I agree - but I really wanted this machine to be the best machine I could possibly buy. With my (very unofficial) performance tests, it appears like it is. It's faster than my dual-core AMD 64 desktop machine that has 3 GB of RAM. Now, I have had the desktop for a couple months, so it's possible I'm suffering from OS Rot, but still - it's impressive it keeps up. Here are the numbers from my Performance Comparisons page:

For the tests below, I used Java version "1.5.0_06" and had the following variables set: JAVA_OPTS=Xms256M -Xmx384M, $ANT_OPTS=-Xmx256m. I used the CVS version of AppFuse (1.9.1-dev).

ComputerOperationTime (mm:ss)
HP Pavilion a1250n with Windows XP Media Center (dual-core 2 GHz AMD64 3800+, 3 GB RAM)appfuse: clean package-web00:15
appfuse: setup test-all01:51
PowerBook G4 with OS X 10.4.5 (1.33 GHz, 1 GB RAM)appfuse: clean package-web00:30
appfuse: setup test-all03:31
MacBook Pro with OS X 10.4.5 (2.16 GHz, 2 GB RAM)appfuse: clean package-web00:12
appfuse: setup test-all01:28

A couple of interesting things to note:

  • When I first got my desktop, it's numbers were 00:14 for "ant clean package-web" and 01:29 for "ant setup test-all". The MacBook Pro? 00:12 and 01:28. The Windows box had 1 GB of RAM when I ran those tests, but no matter how I tweaked the memory settings once I put 3 GB of RAM in, I've never gotten better numbers.
  • My PowerBook has been dog slow for several months now. When looking up the OS X version on it - I noticed it lists the memory as 512 MB. WTF?! I've had 1 GB in it every since I first bought it! What happened? Did half my RAM go bad or did someone steal half of it during a repair? Oh well, at least I now know the reason it was so damn slow. ;-)

Conclusion: The MacBook Pro is one of the best machines you can buy (laptop or desktop) for Java development. As for the battery life? I'm still doing the "calibration", so I'm not quite sure. Nor do I care - I plan on having this thing hooked up to my 20" cinema display that Virtuas was kind enough to get for me. The display combined with a mouse, keyboard and iCurve is a very nice setup.

Update: I pulled out the memory from my PowerBook and put it back in. Upon reboot, it resulted in the correct (1 GB) memory setting. The numbers above appear to be accurate regardless. I ran some tests again and times were actually slower (maybe because I'm on battery power).

Posted in Java at Feb 23 2006, 05:20:14 PM MST 27 Comments

[ANN] Equinox 1.6 Released

For a good story of how Equinox helps, see Wayland Chan's Equinox to the rescue blog post.

This release's major new features are Tapestry 4.0 and WebWork 2.2.1 upgrades. In addition, I changed to use Maven's Standard Directory Layout. It makes IDE and using Maven plugins much easier, so it's a natural progression.

This release does not contain Maven support for running the integration tests with Cargo. This is because Cargo still seems a lot more complicated with Maven than with Ant. Hopefully I'll be able to figure out an easy way to get test-all functionality with Maven and Cargo in the next release.

All of the frameworks used in Equinox, as well as its build/test system is explained in Spring Live. A summary of the changes are below (detailed release notes can be found in JIRA):

  • Added custom exception page for Tapestry, as well as tapestry-flash.
  • Changed birthday date input to use WebWork's DatePicker component.
  • Added support for pre-compiling JSPs when building with Maven (on by default).
  • Added createDatabaseIfNotExist=true to jdbc.properties.mysql to auto-create the database when using MySQL.
  • Changed classes that extend *SpringContextTests to use AUTOWIRE_BY_NAME so more than one instance of an interface is supported.
  • Dependent packages upgraded:
    • Cargo 0.7
    • DisplayTag 1.1
    • Hibernate 3.1.2
    • Scriptaculous 1.5.2
    • Tapestry 4.0
    • WebTest build 1168
    • WebWork 2.2.1

Download. For more information about installing the various options, see the README.txt file.

Demos:

Known Issues: The Tapestry-Flash JAR was built with JDK 1.5 - so you'll need JDK 5 to run the Tapestry version. Howard Lewis Ship said he'd fix this tonight or tomorrow. Also, if you're on Unix, you'll need to run "ant fixcrlf" before you install anything. Finally, downloading dependencies might not work the first time. Running the "ant" or "mvn" command multiple times usually solves the problem.

See the roadmap for what's coming in the next release.

Posted in Java at Feb 21 2006, 04:35:08 PM MST 8 Comments

What do we need to do to make WebWork/Action 2 the best framework for *everything*?

From Ted Husted on the Struts mailing list:

Seriously, hype aside, engineer to engineer, if we can use the new standalone Tiles with WebWork, and use Ajax to store the state of UI controls, what else do we need to do to make WebWork/Action 2 the best framework for *everything*?

My reply:

The tag documentation (and documentation in general) for WebWork is difficult to navigate. Struts' documentation has generally made it easier to find stuff.

I think the hardest part of WebWork/Action 2 is providing the path for migration. If Struts 1.x applications can run in Struts Action 2.x, and users can create new Actions following WW's APIs - that will be truly awesome.

Another that would be cool is smart defaults. For example, having Actions that end with "Action" be available at the "everythingbeforeAction" URL. Spring has something similar coming in 2.0 - and it's mainly just done by extending a certain class.

http://jroller.com/page/raible?anchor=an_example_of_smart_defaults

So if I have UserAction, it's automatically available at /users, /user/edit, /user/save, etc. Default CRUD in a sense. No xwork.xml required by default. But users can override. Default everything w/o requiring annotations, but allow overriding. Or maybe there's different default schemas - a CRUD one, store front, etc.

Ajax stuff that I think WW already has: in-page updates, sortable/pageable lists with something like the displaytag - but with Ajax. There's a lot of these components already available for this stuff, so it might just be a matter of documenting how to integrate them.

Promoting Maven 2 for building might be an easy way of promoting inclusion of 3rd party libraries. Add 3 lines of XML, use this code in your JSP/template, boom - you're good to go. Those that don't like Maven can use the Ant tasks and pom.xml.

Archetypes could be pretty big too - create starter applications that users can use. Even better, provide a means to upgrade the archetypes. Of course, that might be a Maven thing - and editing pom.xml to change versions really isn't that hard.

Above all else - to become the best MVC framework for Java - documentation and easy migration are essential.

Just my $0.02 of course. ;-)

What's your opinion?

Posted in Java at Feb 21 2006, 02:19:17 PM MST 3 Comments

Dependency Injection with SiteMesh

Let me start off by saying I think that both SiteMesh and Tiles are great frameworks. I was a long time user and fan of Tiles, and I think it's appropriate for certain situations. However, I've been a heavy user of SiteMesh since it passed the 10 minute test. While most heavy users of SiteMesh (the Atlassian guys come to mind) say that it can do everything that Tiles can do, these features are largely undocumented. This is my attempt to document a cool feature.

In a site I recently helped develop, we needed a couple of features:

  • A tabbed menu that highlighted the current tab based on which page you were on.
  • A bunch of "panels" on the right sidebar that changed according to the page.

To make this work, we used the meta tag functionality that SiteMesh provides.

Funny side/related note, I just googled for this tag and found this howto, which is similar to this one.

In our pages, we added the meta tags to set the active menu, as well as which panels to show in the sidebar:

<head>
    <title><fmt:message key="authorList.title"/></title>
    <meta name="menu" content="Authors"/>
    <meta name="panels" content="administration,blogs,events"/>
</head>

Then, in our decorator, we interpret these separately. First, we used Struts Menu (with Velocity) for the navigation system:

<c:set var="currentMenu" scope="request">
    <decorator:getProperty property="meta.menu"/>
</c:set>
<c:import url="/WEB-INF/pages/menu.jsp">
    <c:param name="template" value="/template/menu/tabs.html"/>
</c:import>

The menu.jsp page takes "template" as a parameter so we display the same menu links using a different Velocity template (for example, links at the bottom of the page).

<menu:useMenuDisplayer name="Velocity" config="${param.template}" permissions="rolesAdapter">

Then our tabs.html Velocity template uses the "currentMenu" attribute to determine which menu to highlight.

## displayMenu is defined in WEB-INF/classes/globalMacros.vm
#macro( menuItem $menu $level )
  #set ($title = $displayer.getMessage($menu.title))
  #if ($menu.url)
    #if ($menu.name == $currentMenu)
      <span class="current">
    #end
      <a href="$!menu.url" title="$title"><span>$title</span></a>
    #if ($menu.name == $request.getAttribute('currentMenu'))
      </span>
    #end
  #end
#end

#if ($displayer.isAllowed($menu))
    #displayMenu($menu 0)
#end

As far as the panel injection goes, that's processed using the following logic in our decorator:

<c:set var="panels"><decorator:getProperty property="meta.panels"/></c:set>
<!-- No panels set, use default set of panels -->
<c:if test="${empty panels}"><c:set var="panels" value="different,partners"/></c:if>
<c:forEach var="panel" items="${panels}">
    <c:import url="/WEB-INF/pages/panels/${panel}.jsp"/>
</c:forEach>    

Since this site used WebWork, the <ww:action> tag made it easy to give each panel independence. That is, each panel could load on its own, supply its own data, and not worry about the data being prepared beforehand. Here's an example:

<%@ include file="/common/taglibs.jsp"%>

<h2>Author Blogs</h2>

<ww:action name="'authors'" id="authors" namespace="default"/>

<div class="item">
    <ww:iterator value="#authors.authors" status="index">
        <a href="<ww:property value="blog.feedUrl"/>">
            <img src="${ctxPath}/images/icons/xml.gif" alt="XML Feed" 
                style="margin-right: 5px; vertical-align: middle"/></a>
        <a href="<ww:property value="blog.url"/>"><ww:property value="name"/></a>
        <br />
    </ww:iterator>
</div>

Of course, now that you can use Tiles with WebWork, Struts, Spring MVC and JSF - you could use Tiles for the injection and SiteMesh for the decoration.

Now if we could just get someone to write a JSF Decorator for SiteMesh, like Erik Hatcher did for Tapestry.

Posted in Java at Feb 16 2006, 09:57:23 AM MST 6 Comments

EMMA vs. Cobertura for Code Coverage

I'm looking to add code-coverage reporting to AppFuse. The two open source libraries I know of to do this are EMMA (CPL) and Cobertura (ASL). Which one is the better library to use? Both projects seem to be actively developed - and there are AppFuse HowTos for both, so the decision making process is a bit difficult.

Any insights into why one tool (or project) is better than the other is appreciated.

Posted in Java at Feb 03 2006, 05:16:35 PM MST 13 Comments

Improving the Maven Repository

Brett Porter provides a few steps on how you can help improve the Maven repository. My advice? Convert your project to use Maven 2 as an experiment. That's what I did with Equinox 1.5. In the process I found 28 issues with POMs at ibiblio. If you're using Ant, you can use Maven 2's Ant Tasks to download your dependencies w/o going "whole hog" and converting everything to M2.

Yes, this is a somewhat twisted attempt to convince you to endure the same pain I went through. The best and worst part of Maven 2 is its transitive dependencies. If they can all be updated to be accurate by the project owner's - the problem will be solved. But how do you convince project owner's to do that? I wonder how good Ivy's metadata is?

Why is this whole debate important to you? Because Ant 1.7 is (supposedly) going to have a dependency download mechanism. It's likely you'll use it because it is a nice convenience. Steve Loughran is one of Ant's primary developers and he has this to say:

I do find the m2 tasks and repository hard to work with, and am debating a quick investigation of Ivy. Maybe focusing on one thing -library management- has let them do a better job than trying to be all of a next generation build tool.

The "best dependency downloading tool" debate is heating up. I wonder which one will win Ant Developers over? If it's M2, I can see the Apache folks smiling. However, if it's Ivy - at least we'll know it's not a political decision. It's because it simply does a better job. May the best tool win.

NOTE: I've yet to try Ivy, and don't know if I will. Especially now that I've fixed all the POMs I use at ibiblio.

Posted in Java at Jan 05 2006, 08:12:43 PM MST 9 Comments

Use Ant to auto-build your AppFuse project in Eclipse

One of the issues that AppFuse has is it's not that IDE-friendly. When I first started creating AppFuse (December 2002), Eclipse had already been released. However, I only used it as a fancy text editor, and didn't structure AppFuse to be Eclipse-friendly. Most of the unfriendliness is caused by XDoclet, but there's a way to fix that. Rather than using the default "Java Builder" to auto-build your Eclipse project, you can use Ant. Below is a set of instructions that show how to configure Eclipse 3.1 to use Ant as the builder for an AppFuse project.

Step 1: Right-click on your project and go to Properties. Select the Builder menu on the left and click the "New" button.

Builders

Step 2: Select "Ant Build" in the Configuration Type dialog.

Builders

Step 3: In the Properties window, select the appropriate locations for Buildfile and Base Directory (in the Main tab). In the Targets tab, set everything to the default target. Finally, in the Classpath tag set Ant Home to where you have Ant installed.

Builders

Personally, I haven't used this setup to work on an AppFuse project yet, but it seems quite useful. Hat tip to Erik Weibust to showing me how to do this while at The Spring Experience.

Posted in Java at Dec 29 2005, 12:26:20 PM MST 3 Comments