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.

Struts Upgrade: 1.1 RC1 to Nightly Build (20030326)

I decided to upgrade from Struts 1.1 RC1 to a nightly build this morning, hoping to get the fix for the Validator bug that requires an Internet connection. I was also hoping to solve an issue I have where Eclipse thinks that ListUtils.sum(list1, list2) is deprecated (not so according to it's JavaDocs - Ant doesn't seem to think it's deprecated either... wierd). However, instead I was greeted with a couple of new deprecation errors that you might want to know about.

  • ConvertUtils.setDefaultLong(long) has been deprecated. Again, not according to its javadocs.
  • Action.MESSAGES_KEY deprecated in favor of Globals.MESSAGES_KEY

The good news is that the Validator bug is indeed fixed and I don't have to set my proxy host/port variables for Tomcat anymore.

Posted in Java at Mar 26 2003, 11:23:24 AM MST 3 Comments

DBUnit and CLEAN_INSERT

A few days ago I was trying to hook DBUnit into my test process so that my database would contain the same data before my JUnit tests are run. I had some issues getting it to work and later found that there was a bug in DBUnit's ant task. Basically, it was not allowing me to disable batch statements. Anyway, it's been fixed in CVS and now my JUnit tests (all run through a common test-module task) depend on a "db-load" task. Pretty cool and awful easy to configure. I'll be updating struts-resume/appfuse in the next few days to contain this slick trick. In the meantime, here's my db-load target. The file sample-data.xml is also built using Ant via DBUnit's "export" task.

<target name="db-load" description="Loads database from exported DBUnit file">
    <property name="operation" value="CLEAN_INSERT"/>
    <property name="file" value="metadata/sql/sample-data.xml"/>
    <dbunit driver="${hibernate.connection.driver_class}"
        supportBatchStatement="false"
        url="${hibernate.connection.url}"
        userid="${hibernate.connection.username}"
        password="${hibernate.connection.password}"
        schema="${hibernate.connection.schema}">
        <operation type="${operation}" src="${file}" format="xml"/>
    </dbunit>
</target>

Posted in Java at Mar 25 2003, 11:13:58 AM MST Add a Comment

Struts Training: Week 3

I just signed in for 3rd week here in Struts Training. I'm coming to you live from Chelan, WA. So on with what Ted has to say.

Ted's talking about persistence in Struts: Transaction Script vs. Domain Model.

Transaction Script - organizes business logic by procedure. Great choice for small applications with simple logic. For example, online auction, public search engine or an address book.

Domain Model - an object model of the domain. Has a rich variety of objects that incorporate both data and behavior. Ted mentions that the Domain Model is better for larger applications. For example, managing inventory for an online auction might require using the domain model.

What Ted is doing is using the Domain Model to separate Struts from his Actions - so that he passes around a DomainRequest, DomainResponse, and gets his form from a factory. To me, this looks like a good way to make your Struts layer a lot more complicated! ;-) At the same time, Ted is getting this information from Martin Fowler's Patterns (in Enterprise Architecture, ISBN 0321127420) book, so maybe I should move to the domain model. Naahh, I think I'll keep using the Transaction Script method - it's probably easier for folks to learn and would definitely be easier for rookies to maintain.

Onto Hibernate and how it works:

- POJO beans, encourages fine-grained
- Utilizes "persistence by descriptor"
- Provides DBA-friendly text queries
- Plays well with others
- Buffet-style implementation

IMO, if you're not using Hibernate, you should know why. If you're starting a new project, it's worth looking at. If you're using it, but not using XDoclet - you should be. XDoclet is the best way to avoid DD Hell (quoted from Erik Hatcher).

I didn't know that Hibernate supported a version - did you? Apparently you can specify that a property is a version and Hibernate will use it as you'd expect. Don't see that I have a need for that, but possibly. Would a struts-resume user ever want to keep old versions of their resume? I like to keep old versions of mine, but I have to admit, I never look at them again.

<version name="version" />

Ted just touched on how Hibernate can generate your database schema for you. This is a very powerful feature IMO - especially with struts-resume. It makes it nice for an example app. For instance, with struts-resume, you can run "ant setup-db" and it'll drop tables and re-create your db schema for you.

A student asks about the bottom-up approach - what if you already have a database. My advice? Try looking at Middlegen, its Hibernate Plugin in designed to create an XDoclet-enabled POJO from a database schema. There's also the Reverse Schema Generator that is included with Hibernate. I've used this one and it works great. I've never used Middlegen, but I should be considering that I tag the generated POJO up with XDoclet tags.

Interesting: Ted just mentioned that Gavin (Hibernate's Lead Developer) is working on a book for Manning. It is on Object Relational persistence and it uses Hibernate for its example apps. Erik Hatcher, at his preso on Wednesday, also mentioned that an XDoclet in Action book will be published soon by Manning. He even showed us the book's cover - so I'm assuming it will be published soon.

Hibernate's Fashionable Friends: XDoclet, Commons Logging, Commons DBCP, DynaBeans and Turbine Caching.

To learn more about this Hibernate, checkout:

· AgileData Website (Scott Ambler)
· Hibernate Homepage
· Struts Application Site (Hibernate example and Struts Resume both use Hibernate with Struts)

Vic still likes RowSets and SQL better. I'm guessing this is because he's a SQL expert. The nice thing about Hibernate is that it's query language (HQL) is very much like SQL and allows you to do complex joins. At least, to my knowledge, I've never done any fancy joins in the HQL, just in the mapping (*.hbm.xml) files.

Quote from Ted: This is the year of JUnit books. Watch for them this summer..

Now Ted is covering StrutsTestCase, a JUnit extension that hooks into Struts and Cactus. IMO, it's an awesome way to test Struts Actions - even easier than testing a servlet with Cactus.

Another book: JUnit in Action (Manning) by Vincent Massol and Ted. To be published this summer. Vincent is the lead developer on Cactus, so I expect this to be a great book. Right now, I wish I had written my first book for Manning rather than Wrox. :-(

The one bad part about today's session is that I had to use a calling card to dial in and at $0.35/minute, I'm up to about $25! I should probably sign off soon and save some cash...

Tapestry - are you using it? A student asks about it and Ted mentions that he views it as a presentation framework like Velocity. I've heard lots of good things about it, but have never used it. Ted admits that he uses Velocity and gave up on using JSPs a while ago.

Good stuff - thanks Ted, I'm signing off (the QA session is still in progress).

Posted in Java at Mar 15 2003, 08:37:28 AM MST 1 Comment

Struts from Scratch

More goodness from the struts-user list this afternoon. In reality, I don't know why I'm posting these as I'm not planning on reading them - maybe in hopes that some of you will find it interesting. Could be that I worked until 3:30 last night and got up again at 7. Red Bull at lunch and I feel like I got a full night's sleep!

Struts from Scratch covers a Struts install from ground zero.

It provides detailed install and configuration steps for a beginning Struts application. It comes with a basic sample application and basic Ant build script (available for download from http://www.strutskickstart.com).

Posted in Java at Mar 11 2003, 12:42:39 PM MST 1 Comment

RE: Debugging JUnit tests in Eclipse - how?

James provided me with the answer I was looking for this morning - use Run >> Debug As >> JUnit Test. Cool - it worked! I had to add a few additional JAR files to my project's classpath to make it run a test succesfully - but I'm stoked that it's working! A comment I left on James's weblog might interest you:

I don't *need* Ant to run JUnit tests, but as strange as this may sound - it's the only way I've ever done it. In fact, I've hardly written or run *any* Java classes with a main() method. ;-)

Crazy, huh? I guess that's what happens when you start out writing JSPs and Servlets vs. command-line or Swing apps.

Posted in Java at Mar 08 2003, 10:47:40 AM MST 1 Comment

Struts Training: Week 2

I'm planning on attending today's Struts training and will be reporting here again. I got up at 6, hoping to do the labs and discovered the first step was downloading the latest Basic Portal setup. Since it's 200 MB, I've been dicking around for the last hour and a half, waiting for it to download. Yikes - I thought struts-resume was bad at 10.5 MB! I guess the difference is that it includes JRockit, Mozilla, OpenOffice, Vim, Ant, Eclipse, JMeter, Jikes, PostgreSQL and Resin.

Today's session seems to be covering databases, SQL and database performance. Vic mentions that 90% of performance is in the data model design. If you can fit your database on a laptop, then performance will probably not be an issue. I agree with this. I did the first lab during the first half-hour of the preso. Pretty simple stuff: creating HTML files and accessing them through a browser. This is probably a good lab to get everyone going and stuff installed. Also proves that Resin is running. Of course, it took me two hours to complete this lab, including the download, so I guess it's not that short!

Commons SQL is a new version of Torque (a manual persistence layer). Vic uses RowSets a lot, has one site with 40,000 concurrent Struts users with sub-second response times. He attributes this to rowsets. He says, "To create high-scalable applications, you need to know SQL and use things like RowSet, Ibatis.com, Commons SQL and Scaffolding." I tend to disagree - I think that EJBs (and possibly Hibernate) are your best bet for highly scalable application (i.e. 10,000+ hits per second). If your EJBs are slow, it's probably your code or your appserver. Try EJBs on JBoss and I'm betting you will be pleased. Then again, I've never created a highly-scalable application, and Vic has, so I'm not much of an authority. He, he - he mentions that Castor has lost a lot of mindshare; "Great for development, but not very scalable in production." So true - or at least Roller seems to prove this. From the folks he's talked to, Vic says that TopLink has a horrible reputation.

Hmmmm, interesting. Vic puts all the database connections and CRUD in his ValidatorForms. This is not saying that his bean matches his database tables. I don't know that I'd recommend this, but it certainly might simplify things. However, personally, I'm more comfortable with keeping my POJOs and ActionForms pretty dumb (just getters and setters). He has a DAO that handles CRUD and population of the bean. I wonder where you'd put the business rules in this implementation? In the DAO? If it's in the DAO, what if you have to write a new DAO implementation. For instance, if we used this approach on Roller, we'd have to re-write our business rules for Hibernate and Castor. Ugh.

For testing, he puts a test() method on his beans and uses a Servlet or a plain class with a main() method. Personally, I'd recommend using JUnit and JUnitDoclet (and Ant) to generate and run your unit tests. It's much easier than writing a servlet to test - and can easily separate your tests from your real code. See struts-resume for examples. I'll be releasing AppFuse in the next couple of weeks. This (hopefully) will provide a nice starting point for creating web applications. In reality, if no one uses it, I'll probably be better off (less support). It's been working great for me on my current project and has easily saved us a month of startup time. Right now, appfuse == struts-resume.

Vic mentions using a BaseAction that dispatches to the appropriate method in your subclasses. He says that the only difference between this technique and DispatchAction (or LookupDispatchAction) is you can specify a default method. Here's a tip: use the unspecified method. Here's how to make your edit() method the default:

public ActionForward unspecified(ActionMapping mapping, ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
throws Exception 
{
    return edit(mapping, form, request, response);
}

Vic hints that the next iteration of Basic Portal will be written to use the iBATIS Database Layer and MySQL. Interesting, I thought iBATIS was a company, but nope: it's from the author (Clinton Begin) of JPetstore. On most days, I'd recommend Hibernate here, but I've spent the last 3 days wrestling like mad with it, so I won't. Of course, after leaving work last night, I think I might've figured out the problem. My brain is likely to blame more so than Hibernate.

Ted Husted chimed in at the end and mentioned that he is going to touch on Hibernate next week. Cool!

Posted in Java at Mar 08 2003, 08:13:11 AM MST 4 Comments

Debugging JUnit tests in Eclipse - how?

Does anyone know how to run JUnit tests using Ant and debug them in Eclipse? I have the JUnit/Ant part figured out, it's the debugging I'm having issues with. I'm able to run debug (using breakpoints) in Eclipse while running Tomcat, but not while running a simple JUnit test from Ant. Man that would be cool. If I could run Ant (from w/in Eclipse or on the command line) and set breakpoints in Eclipse - I could sure speed up my development time.

Posted in Java at Mar 07 2003, 09:15:09 AM MST 3 Comments

[ANNOUNCE] Ant 1.5.2 Released

It actually happened yesterday, but I've seen little signs of the word being spread, so I'm here to help. Get it from the main distribution site while the mirrors catch up. I don't think it has anything I need at this point. But I'm upgrade happy, so I'll do it tomorrow.

Posted in Java at Mar 04 2003, 07:22:24 PM MST Add a Comment

Ant JMeter Task

By now, you've probably heard of JMeter. It's basically a Swing-based performance testing framework. From the struts-user list today, I found out there's a JMeter Ant Task. Sweet - looks easy to use too. Now if I could just figure out JMeter, or better yet - be tasked with actually implementing it. I've played with it a couple of times, but never long enough to get something I rely on and use.

Anthill, on the other hand, was so easy to install and use that I've set it up at home and I've automated some of my projects' build/deploy processes. I might have to add Roller to the mix. If I were real daring, I could set it up on this server and build/deploy Roller every day or so. Of course, I wouldn't keep this site up to the latest version - I'd setup a 2nd instance of Roller. Any interest in this? Or better yet, do you know anyone that's hosting an Anthill install that we can use?

Posted in Java at Mar 04 2003, 02:07:49 PM MST 1 Comment

Another Example App and Job Hunting in Florida

I released another example app today - security-example 1.0. This is basically the example app for the "Web Application Security" chapter I wrote for Wrox. There's nothing ground-breaking in it, and in fact, it's just a stripped down version of struts-resume. It'll probably only be useful for those folks that buy the book. For those that choose not to, but still want an example, I invite you to download struts-resume. Regardless, here's the release notes for security-example 1.0:

Features in 1.0
===============
Allows user to login using different Tomcat Realms.  Sample realm configurations
are located in metadata/web/tomcat-context.xml.  Wrox's Professional JSP 2.0, 
Chapter 13, describes how to setup a MemoryRealm, a JDBCRealm, a JNDIRealm
and a JAASRealm.  

Retrieves user's information from a MySQL database using a Filter and Container
Manager Authentication.

"Remember Me" Feature using cookies.

Encrypted passwords using native Tomcat feature or programmatically.

Advanced build/deploy process using Ant and XDoclet.

SSL-based login, optional switch back to regular http after logging in.

For more information, and a further developed example application with these
same features, see struts-resume at http://www.raibledesigns.com/downloads.

It feels good to finish up these example apps for the book. I'll keep developing struts-resume, but I'm going to take some time off to enjoy my evenings/weekends and tone down my moonlighting for a week or two.

My latest and greatest passion will be trying to find a job/contract in Florida. I realized this evening that this doesn't necessarily mean that I have to work for a company in Florida - I could telecommute. However, it is tough to convince companies/clients that this is a good thing. In general, I think I get a lot more done telecommuting (I did it for all of 2002) - but I definitely enjoy an office environment more. Being motivated and inspired to do your job, and collaborating with co-workers can be huge for morale. On Friday, a co-worker and I integrated some stuff we'd been working on for weeks, and it felt awesome once we got it working. The best part - we'll still be pumped about it tomorrow when we give a demo.

I did some research today and conducted a search for Java User Groups in Florida. I found that there were two folks interested in starting groups in West Palm Beach (where we want to live) and in Ft. Lauderdale. The only existing user group I found was the South Florida Java Users Group.

Their February Meeting looks OK, but if I lived there, I'd probably pass. It doesn't seem like they're getting nearly the caliber of speakers we're getting in Denver. To me this says a few things: (1) it could be an opportunity to inspire a JUG to get (or help them get) better presentations, (2) it's gonna suck to move to Florida from a vibrant Java Community, or (3) it's gonna be tough to find a gig there. I think I'd better buck up and only focus on #1. Wish me luck - know anyone that's hiring (my resume)? ;-)

Posted in Java at Mar 02 2003, 10:28:25 PM MST 2 Comments