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 be using DBUnit?

Here's a question for you: Should I be using DBUnit in AppFuse and struts-resume? I've heard of it before, but have never used it. It sounds good:

The Dbunit database testing framework is a JUnit extension which sets up your database in a known state before executing your tests. This framework uses xml datasets (collection of data tables) and performs database operations before and after each test. The Dbunit framework supports both the clean insert and the refresh strategies.

Actually, know that I think of it, of course I should be! Currently, I use an Ant Sql task to create my database, and then Hibernate's SchemaExport class to create the tables. I have no way to automagically enter data into the database. I suppose I could use another sql task in my build file, but it sounds like this job is more suited for DBUnit. I don't want to give up Hibernate's table generation as it's smart and adds new columns when I add new columns to my VO. Hopefully these two can work together nicely.

I also found this Best Practices guide on using Hibernate. The first line about using fine-grained objects has motivated me to refactor my User class.

Write fine-grained classes and map them using <component> or <component-element>. Use an Address class to encapsulate street, suburb, state, postcode. This encourages code reuse and simplifies refactoring.

Posted in Java at Dec 14 2002, 01:37:09 AM MST Add a Comment

New Job, Struts, Testing Frameworks and Maven

I found out this afternoon that they want me for the job I interviewed for yesterday. I'm expecting to start on Wednesday. It's a small team of 3 folks and should be a lot of fun. I'm really looking forward to getting back into an office environment where I can converse with co-workers and such. After blogging for the last few months, I feel like the java.blogs guys are my co-workers, but it's still fun to talk and interact with folks. I never used to like it - I'd bring my lunch to work everyday, and hunker down like a code monkey the whole time - just trying to get my 8 hours in and get outa there. I'd get annoyed when people would stop to talk about their weekend or other random stuff. Now I'm going to be that guy - I'd better watch for the telltale signs of get the hell out of my cube! I wonder if we'll even have cubes? The floor where my interview was had just cleared out a bunch of folks - it was empty when I went in there. When I say cleared out, you know what I mean. Needless to say, there is plenty of space and plenty of computers available -- it'll be interesting to see what I get.

My last project had horrible machines - NT4 Gateways with 4MB video cards and about 700 Mhz. And this was last year!! I had just bought a brand new Dell 8100 P4 1.5 Ghz 2 weeks before I started the gig - so you can imagine my disappointment. And I was running XP at the time, albeit a beta version. But still, I felt like I was taking a huge step back in time. So I brought in my own Windows 2000 CD on my 8th day on the job. It all looked to be going pretty smooth (and the install was about to finish around 7 a.m. - I got there at 5) when everyone started rolling in. The video drivers weren't compatible and I was forced to humbly call tech support and tell that how I had violated all the rules. This place at least has Windows 2000, and I have my Powerbook, so all should be good. I just hope I can get a dual monitor setup - there's nothing quite so enjoyable.

This evening I did some minimal development on AppFuse. I spent most of the day writing the Struts Chapter. I'm on page 12 and expect to do 10-20 more pages. It was fun writing because I described tools that make developing Struts apps easier: Ant, XDoclet, JUnit, StrutsTestCase, and Cactus among others. I dug in a little to the Testing frameworks and played with them, but nothing too serious. I can waste many hours coding and I need to finish writing, then code later. I used 2 very cool tools today. The first is Canoo's WebTest. It basically is a framework built on top of HttpUnit that allows you to write all your tests as Ant tasks. It's fricken sweet as you don't have to really write any code, and it just worked for me. Check out this file (XML) to see how easy it is.

The 2nd tool was written by Erik Hatcher to generate JSPs and a resource bundle based on a Struts ActionForm. I hadn't tried it out until tonight and it just worked - my favorite feature in any software. The one area I think I might run into issues (in generating all this code), is when I have ArrayLists of beans on a form. I think Hibernate will allow this using Sets, Lists and other types of Collections, but I'm doubting that XDoclet's strutsform task will support it and I don't think Erik's too; generates nested tag libraries or anything like that. This is unfortunate because I'll probably get a wild hair up my you-know-what and want to create this functionality. And there goes my deadline, right out the window. Need.... to ... stay ... focused..!

Lastly, I made an attempt to mavenize AppFuse. It was pretty easy at first, as you're only required to alter this XML file to fit your project's needs. I realized I didn't have much as far as a CVS repository, mailing lists, etc., but I also realized that these would be almost essential to any project. And they'd certainly make things a lot simpler - even on a small team. When I got to the dependency section (which is what I really need), I sorta gave up. Here's my dependencies and their presence at the Maven Repository:

So while Maven looks great, it doesn't offer all the third-party jars I need. Is it possible to partially integrate? Also, I found the documentation to be a bit lacking on how exactly to configure each dependency. Is there a standard naming convention or versioning to rely on? It'd be great to have a list and possible versions - or even XML fragments you can copy/past. Can we, as developers, contribute nightly builds to the repository? I'd love to use both AppFuse and Maven at my new project, but I hate waiting on things to happen. If I can do anything to make the above modules/versions present in Maven, let me know.

Posted in Java at Dec 13 2002, 06:23:07 PM MST 1 Comment

Jenerator

I heard about Jenerator on the mailing list this morning. Sounds cool.

The Jenerator Version 0.9 is a code generator (Licensed under the Academic Free License version 1.1) and hosted on SourceForge, which takes meta information from different mediums, applies XSL templates and generates code. Unlike other code generators, which use JavaDoc custom tags to define and describe what is to be generated, Jenerator uses XML based Descriptor files.

It's got a heck of a list of features too: supports regeneration, EJBs, VOs, Unit Tests for JUnit and Cactus, Ant's build file, JDO source descriptor, and Servlets. While all this sounds good, I probably won't even download it - I'm just not interested as I really like how XDoclet works right now. I might change my mind in a few weeks, but I've learned too much to give it up now.

Posted in Java at Dec 13 2002, 02:47:53 AM MST Add a Comment

Eclipse Plugins and Hibernate

I found a new site with a list of Eclipse plugins tonight. I was hoping that the Ant View plugin could solve my Ant problems in Eclipse, but I can't seem to figure out what it does. I gave it the ol' 30 seconds of investigation - maybe I should read the documentation. The problem I'm having now is (after swapping Ant 1.4 jars for 1.5.1) is:

Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.

Hmmm, works fine from Cygwin, and Eclipse (2.0.2) has tools.jar and rt.jar in the classpath. Must be time to download a nightly build.

There was a lot of talk today in the java.blogs community about Hibernate. I'm happy to see this as it feels like I just bought a new car and everyone is saying it's the best car on the road. I decided to use Hibernate based on Dave's implementation in Ag. It looked easy enough, so I figured - why not?! It turns out, at the same time, that the XDoclet folks were in the midst of creating a new hibernate module in CVS. In fact, I got the hibernate module from Joel Rosi-Schwartz (I'm assuming a hibernate developer) before it was even in the XDoclet source tree.

I got to be a guinea pig in making hibernate tags work with XDoclet. I have to say that with Dave's working example, I was able to markup a POJO with hibernate/xdoclet tags and generate my persistence layer in a matter of minutes. It just worked. Kinda like Tomcat IMHO. That's how software should be. Check out my security-example if you're interested in using Hibernate with XDoclet. The readme in the source will explain how to run initial generation and tests. Currently, it generates a Struts Validator Form and VO from an Entity bean (located at src/ejb/org/apache/template/User.java). Why? Because Struts Forms can only be generated from Entity Beans. This needs to change IMO. But at the same time, the EJB architecture is already in place, I just need to execute the ejb-related tasks, and I'm in business.

In other news, a couple of Struts related goodies:

  • ONJava.com has an introduction to the Validator Framework by Chuck Cavanass, an Introduction to Eclipse and Creating Reports with FOP. I used FOP on a project last year around this time and it's super slick. It's basically using XSL to generate PDF and RTF from an XML file. I highly recommend using something like RTF2FO to generate an XSL Template from a Word document.
  • Struts Kick Start is now shipping from Amazon. I'd buy all the Struts books just to say you have them. I've got three ;) Haven't read any. Damn, I wish I had the time! Reading Erik Hatcher's Java Development with Ant was one of the smartest things I did this year. Actually, the smartest thing I did was get my wife pregnant yeah baby
  • I downloaded TogetherSoft's Control Center to do some UML Modeling for the Struts Chapter, and found that they use Struts on their site. Nice...

Posted in Java at Dec 12 2002, 05:37:04 PM MST 22 Comments

XDoclet and EJBs

I saw the following on the xdoclet-user mailing list today:

Chapters from Manning's "EJB Cookbook", by Ben Sullins and Mark Whipple will be made available on TheServerSide for public review. A chapter on "Code generation" is now available for download. "Code generation" presents the most common uses of XDoclet, an open source tool, tightly integrated with Ant, that lets you generate source code or other files.

Also, I just received the following e-mail from a fellow Denverite, Mike Clark:

Subject: Nice Blog

Hi Matt!

I've been enjoying reading your blog for a while and meaning to introduce myself since we both live in Denver. I'm speaking at the DJUG in April, so perhaps we can meet each other there.

By the way, my weblog is at: http://www.clarkware.com/cgi/blosxom.

Nice - gotta like e-mails like that!! Apparently, Mike is the Author of BitterEJB and also has some chapters for review at TSS:

If you're into JMS and message-driven beans, my "Bitter Messages" chapter is up for review on TheServerSide. As always, any feedback you might have is greatly appreciated!

Posted in Java at Dec 12 2002, 08:45:19 AM MST Add a Comment

Code Readability

There's a debate taking place at FreeRoller about code readability. Isn't this a non-issue with sweet code formatting tools such as jalopy? I don't think I've cared how my code as looked in months, I just use the formatter. For the record, I prefer one space, not all my variables lined up on one side. Why? If you add a new variable with a long name, you have to adjust the spacing for all your variables - what a pain in the ass. However, Jalopy does offer this type of formatting and will plugin to all your favorite IDEs.

Along these same lines, XDoclet uses a beautify ant task that fixes the code everytime you re-compile. While it's nice, it can be annoying that you have to reload your .java file everytime you compile.

Posted in General at Dec 12 2002, 01:07:25 AM MST 1 Comment

IDEA vs. Eclipse

I've been switching back and forth between IDEA and Eclipse for the past couple nights. I DO like IDEA, but as I only have 3 days left on my evaluation, I'll sadly have to let it go. My favorite feature is it's ability to recognize that you haven't imported a class, and then allows you to hit Alt+Enter to add the import. Also, it grays out imports that aren't being used, both very slick features. As for generating getters and setters, it does a poor job in my opinion. It puts them above your variable declaration and doesn't add any javadoc comments. Eclipse puts them at the bottom of your class and adds javadoc comments - so Eclipse wins here. Also, Eclipse does a much better job of adding and recognizing javadoc comments. IDEA wins on indentation, it always seems to know where you want to be. If I get a full time gig here soon, I might have to buy IDEA. I think it's best when you can use multiple tools to make your development life easier. I say screw these debates on Eclipse vs. IDEA or Struts vs. Webwork - use them all! (I need to examine Webwork as it gets lots of good comments from it's developers.) Of course, it's easier to use both when you have a dual-monitor setup! I highly recommend this... it's awesome!

Later: The other thing that IDEA wins on is that it can actually run my Ant script without puking. Eclipse doesn't let me run it - maybe it's cause it has Ant 1.4.1. Hmmm, wonder if I can upgrade it to 1.5.1. IDEA has better XML editing, and even seems to detect errors in build.xml.

As I'm editing this post with the Later paragraph, I received the following from Cédric (who seems to work for BEA from his e-mail address).

You didn't say if you already knew this about Eclipse, so I thought I would tell you anyway:

- To fix a missing import, just press Ctrl-1 (Quick Fix) on the class with squiggly lines. Ctrl-1 does a lot of incredible things, like it sometimes reads your mind. I much prefer this approach to having specific actions and shortcuts to remember. Another interesting one is Ctrl-Shift-O (Organize Imports), when you have a lot of imports to fix. Eclipse will analyze your whole source and add them all for you (and possibly prompt your when there are ambiguities).

- The latest builds underline the unused imports with yellow squiggly lines.

-- Cédric http://beust.com/weblog

Sweet! Must be time to download a nightly build!

Posted in General at Dec 10 2002, 10:35:41 AM MST 4 Comments

J2EE 1.4 as Open Source!

Erik gave me the link to this article from The Register. This sounds like big news to me.

Marc Fleury, Atlanta-based JBoss' founder, told ComputerWire yesterday the company has finished its implementation of Java 2 Enterprise Edition (J2EE) version 1.4. J2EE 1.4 is due for official publication by the Java Community Process (JCP) in the first quarter of 2003.

Fleury said JBoss would now seek standards certification for its implementation. JBoss stands to become the first open source group to deliver a version of J2EE 1.4 under the revised JCP.

JBoss received the green light last week, after Sun told ComputerWire that it would allow all of the APIs contained in J2EE 1.4 to be open sourced. Fleury had expressed concern that certain critical APIs, including Enterprise Java Beans (EJB) 2.1, would be not be made available to open source organizations.

That reminds me that Marc Fluery will be speaking at the next Denver JUG meeting. That's Wednesday of this week. The Basic Concepts preso is covering Ant. I could probably skip this as these are usually pretty basic, but I'm expecting the place to be packed so I'd better get there early. Now I just have to see if I can get a few friends to buck up and go. I know a fair amount of developers that don't use Ant - how bad would that suck?!

Posted in General at Dec 09 2002, 04:01:59 AM MST Add a Comment

Struts Menu - Improved!

Well after working until 4 in the morning last night and most of the day today - I'm happy to say that I've completed my desired changes on Struts Menu. I've been talking with the inventor, Scott Sayles, and hopefully I can get these changes committed in the next day or so. The biggest improvements I made were adding new Displayers - one for CoolMenus (CoolMenu4) and one for DHTML Lists (ListMenu). I also added support for a roles attribute (comma-delimited) that will hide menus when users are not in that role. Of course, you will have to use container-managed security for that to work, but it's easy - right? I'm thinking we should probably add a denyRoles attribute as well, as its a pain to add 5 roles just to exclude 1.

The problems I ran into with CoolMenus4 seem to be CSS related, and the Dropdown DHTML List is a little funky when you have too many nested items. Please feel free to dig in and fix these -> should be easy using good ol' view-source copying some files locally if you like. I can also post the source if you'd like, but I think you're more interested in just a demo.

Click here for a demo (expires on 12-15-02), or download the source.

The coolest thing about this bad-ass menuing system is that you can choose a new type of menu just by changing your JSP. Of course, a little magic and you can do it based on request variables or something of the sort. Check out the permissions page for an example.

The sweetest improvement I can think of is to now make the menu-config.xml file editable through a browser - and it'll save the results for you. Even sweeter - if you're really nuts - have this UI talk to struts-config and allow you to select forwards for locations! I could dig in and work on this thing for a week - but alas, I have a chapter to write! Too bad I'm only halfway done and it's due tomorrow :-( Oh well, at least the chapter will demonstrate some good code!

Posted in Java at Dec 07 2002, 10:28:21 AM MST 2 Comments

Using JAAS and making it switchable

Erik Hatcher has convinced me that I need to give more coverage to JAAS in my chapter on Security. To quote his comment from yesterday's JAAS post:

I think you are underestimating the value of JAAS a fair bit. Suppose you want to authenticate your users against a database table of users/passwords. Without JAAS this is container-specific (sure it works nice in Tomcat, but would you be able to do FORM authentication in WebSphere easily?). We use JAAS in the big application I'm developing and it gives us the freedom to more easily port our application to other containers. What if your application needed to authenticate users (suppose for a portal, not that far fetched, eh?) where each "portlet" had a different authentication scheme: LDAP, Windows NT, database, etc. JAAS is the way to go.

While I can see Erik's point, I think that if the app servers follow the Servlet spec, implementing form-based authentication on any J2EE-compliant server should be easy. After all, Tomcat is the Reference Implementation. At the same time, the bit about the portles is a whole other can of worms - I can see what he's getting at, and I guess I need to figure out an easy way to demonstrate using JAAS. From what I understand, you do have to call the authenticate() in a servlet or filter. Hopefully, I can use a little Ant/XDoclet magic to create a sample that can switch b/w form-based, container-managed authentication and JAAS. Tell me what you think of this idea:

  • Use Ant and a task that runs if ${enable.jaas} is true
  • This task (i.e. jaas) will add a JAAS policy file to the webapp, maybe in the WEB-INF/classes directory so it's in the classpath
  • The jaas task will do some token replacement in login.jsp to change the form's action from j_security_check to something else. Ideally, I wouldn't have to do this.
  • The webdoclet task with not merge the web-security.xml file into web.xml
  • The ActionFilter, which I currently use to retrieve the user's information, will call the authenticate method and route appropriately if JAAS is enabled.

One thing I really like about form-based authentication (besides the ease of setup and no required programming) is that it allows users to bookmark pages in your app. When they select that bookmark again after logging out, they are prompted for a login and routed to the bookmark upon successful authentication. I hope JAAS can do this too.

Posted in General at Dec 05 2002, 04:22:22 AM MST 5 Comments