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.

Should I buy a PowerBook or a PC?

I received the following e-mail from Jason Boutwell a couple of days ago (published here with his permission).

I'm in the market for a new development laptop, either a P4 or a G4. I see from some of your older blog posts that you went through the same thing last year. First you went with a P4, then ended up with a PowerBook, so you've done both.

Since we seem to have similar professional interests (jobs where you BYOL, developing J2EE apps with tools like Hibernate, Struts, XDoclet, IDEA, etc.), you seem an ideal person to ask.

It's as simple as this: you can't beat the form-factor of the PowerBook. The fact that it's so small and light really make it a killer laptop. iPhoto, iMovie and iTunes are all killer apps and make digital photography and video so much easer. However, as a development environment - it sucks. It's sooooo much slower that my Windows XP desktop (that only cost $800).

My perspective of the speed difference might not be fair though - desktops (most likely) will always be faster than laptops. However, to run "ant deploy" for AppFuse takes 23 seconds on my 2.6 GHz CPU / 1.5 GB RAM desktop and 36 seconds on the PowerBook (1.33 GHz CPU / 1 GB RAM). It is difficult for me to develop on the Mac after developing on my PC for awhile, it's just so much slower. That being said, I don't think I'd be happy with a PC laptop - they're too ugly and bulky (for the 17" models) and don't offer the slick digital hub integration that the Mac does.

Don't expect the PowerBook to be a desktop replacement. And if you've never used a Mac, prepare to be frustrated. I've been a Windows user for 10+ years and getting used to the way a Mac works is not easy. It's been most frustrating for me because I can navigate around and do stuff on Windows really fast - it's almost like second nature. On the Mac, I have to think about how to do stuff. I think that Mac or Linux users migrating to Windows would feel the same frustration.

Above all else, you need to experience a Mac first hand. Go to your local Apple Store and play around with one. Download your favorite IDE and checkout an open source project from SourceForge. Download and install Ant and try compiling the project. You're gonna love the feel of the Mac, but you might find it's a bit slower than you're used to.

The one problem with not buying a PowerBook is that you'll always long for one. ;-) Would I buy a PowerBook again? Definitely. Would I give up my Windows desktop for a Mac desktop? No. Why should I give up all my years of becoming an efficient Windows user to be a slow-ass frustrated Mac user - it just doesn't make sense.

Posted in Mac OS X at Jan 10 2004, 05:58:17 PM MST 23 Comments

What should I learn next?

I received an e-mail a few minutes ago from an old friend. We used to work together at eDeploy, which has finally gone out of business, 2.5 years after they closed their doors. This was my last full time job and was also my favorite job of all time. I rode my bike to work, got to learn Java, wore shorts all the time, and thoroughly enjoyed our Friday lunches.

His questions were fairly simple:

  • What is the best way to find a Java job/contract in Denver?
  • Since you've had a lot more exposure to what technologies are being used more than others, is there somethings that I should brush up on while I've got the time off (i.e. struts, xslt, EJBs, . . .)?

I wrote a long answer and thought others might be able to benefit from it - so here it is (please add your own advice as you see fit):

What I'd recommend is to subscribe to the following local mailing lists:

RMIUG Jobs: RMIUG Jobs: http://rmiug.org/html/email_lists.html
DJUG Jobs: http://www.denverjug.org/resources/mailinglist.html

They get a fair amount of jobs that come across the wire, and I actually got 2 gigs last year through the RMIUG list. Struts is definitely one of the hottest skills, but I continue to get a lot of calls as a UI/Java Developer. Having the ability to write clean and pretty HTML as well write Java seems to be rare. To complement Struts, I'd focus on JSTL and JSP 2.0. You can't go wrong learning more about Ant and JUnit - I think a lot of people know JUnit, but not many put it on their resume.

You could check out my AppFuse application which uses all of these, as well as Hibernate (another hot one) for the persistence layer.

I started writing AppFuse when I wrote a couple chapters for Pro JSP last year. I use it on all my projects and it really helps accelerate the whole JSP/Struts/JUnit/Tomcat development cycle.

I'd also recommend reading a couple of really great books:

Java Development with Ant: a truly awesome book
Pro JSP: of course ;-)
J2EE Design and Development: I'm reading it right now

EJBs are a thing of the past - you might be able to get a gig doing them, but they're definitely waning. Rod Johnson (author of the 3rd book) wrote the Spring Framework as part of the book, and it's a pretty slick framework for taking the ugly out of J2EE. The project is getting a lot of press, and I hope to use Spring pretty soon to bind all my components together in AppFuse.

Above all else, I recommend starting to read weblogs (a.k.a. blogs), and if you like it, start your own. The best place to start reading them is JavaBlogs, JRoller and Java.net. I'm a committer on the open source project (Roller Weblogger) that runs JRoller. It's some damn slick blogging software. I host my site at KGBInternet for a measly $20/month and I get my own instance of Tomcat to screw up. Reading blogs is definitely the best way to stay on the bleeding edge of Java (and any other industry for that matter).

Posted in Java at Jan 09 2004, 12:38:04 PM MST 1 Comment

Cactus and Form-Based Authentication

Quick Summary: Did you know it's possible to login (with form-based authentication) before running each of your testXX methods in a ServletTestCase or CactusStrutsTestCase? Just add a "begin" method in your Base class, or in each of your Tests, and it will be called automatically, just like setUp() is called.

    public void begin(WebRequest request) {
        request.setRedirectorName("ServletRedirectorSecure");
        request.setAuthentication(new FormAuthentication("tomcat","tomcat"));
    }

Long and Winded: Yesterday, I began adding the "roles" attribute to my Struts action-mappings - to limit access for certain user roles (Yes, XDoclet 1.2 supports this). This worked great in my web UI, until I tried to run my StrutsTestCases. Access was denied because I was not logged in. Rather, I was "faking it" by retrieving a UserForm object in my setUp() method and stuffing it into the session [View Source]. This worked like a charm until I added the roles restriction.

Cactus has a nice feature: if you write a beginXX method, it will be called before your testXX method. In other words, begin = client, test = server. So I added a number of beginEdit, beginSave, etc. method to my Action Tests. Great - everything worked. But it was ugly to add all those beginXX methods. Then, via Vincent Massol's wisdom, I learned of the global begin(WebRequest wr) method. Now I simply have a begin() method in my BaseStrutsTestCase class, and everything works as smooth as pie.

    public void begin(WebRequest request) {
        request.setRedirectorName("ServletRedirectorSecure");
        request.setAuthentication(new FormAuthentication("tomcat","tomcat"));
    }

A couple of issues I discovered:

  • If you have an Action that doesn't have any roles in any of it's mappings, this will fail, so you have to override the begin() method with an empty {} method in your *Test.class. I believe the error message was it couldn't find the SecureServletRedirector.
  • You must define all the roles (you plan to authenticate with) in your Ant build.xml file. [Read More]
  • My <error-code>403<error-code> is not working on AppFuse or the current real-world app I'm working on. [Read More]

All in all, I'm pretty pumped that Cactus makes it this easy to test my app in its true production environment.

Later: I figured out the source of the 403 error-page not rendering. Once again, my Compression Filter does more harm than good. I switched it out for a more recent GZIPFilter and the same thing happens. The good news is that the new filter works on Resin, whereas the old one did not.

Posted in Java at Jan 08 2004, 01:46:32 PM MST Add a Comment

HowTo: Get an input field's value with Canoo's WebTest

I should start this by saying that I love Canoo's WebTest. It allows you to test clicking through your webapp as if you're using a browser. You simply write your tests in an XML file (which is really an Ant build file), and then run it with Ant. Usually, in my webapps, I write simple tests for CRUD on entities - i.e. EditUser (tests pulling up the edit screen), SavePosition (edit and save, verifies next screen's title), SearchUsers (verifies list screen's title).

One of the issues I had this morning was testing a wizard with WebTest. This was because I didn't know how to get the id of the new record after it was added. Now I found a way. Let's say you have a Create a Job wizard. On the first screen, you enter the job, and on the second, you add the required skills, on the third, you view a summary. To get the new id of the job, you can use XPath to get the hidden field named "jobId" - to do with what you may (i.e. click on a link to the third screen). Here's how: {{{ }}} This is especially helpful because I tend to use a lot of onclick handler's (with location.href's) on buttons (so I don't have to submit to the same action). I also turn off JavaScript for my tests - by not including js.jar in WebTest's classpath. I can't say enough about this tool - the ability to test your app, with JavaScript turned off, and verify that everything works... that's just cool. Especially when you're a JavaScript junkie like me.

Posted in Java at Jan 06 2004, 05:25:15 PM MST 5 Comments

Jalopy source code formatter no longer free

I love the Jalopy Source Code Formatter. I hope it continues to be developed on SF (though it hasn't had a release in over a year). My issue? It doesn't work on Eclipse 3.0 Mx on OS X. Why am I worried development will stop? Because the original author has a non-free version (at www.triemax.com).

I can't blame the guy - developing Open Source projects is fun, supporting them is a pain. You get rewards for developing: personal milestones, discovery, knowledge enhancement. For supporting, you get to use your precious non-paid hours to try to disseminate your knowledge. This can also be rewarding, it's just not as immediate, leading to the frustration and pain of support. Good documentation reduces support, but that's a pain too.

We have test-first methodologies, will we ever get to document-first? Write the help files, then write the tests, and then the actual code. I'm willing to bet you'd get even higher quality software going this route.

Posted in Java at Dec 31 2003, 08:49:54 AM MST 4 Comments

[ANNOUNCE] Ant 1.6 Released!

Big news baby - the best Java tool in the world has a new release. I don't know that I'll use any of the new features (such as antlib, macrodef, presetdef, ssh tasks), but I do love to upgrade. Downloading now...

Later: It looks like Canoo's WebTest is not compatible with Ant 1.6. Reverting back to 1.5.4.

C:\Source\appfuse\test\web\web-tests.xml:29: Task must be of type "Step": invoke at 
C:\Source\appfuse\test\web\login.xml:1:  is of type org.apache.tools.ant.UnknownElement

Line 29 is: <canoo name="login">. I've notified the webtest mailing list, hopefully there will be a resolution shortly.

Posted in Java at Dec 18 2003, 08:17:01 PM MST 3 Comments

Eclipse Plugins on OS X and 3.0 M5

I did a bit of tinkering yesterday and today and finally got the Colorer plugin to work on OS X. From the Colorer Forums, you can now see how to build the colorer plugin for OS X and how to get the plugin working with Eclipse M5. I also discovered that the Lomboz plugin now supports M5 too (even on OS X!).

So, you ask, "What happened to using IDEA?" I do use it, but not as much as Eclipse. The main problem I have with IDEA is that I can't have more than one project open at a time. I typically copy code from AppFuse and it's just easier in Eclipse - I can even copy a whole class and it renames the package for me. And now that I've discovered the Ant View in Eclipse, they're pretty much equal to me. Another reason for targeting Eclipse is there's more users. Most of the folks that download AppFuse use Eclipse - so being aligned with the my "users" (all 6 of them) makes things much easier.

Posted in Java at Dec 17 2003, 08:33:07 AM MST 3 Comments

DB2 with Hibernate and Tomcat

At my current project, we're using AppFuse for our baseline and (currently) Tomcat and MySQL for our databases. Soon we'll be migrating to DB2 for our database. I'm assuming everything will work smoothly with Hibernate, but there's probably some Ant things I will need to modify. For instance, with MySQL, I currently create a new database with the following script:

create database if not exists appfuse;
grant all privileges on appfuse.* to test@"%" identified by "test";
grant all privileges on appfuse.* to test@localhost identified by "test";

Is this possible with DB2? It's no biggie if it isn't - at my Comcast gig earlier in the year, we tied AppFuse/Hibernate into Oracle and simply didn't use the db-create nor db-init (creates tables) tasks. I use Hibernate's <schemaexport> task to create the tables - hopefully this will work in DB2. As for Tomcat, has anyone successfully configured DB2 with Tomcat's DBCP? We'll eventually be migrating to Websphere 5, hopefully it's not a big leap from Tomcat 4.1.27.

I haven't done any research on this yet, just wanted to put out some feelers and get any helpful advice before I start banging my head against the wall (hopefully I won't have to).

Posted in Java at Dec 08 2003, 10:01:55 AM MST 6 Comments

[JSPWiki] Sweet Java/HTML/XML syntax coloring

I found a very nice plugin for JSPWiki this morning: the Java to HTML converter.

This tool converts Java source code (files and snipplets) to HTML, RTF, TeX and XHTML with syntax highlighting. It is Open source under the GPL.

I've found that it works for Java, XML and HTML. Here's a couple of examples (I've hooked it into Roller's JSPWiki support):

Java


/**
@return Returns the id.
* @hibernate.id column="id"
*  generator-class="native" unsaved-value="null"
*/

public Long getId() {
    return this.id;
}

HTML


<html>
  <head>
    <title>HTML Test</title>
  </head>
  <body></body>
</html>

XML



<?xml version="1.0"?>

<!DOCENGINE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN" 
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class
        name="org.appfuse.persistence.User"
        table="app_user">

        <id
            name="id"
            column="id"
            type="java.lang.Long"
            unsaved-value="null"
        >
            <generator class="native">
            </generator>
        </id>

    </class>

</hibernate-mapping>

The one thing I don't like is that it centers the code using <center>, adding "center table {width: 100%}" to your stylesheet fixes the issue. I also tried to upgrade Roller's JSPWiki.jar to 2.1.86-alpha (to get XHTML support), but I was getting all kinds of stacktraces from OSCache and it just didn't work. Java2Html also has an Ant Task to convert Java source to HTML. Java2HTML has the same thing, but this new one supports different styles.

NOTE: The above syntax coloring produces invalid XHTML, so this site won't validate for awhile.

Posted in Java at Dec 05 2003, 01:02:08 PM MST 4 Comments

Users and Groups on Linux

Now that I've rebuilt my Red Hat 9 box with Fedora, and installed Out-of-the-Box - I really should get my user and group permissions setup properly. If I ever decide to host CVS, shell access or bug tracking for clients, it'd be nice to know my server is secure. Out-of-the-box installs everything as root (save CVS), so I'm constantly doing "chown -R matt $CATALINA_HOME" or "su" to simply deploy files to Tomcat.

How are these open source servers (i.e. SourceForge) setup? If I wanted to setup a SF-clone, I'm assuming I'd need to setup a "developers" or "clientName" group and then create specific cvs repositories for each client. However, I'm not looking to setup a SourceForge-like server right now - I just want to get my permissions right. I'm thinking of creating a "developers" group, and giving it rw rights to Tomcat, Ant, Anthill, etc. Then I'll make myself a user in this group, rather than having to "su" every time I want to do something. What would you do? How would you setup your "dev" box to be more secure with users and groups?

Posted in Java at Dec 03 2003, 05:45:23 AM MST 1 Comment