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.

How To: Configure Log4j to notify you of errors

A couple of weeks ago, I mentioned that I was interested in using Log4j's SMTPAppender to e-mail me messages when errors occured in my webapp. I discovered how easy it is a couple of days ago. Here's how to configure it.

1. Add mail to the log4j.rootCategory in log4j.properties: log4j.rootCategory=INFO, stdout, mail
2. Add the following configuration settings to log4j.properties:

# Configuration for receiving e-mails when ERROR messages occur.
log4j.appender.mail=org.apache.log4j.net.SMTPAppender
log4j.appender.mail.To=@ERROR-MAILTO@
log4j.appender.mail.From=@ERROR-MAILFROM@
log4j.appender.mail.SMTPHost=@ERROR-MAILHOST@
log4j.appender.mail.Threshold=ERROR
log4j.appender.mail.BufferSize=1
log4j.appender.mail.Subject=CCT Application Error

log4j.appender.mail.layout=org.apache.log4j.PatternLayout
log4j.appender.mail.layout.ConversionPattern=%p [%t] %C{1}.%M(%L) | %m%n

One question I have is that the ConversionPattern is kinda funky - where the line breaks don't seem to be carried into the e-mail (from exception.printStackTrace()). Any suggestions for a better configuration are appreciated. The To, From, and SMTPHost are all replaced with values from Ant during the build process.

Posted in Java at Jan 30 2003, 06:25:43 AM MST 5 Comments

Enhancing the build process with CruiseControl and Maven

Now that we've passed the first milestone on my project, we're getting into "What's Next." I'm going to propose that we use Maven and CruiseControl to create a tighter continuous integration and testing process. I hope to continue to use our current Ant build.xml, just re-arrange some jars and such for Maven. Think it'll work? I'd love to hear any experiences or helpful hints with either of these tools. I have a start on Maven, and I think I'll be fine getting started with it, but I've never used CruiseControl. Luckily, I have Java Development with Ant on my desk to help me out.

Posted in Java at Jan 28 2003, 08:57:54 AM MST 3 Comments

Java Development with Ant Quiz

Sun has a Ant Quiz. Test your Ant knowledge! I missed 2 - #5 and #9. Number 9 asks "XDoclet is?" You'd think I've worked with it enough by now to know what the heck it is - but apparently not. ;-)

Posted in Java at Jan 21 2003, 08:21:26 PM MST Add a Comment

xPetstore v2.2 Released!

I haven't looked at it much or used it at all, but it sounds good.

xPetStore is a WODRA (Write Once, Deploy and Run Anywhere) implementation of Sun PetStore application based on the following opensource tools/framework:
- XDoclet
- Struts
- SiteMesh

If you're writing web applications (and you're using Struts or Webwork) and you're NOT using XDoclet (or one if it's derivatives - i.e. Middlegen), you're wasting your time (IMHO). Of course, I also believe that if you're not using Ant to build your java-based project, you're really wasting your time.

Hmmm, while over at the WebWork site, I stumbled upon this Eclipse + Resin + WebWork + Hibernate tutorial. I don't know if it's such a good idea to call your persistence layer directly from your servlets is it? Shouldn't that be in a Business Delegate - or am I losing focus of KISS and trying to follow too many patterns? Patterns give me more opportunities for Unit Testing. The only way to test this servlet would be something like Cactus, right? As always, to each his own... ;-)

Posted in Java at Jan 19 2003, 10:24:25 PM MST 1 Comment

Conditional Task Execution with Ant

I'm trying to conditionally include my test jar files based on an Ant property. My problem is that the "if" attribute of the <task> element only accounts for the property being present or not. I'd love to be able to specify:

ant -Denable.cactus=false

But Ant seemingly executes my task if a property is present - so even though the value is false, it still executes. Any ideas? Here's my task:

<target name="copy-test-jars" depends="init" if="enable.cactus"
    description="Copy test-related JAR files to WEB-INF/lib">
    <echo>Copying Cactus, StrutsTestCase and JUnit JARs</echo>

    <mkdir dir="${webapp.target}/WEB-INF/lib"/>
    <!-- Copy jars -->
    <copy todir="${webapp.target}/WEB-INF/lib">
        <fileset dir="${strutstestcase.dir}" includes="*.jar"/>
        <fileset dir="${cactus.dir}">
            <include name="*.jar"/>
            <exclude name="commons-logging.jar"/>
            <exclude name="log4j-*.jar"/>
            <exclude name="servlet.jar"/>
        </fileset>
        <fileset dir="${env.ANT_HOME}/lib" includes="junit.jar"/>
        <fileset dir="${env.ANT_HOME}" includes="junit-noframes.xsl"/>
    </copy>
</target>

BTW, this XML was made web-savvy by the E2 Source Code Formatter - a must-have bookmark. I got this tip from The FuzzyBlog!.

Posted in Java at Jan 15 2003, 11:19:10 AM MST 6 Comments

Tomcat 4.1.x Tip - Contexts

Did you know that with Tomcat 4.1.x you can actually take an application's context out of the server.xml file and put it in a contextName.xml file in the $CATALINA_HOME/webapps directory? This makes it much easier to install and configure your webapps. Using this feature, you can easily setup Tomcat for your webapp using an Ant task. Here's the one I'm using for AppFuse:

<target name="setup-tomcat" if="tomcat.home"
    description="copies mysql jdbc driver and application's context to tomcat">
    <echo level="info">
        Copying MySQL JDBC Driver to ${tomcat.home}/common/lib
    </echo>
    <copy todir="${tomcat.home}/common/lib">
        <fileset dir="${hibernate.dir}/lib" includes="mm*.jar"/>
    </copy>
    
    <echo level="info">
        Copying ${webapp.name}.xml to ${tomcat.home}/webapps
    </echo>
    <copy todir="${tomcat.home}/webapps">
        <fileset dir="metadata/web" includes="${webapp.name}.xml"/>
    </copy>
</target>

Posted in Java at Jan 11 2003, 08:01:51 AM MST 1 Comment

PMD and Checkstyle

I knew about Checkstyle, but PMD is new to me. The Struts Development Team has recently added these tasks to its build.xml file if you're interested in an example. Erik Hatcher has the Checkstyle task in his JavaDevWithAnt project, and I'm using his build.xml file as a model, but I've never used the Task. I've also had the Checkstyle Plug-In for Eclipse installed at one point, but it gave me so many errors - I disabled it. It'd be nice to use these from the beginning on a project.

Posted in Java at Jan 05 2003, 12:52:38 PM MST 2 Comments

Using Both Ant and Maven

Erik Hatcher makes a request to get his JavaDevWithAnt project converted from using Ant to Maven:

Ok, a challenge to the Maven or Centipede experts tuning into my blog: make my JavaDevWithAnt project build with either. But the trick is that it has to be simpler than the current Ant build.xml. Believe it or not, I've not (seriously) used either of these tools. I hear the buzz about these and want to become a "believer".

I'm all for this as I've created my AppFuse project using his directory structure/build file as a template. I did go down this path to Mavenism already, but gave up before I finished. My problem is I have 15 different 3rd party JARs I use in my project - many testing frameworks and jakarta stuff. And a lot of these are nightly (or personal) builds because there's been some bug fixed, or enhancement added. What I really want is to continue using Ant b/c I think it rocks and it gives me more control over little tasks, but also to use Maven to generate a project site.

The problem with Erik's request is that I'm guessing no one will jump at the opportunity. Maybe, but in reality, no one looks at each others code unless there's a bug, or they need a sample to get started. Too bad - we could really do wonders for the Java Community if we started reviewing each others code. Erik, maybe you could post little snippets of your build file, and we could convert small parts of it. By posting a measly 10 lines, some other coders might be so inclined to help mavenize it. I know this is not how Maven works, but it sure would be nice if using Maven didn't require abandoning Ant.

Tonight I'll be staying up late trying to finish up AppFuse and Struts-Resume. Since the security-example download seems to be getting a lot of traffic (and it's a 15MB download), I should probably try to get these projects into SourceForge and save myself some bandwidth. Who knows if I'll get it done, I'm pretty tired, and it's already 10:00. But what choice do I have - Saturdays are family days, I promised my client that I pump a bunch of new features out on Sunday, and I get to work an 80 hour-week next week to get our first version out at my new job. Ugh, I need a vacation.

Posted in Java at Jan 03 2003, 09:47:25 PM MST Add a Comment

JUnit Tests - Naming Conventions

I am using Interfaces in my persistence layer, as well as for my Business Delegates. These interfaces are named things like UserDAO and UserManager. Their implementations are UserDAOHibernate and UserManagerImpl. First off, I don't know that I need interfaces for my business delegates, but they're already in place, so I'm going with it.

What I'm wonder is if my JUnit TestCases should reflect the Interface name, or the implementation name? UserDAOTest.java or UserDAOHibernateTest.java. I like the first one better, but I tend to hard-code information in it so I can call UserDAOHibernate.java - like the daoType to use. I started out using UserDAOTest because I thought it made more sense - and then it could be used to test all implementations.

Lately, I've been using JUnitDoclet to generate my TestCase skeletons, and it only generates TestCases for concrete classes, not interfaces. Therefore, I've changed to using UserDAOHibernateTest, which can be a helluva lot to type (and remember) when running TestCases! Here's the Ant command I use to run this test:

ant test-ejb -Dtestcase=UserDAOHibernateTest

And User is a short word! Can you imagine what these suckers will look like when I have an object such as ChangeRequest. Ughh. What do you gents think - I'm all ears.

Posted in Java at Jan 03 2003, 04:02:14 PM MST 3 Comments

RE: Ant's jspc task - doesn't work on Tomcat 4.1.18

A week ago, I reported that Ant's <jspc> task doesn't work with Tomcat 4.1.18. I posted a message to the ant-user mailing list (which is very low traffic BTW, a nice feature in my book) describing my issue. Last night, I received a reply from Steve Loughran, co-author of Java Development with Ant (BTW Steve - great book, you've already got my respect!) The short story is that there is something wrong with the Ant task and someone needs to "sit down and spend an evening looking at [Tomcat's] jasper." The real hope is that a Tomcat Developer could take over maintaining the <jspc> task, and then these types of issues wouldn't occur.

Posted in Java at Dec 29 2002, 05:00:50 AM MST Add a Comment