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 Training: Week 1

I was invited to attend Basebean's Struts Training today. Vic Cekvenich was nice enough to give me a password to attend, and I agreed that I would blog about it. I also agreed to help out on the MVC Programmers mailing list. I don't know that I'll do the labs, but I am interested in doing them - especially since the examples run on Resin 3.0. So I'm sitting in right now and they're doing some introductions. More to come soon. It's about a 1 and 1/2 hour class this morning - should be fun.

The first 20 minutes have been mostly about open source and it's benefits. I'm thinking - most of the students already know this don't they? Maybe not. I guess my perspective is skewed since I've been involved in open source for so long. Before I started using it, I guess I kinda scoffed at it - so I suppose the intro is good.

The second 20 minutes has been about "why projects fail" and the importantance of requirements. I can definitely understand this - as I've been on a couple projects with a bad requirements-gathering process. So far, this class has been a little disappointing as I haven't learned anything yet. The students seem very interested in the first two topics though - so I guess it's satisfying them. I'm sure I'd be more satisfied if I'd already done the labs (the students have).

Now onto Project Management and CMM. Didja know you can get certified as a Project Manager from PMI.org. IMO, a Project Manager can single handedly make or break a project. I agree with Vic that "the best person to have certified on a project" is the PM. The PM on my current project rocks, and it's made the project soooo much easier. You can track your project's ROI at softwarereality.com.

Don't these student's have mute on their phones? I've heard kids crying and dogs barking so far ;-) No one's heard me sneeze yet - and I've done it 3 times!

Vic recommends the following:

  • When starting a project, create the entire application as an HTML mockup. I agree with this - it's awesome for getting requirements solidified.
  • Mockup the outputs - i.e. Reports in Excel. For reports, he recommends using iReport. After a quick review - it looks like a report designer that creates an XML file that can be fed to Jasper Reports.

NetLedger.com is a recommended UI for complicated forms. Rumored to have a free login.

Tip: When you have bad requirements, surf the web. Programming on your project will just frustrate you. My advice: contribute to an open source project - then you'll keep your skills up to par. Or, read blogs - you'll learn something there too.

Now we're learning how to setup an IDE (Eclipse) and deploy/test and example app. Looks like the sample app (webPIM) uses JSTL's Fmt tag. Cool, I've never used it, I should probably do the labs. Teaching students how to use an IDE for Struts Development is definitely the easiest way to go, but using Ant is the real-world way - right?

The next lab covers configuring Tiles and developing a sample layout. I noticed it was a big confusing for the students that the tiles definitions file is named layout.xml and the base Tiles template is named layout.jsp. I usually name my tiles definition file tiles-config.xml.

Posted in Java at Mar 01 2003, 09:49:51 AM MST Add a Comment

Ant Rocks (but you already knew that)

I have a few different side projects I'm working on right now. The first two, struts-resume and security-example are for the Wrox chapters and the third, AppFuse is the kindling I'm using to build these projects. Basically, I'm using AppFuse as a starting point for developing webapps. I think I've got most of what I want done for a baseline, so I'll be removing some struts-resume specific code from appfuse and calling it 1.0. For security-example, I'll be removing even more code.

The slick thing, and the reason for this post, is that I've been doing all my development on one project - appfuse. When I want to update struts-resume or security-example, I simply execute an ant command, and it updates whatever files have changed since I last updated. Ant figures out automagically which files have changed. I love it. I did a few updates and I'll be uploading the struts-resume 0.6 release tonight. Here's what I did to update the app from appfuse.

$ant new -Dapp.name=struts-resume -Ddb.name=resume
Buildfile: build.xml

clean:
     [echo] Cleaning build and distribution directories
   [delete] Deleting directory D:\source\appfuse\build
   [delete] Deleting directory D:\source\appfuse\dist

new:
     [echo] Creating new application named 'struts-resume'...
     [copy] Copying 17 files to D:\source\struts-resume
     [copy] Copied 1 empty directory to D:\source\struts-resume
     [copy] Copying 1 file to D:\source\struts-resume

BUILD SUCCESSFUL
Total time: 27 seconds

Now all I have to do is commit it to CVS (BTW, you can get struts-resume from SourceForge CVS) and execute and dist. I could FTP to SF using Ant too I suppose (I have Erik's book sitting right here), but I'll just hope someone sends this task (or page number) to me. ;-)

Posted in Java at Feb 28 2003, 12:25:30 AM MST 1 Comment

Taglibs Standard 1.0.3 Released

I've just noticed that a new version (1.0.3) of the JSTL reference implementation has been released containing some minor bug fixes. [Simon Brown]

Hmmm, no release notes eh? Makes you wonder if it's worth the upgrade/headache. I'll be in for it for quite some time with my struts-resume project. I'm using 17 different OSS packages - it'll be a maintenance nightmare to keep up. That is, until I break down and do some Maven integration.

Posted in Java at Feb 27 2003, 11:35:11 PM MST 2 Comments

XDoclet now supports Hibernate 2.0 (almost)

I finished patching XDoclet to allow for Hibernate 2.0 support. I say almost in this post's title because someone still has to commit it. Seems to work pretty good on struts-resume. I can't get one of my unit tests (UserManagerTest) to run, so I won't be releasing tonight (though I was hoping to). Maybe tomorrow. Here's a rough draft of features and plans in the coming 0.6:

Features in 0.6
===============
- Upgraded to Hibernate 2.0 (http://tinyurl.com/6b00) and 
  Struts 1.1RC1 (http://tinyurl.com/6cp9).
- Fixed Validation issues when attempting cancel validation and using
  LookupDispatchAction (document in Struts 1.1RC1 link above).
- Moved opening Hibernate sessions from being at a method level to being passed
  in to each method on the business/persistence tier.  Sessions are now obtained
  via the ActionFilter.getSession() method.
- Added SMTPAppender to log4.properties to e-mail errors that occur in log 
  files.
- Added "Remember Me" feature - for details see http://tinyurl.com/6du0.
- Added "Current User" count as a demonstration of a Tiles Controller.

// TODO for 0.7 
- Add Skills, SkillGroups, Education, Experience to the mix.  Make them 
  all editable when editing a resume using the Struts Nested Tag Library.
- Figure out a way to display resumes to anonymous users.  Do I create XML 
  versions of a resume in "resources/${username}" or use a servlet that maps
  to something like /struts-resume/view/${username}.  I like the servlet 
  idea better, then it's dynamic.  However, how often does a resume really
  change.
- Complete tests for all Action classes using StrutsTestCase.
- When Tomcat 5 become stable, or I figure out how to install an app on Resin 3,
  figure out a way (using Ant) to create JSP 2.0-compliant distribution.
  
// TODO for 0.8
- Add Transformers and XSL for transforming an XHTML document to XML or Text.  
  PDF will be covered in a later release.
- Allow a way for users to register (similar to Roller).
- Create User Administration interface with sortable/pageable list of users.
- Complete tests for all JSPs using Canoo WebTest.

Posted in Java at Feb 24 2003, 10:07:04 PM MST

Hibernate Upgade: 1.2.3 to 2.0 (My Story)

I'm upgrading struts-resume to Hibernate 2.0 tonight. I thought I'd blog my adventure and what I needed to change.

Step 1: Patch XDoclet to allow specifying the DTD in the generated .hbm.xml files.

Step 2: Download Hibernate 2.0 beta 2. It's at the bottom of the preceding link.

Step 3: Extract to struts-resume/lib and change lib.properties to version 2.0.

Step 4: Edit build.xml file to pick up the new DTD. I changed <hibernate/> to be <hibernate validatexml="true" version="2.0"/>.

Step 5: Using HomeSite, I did s/cirrus.hibernate/net.sf.hibernate/g. 14 matches. The project currently has 3 DAO's and a ServiceLocator to get Hibernate Sessions.

Step 6: ant clean deploy Not too bad, only one compile error.
D:\source\appfuse\src\ejb\org\appfuse\persistence\ServiceLocator.java:12: cannot resolve symbol
symbol : class Datastore
location: package hibernate
import net.sf.hibernate.Datastore;


Step 7: Open up Eclipse, refresh the project and right click on the project name, click Properties >> Java Build Path. Change path for hibernate.jar to struts-resume/lib/hibernate-2.0/hibernate.jar. Remove the previous path.

Step 8: Go searching for what the heck happened to Datastore. Hibernate CVS is first choice. Pause to post (per chance someone reads and sends solution).

Step 9: Step 4 from the Hibernate 2 Porting Guidelines. Replacing attribute names, DTDs and changed throws SQLException to JDBCException in ServiceLocator class.

Step 10: Repeat Step 5 for all Unit tests (they live in "test," rather than "src"). End up repeating for entire project, makes about 1800 replacements - hibernate-1.2.3/src was in search path. Remove lib/hibernate-1.2.3.

Step 11: Revisit Step 8 and try to use new Configuration API. Tried this...
Datastore datastore = Hibernate.createDatastore() - changed to Configuration config = new Configuration();

Not working yet... But Gavin has responded to the mailing list and Chiara is listening. Good to have the support ;-)

Step 12: Found a problem with XDoclet, modifying source. Changing "role" attribute to "name" for the following types (in order replaced by HomeSite): subcollection, collection, set, bag, list, map, array, primitive-array. Rebuilt hibernate module. Changed attribute "readonly" to "inverse" and tried again. Changes to set and bag only.

Step 13: I'm using the Configure.configure() method to initialize from hibernate.cfg.xml (I had to rename the package for my dialect from cirrus.hibernate.sql.MySQLDialect to net.sf.hibernate.dialect.MySQLDialect). I doubt it'll work though since this expects a JNDI DataSource.

Step 14: Nope, that didn't work. I found out I needed to remove the "length" attribute from any <key> elements in <bag>'s. Back to trying to use config.addClass().

Step 15: Internet connection goes down, reboot router. Change dialect package name in database.properties. This file is renamed to hibernate.properties and used for running JUnit tests. Now time to have fun with JUnit and get UserDAOTest to run.

I'm getting a connection to the database now thanks to Gavin's advice:
sf = new Configuration()
     .addClass(Foo.class)
     .addClass(Bar.class)
     .buildSessionFactory();


Step 16: Changed xdoclet tags "inverse" attribute to be "false" where previously readonly="true", now inverse="false". Now I'm getting the following error:

[junit] java.sql.BatchUpdateException: Invalid argument value: Duplicate entry '0' for key 1
[junit] at com.mysql.jdbc.jdbc2.PreparedStatement.executeBatch(Unknown Source)


Whenever I try to run the addResume test for a user. The mapping looks fine, I'll try dropping and re-creating the database. Found I needed to change the package names in build.xml. Note to upgraders: don't filter by file extension when replacing the package name.

Discovered that the SchemaExport class had moved from net.sf.hibernate.tools to net.sf.hibernate.tool.hbm2ddl.

Step 17: The UserDAOTest runs successfully. Now for the web...

Couldn't get "ant test-canoo" (Canoo WebTest) to run until I copied xerces.jar back into lib/hibernate-2.0/lib. Changed my log4j.properties to use new package name for logging.

After looking at some 2.0 documentation, I discovered a new DTD for hibernate-configuration. Unfortunately, it's not there. So I put it on this site as a workaround. Got rid of startup errors. One change in the DTDs is that all <property> declarations must be within a <session-factory> element.

Now I can't get Hibernate to connect to JNDI. Back to the doco...

(5 minutes later) Yep, right in the doco. I changed StartupServlet.java to have the following:
SessionFactory sf =
  new Configuration().configure().buildSessionFactory();


Now, when I login I'm getting:

java.lang.UnsupportedOperationException
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:125)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:329)


Since my Unit tests on the business level run, I'm guessing it's something wrong with this line in hibernate.cfg.xml:
  <property name="connection.datasource">java:comp/env/jdbc/resume</property>

Get a good nights sleep; zonked out at 3, up at 8:30 to continue...

Step 18: Find out (from Gavin) that there's probably a hibernate.properties file in my classpath that is causing the problem. I find this fine inside hibernate.jar. Doh! There's an error in packaging. ;-) I remembering seeing this sometime last week on the mailing list. I decide to upgrade to Hibernate 2.0 beta 3, which was released while I was sleeping. The file hibernate.properties is removed from hibernate2.jar in this release. I did have to update lib/lib.properties to handle the change of jar-name. Compiling, testing...

Dropped and re-created the database b/c I was getting duplicate key errors. Ran UserDAOTest - BUILD SUCCESSFUL - run it again - BUILD FAILED.

Further updates to hibernate-properties.xdt to replace paramName="role" to paramName="name", also replaced paramName="readonly" with paramName="inverse". Sent an e-mail to xdoclet-devel inquiring about best way to make hibernate-properties.xdt both 2.0 and 1.1-compatible.

This change in XDoclet makes UserDAOTest pass - so it looks like the upgrade is a success. Now I just have to figure out a way to convince the XDoclet team to add support for Hibernate 2.0. This might take awhile, it has for POJO -> StrutsForms support (still pending).

Posted in Java at Feb 23 2003, 11:03:02 PM MST 6 Comments

Use Maven? Experience says no...

I've been wanting to upgrade struts-resume to use Maven, but after reading Patrick's post, I might just change my mind.

And after 2 years of using Ant, Maven (which uses Jelly and Werkz as the underlying engines) behaves differently enough from Ant to utterly frustrate me. So I'm back heading back to the drawing board for new ideas.

Of course, my hope is to integrate Maven without losing Ant and let them both live beside each other intimately. Someday it will be done...

Posted in Java at Feb 23 2003, 04:30:52 PM MST 1 Comment

JSP 1.2 <-> JSP 2.0

Here's something that I need: A way to convert JSP 1.2 pages to JSP 2.0 pages. Basically, this only really involves changing all the <c:out value="${...}" /> tags to be simply ${...}. I have a couple motivations for this. The first is that Wrox wants struts-resume and security-example to be written using JSP 2.0 (it is a JSP 2.0 book after all). However, I'm afraid that most developers won't be able to use 2.0 for quite some time, considering that the J2EE 1.4 (with JSP 2.0) won't be released until this summer. So I'd like a way to create a JSP 1.2 version and a JSP 2.0 version of my these applications from the same source code. What would be best - to write the source in JSP 1.2 and then parse it for <c:out /> tags and strip them accordingly? I'd rather write the source in JSP 2.0 and then add in the <c:out /> tags using Ant, since it'd be much simpler. Then again, I've already written a fair amount using JSTL with 1.2. Comments and suggestions are encouraged!

Posted in Java at Feb 19 2003, 04:45:02 PM MST 2 Comments

Java.blogs and Roller in Java Developer's Journal

I received the February issue of Java Developer's Journal today. I thought it pretty cool that java.blogs, Roller and MiniBlog were all mentioned. I barely skimmed the thing, so it's possible that there are more nuggets like this hidden in its pages. Maybe I'll find out tomorrow - Abbie wants me to read her a story tonight.

I received the reviews/comments back from Wrox today on my Security and Struts chapter. I briefly read the e-mails and gasped at the deadline for editing/returning (next Monday). Overall, the e-mails were encouraging and didn't seem to indicate a lot of change, just more code samples and a more consistent flow. Knowing my luck, there's all kinds of work hidden in the marked-up Word docs. Getting these chapters edited and returned could take a while since it gives me an excuse to dive back into struts-resume and add some more features. Maybe that's why they give the short deadline.

One interesting point that was mentioned is that the Struts chapter was so packed full of tools (i.e. XDoclet, Struts, Validator, Ant, Hibernate, Tiles) that they're thinking of renaming it to be something like "Leveraging Struts, Tiles, and other Tools." Sounds cool to me. In my current project, it seems that Struts only plays a small role in the whole webapp, but after teaching it to a co-worker over the last week - I guess it plays a larger role than I thought. The combination of all these tools and learning them can be a bit overwhelming - I guess I had an advantage in learning since I wrote about them and also did a sample app. I tell you what - "doing it" is certainly the best way to learn. Now hopefully I can come up with a better way to explain how to do it. The book is (to my knowledge) still scheduled to be released in March.

Posted in Java at Feb 10 2003, 08:56:31 PM MST 4 Comments

Deploying to Tomcat using Ant

If you're using Tomcat 4.1.x, did you know you can deploy using an Ant task that ships with Tomcat. You'll need to add $CATALINA_HOME/server/lib/catalina-ant.jar to your classpath, but then you can configure your ant task as follows:

<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>

<deploy url="${manager.url}"
         username="${manager.username}"
         password="${manager.password}"
         path="/${name}"
         war="file:/${dist.dir}/${name}.war" />

I haven't tried it, but it looks cool. Right now I use a simple copy task that works pretty well for me, so no need to change at this point.

<target name="deploy" depends="package-web" if="tomcat.home"
    description="unwar into the servlet container's deployment directory">
          
    <unwar src="${webapp.dist}/${webapp.war}" 
        dest="${tomcat.home}/webapps/${webapp.name}"/>
    
</target>

If you know of any advantages to using Tomcat's deploy task, or you'd like to share your experience using it - please post a comment.

Posted in Java at Feb 07 2003, 06:58:04 AM MST 12 Comments

[SOLVED] Connection Timeout using Oracle with Tomcat

I finally solved the problem I was having where the DBCP Connection Pool in Tomcat kept getting closed. At first, I thought it was happening every 24 hours. After we configured connection logging in Oracle, we discovered it was happening every 2 hours. After posting numerous (likely annoying) messages to tomcat-user and struts-user (with no resolution), I looked up my local Oracle user-group mailing list and fired off a message.

The first (and only) response solved my problem. It said I should check and see if there is a connection timeout on the firewall. Sure 'nuff, 90 minutes. So I wrote a DBPingServlet, coupled with an Ant task to make an HTTP Request to get the servlet, and scheduled it as a cron job. Whalla - the problem is fixed! Thank God - it was annoying to restart Tomcat every 2 hours! Of course, if folks where actually using our application - this would've never been an issue... ;-)

Posted in Java at Jan 30 2003, 03:17:35 PM MST 1 Comment