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 "maven". 270 entries found.

You can also try this same search on Google.

Running Cargo from Maven

Yesterday, I integrated Cargo into our application so we could start/stop Tomcat before running our jWebUnit tests. I use Cargo in AppFuse and Equinox - which are both Ant-based. Since we're using Maven on our project, I had to do a bit of futzing to get Cargo integrated into Maven. I prefer to use the Ant tasks from Cargo than the programmatic API because it's nice to run your tests when you start Tomcat manually. If you use the programmatic API, and start/stop Tomcat in setUp()/tearDown() methods - your test will fail if Tomcat is already running.

Below is what I added to maven.xml. With this, we can run "maven test-web" to test our UI with Tomcat running or "maven test-tomcat" to start/stop Tomcat before running our tests. Now I just need to figure out the best way to configure the proper port in my jWebUnit test. I'll probably put it into project.properties and the read the value as part of my test. I've also included a "deploy" goal in this example to demonstrate an easy way to deploy to Tomcat.

    <property environment="env"/>
    <property name="maven.tomcat.home" value="${env.CATALINA_HOME}"/>

    <!-- deploy the directory created by war:webapp to tomcat/webapps -->
    <goal name="deploy" prereqs="war:webapp">
        <copy todir="${maven.tomcat.home}/webapps">
            <fileset dir="${maven.build.dir}">
                <include name="${pom.artifactId}/**"/>
            </fileset>
        </copy>
    </goal>

    <goal name="test-tomcat" prereqs="war:war"
        description="Starts Tomcat, runs jWebUnit tests, stops Tomcat">

        <taskdef resource="cargo.tasks" classpathref="maven.dependency.classpath"/>

        <cargo-tomcat5x homeDir="${maven.tomcat.home}"
            output="${maven.test.dest}/cargo.log" action="start" >
            <war warFile="${maven.war.build.dir}/${maven.war.final.name}"/>
            <configuration dir="${maven.test.dest}/tomcat5x">
                <property name="cargo.logging" value="high"/>
                <property name="cargo.servlet.port" value="8280"/>
            </configuration> 
        </cargo-tomcat5x>
        
        <attainGoal name="test-web"/>
        
        <cargo-tomcat5x homeDir="${maven.tomcat.home}" action="stop"/>
    </goal>

    <goal name="test-web" prereqs="test:compile" description="Runs JUnit tests">

      <taskdef name="junit"
        classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
      
        <mkdir dir="${maven.test.reportsDirectory}"/>
        <junit printsummary="no" errorProperty="test.failed" 
            failureProperty="test.failed">
            <classpath>
                <pathelement location="${maven.test.dest}"/>
                <pathelement location="${maven.build.dest}"/>
                <path refid="maven.dependency.classpath"/>
                <path location="web"/>
            </classpath>
            <formatter type="xml"/>
            <formatter type="brief" usefile="false"/>
            <batchtest todir="${maven.test.reportsDirectory}" if="testcase">
                <fileset dir="${maven.test.dest}">
                    <include name="**/*${testcase}*"/>
                    <exclude name="**/*TestCase.class"/>
                    <exclude name="**/*$*.class"/>
                </fileset>
            </batchtest>
            <batchtest todir="${maven.test.reportsDirectory}" unless="testcase">
                <fileset dir="${maven.test.dest}">
                    <include name="**/*WebTest.class"/>
                </fileset>
            </batchtest>
        </junit>

        <fail if="test.failed">
          Unit tests failed. For error messages, check the log files in
          ${maven.test.reportsDirectory}.</fail>
    </goal>

Posted in Java at Jan 15 2005, 02:15:05 PM MST 2 Comments

CruiseControl and Maven

At work today, I put together a config.xml for CruiseControl to run continuous integration builds for our project. We're using Maven, so I used the CruiseControl Plugin to generate a cruisecontrol.xml file to get started. Then I moved this file up a few directories, renamed it to config.xml and changed all the log paths to be outside of the project.

There's quite a difference between running CruiseControl with Ant vs. Maven. With Ant - you tend to delete the whole project, check it out from CVS and build/test it from scratch. With Maven, the recommendation seems to be a bit different. What I found on the mailing lists and such was that you should manually checkout your project into your "checkout" directory and then call "scm:update-project|clean test" from config.xml. With Maven, it seems there's no CruiseControl-specific maven.xml file for your project.

I tend to like the delete/checkout/test approach you get with Ant over the update/test approach with Maven. For those of you that are using CruiseControl with Maven - is it possible to do delete/checkout/test - or am I stuck with the update/test approach?

Posted in Java at Jan 10 2005, 10:34:09 PM MST 3 Comments

[ANN] DisplayTag 1.0 RC2 Released

Fabrizio, the main man behind the Display Tag, has been fixing bugs and adding features at breakneck speed. Early this morning, he released the final 1.0 candidate for the Display Tag. Good stuff - thanks Fabrizio!

Posted in Java at Nov 20 2004, 09:53:59 AM MST 5 Comments

[DJUG] Web Services and Geronimo

We're finally getting started at 6:25 and we were supposed to start at 5:50. Good ol' projector issues. This time it was a bent pin.

J2EE 1.4 introduced the first web services component type (SE) and augments EJB specification (2.1) to expose SLSBs as a web service endpoint.

Writing J2EE 1.4 web services ("endpoints")

Two J2EE components to implement a web service:

  • JSE (JAX-RPC Service Endpoint). New component, new deployment descriptor. Looks like a servlet, acts like a servlet. Run's in a web container like a servlet. Isn't a servlet.
  • SLSB. Exposed as web service via deployment descriptors.

JSE is easier because it's (mostly) POJO based. EJB might be preferred if you already have EJBs or you need transaction management. However, the SOAP client calling the EJB web service does not participate in the transaction (at least the spec does not define it).

"Mandatory" transaction attribute not allowed in EJB endpoints because SOAP client can't propagate transaction.

JSEs are similar to servlets:

  • Instances run in the web container
  • follow servlet lifecycle
  • Must have a public no-arg constructor
  • Can add servlet filters just like you do normally

Steps to writing a web service JSE:

    1. Write remote interface (the service endpoint interface) - must extend java.rmi.Remote and throw RemoteException
    2. Write implementation class
    3. WSDL Document
    4. Deployment Descriptors (web.xml and web-services.xml)
    5. Create WAR File

J2EE 5 will allow you to turn any POJO into a web service - no interface needed. Apache Axis can be used to generate the WSDL for you with Ant. You map the implementation class as a servlet, with a servlet-mapping and everything. The difference b/w JSE's and servlets is you can only map one JSE to one URL.

Writing web service clients. Client model is defined by the JAX-PRC 1.1 spec. You can write web service clients using three JAX-RPC techniques:

1. Generated Stub - Easiest. Done at development time. JAX-RPC is invisible to your code. Stub classes hide it. Runtime implementation will be tied to a vendors JAR because vendor tool will generate class based on WSDL.

2. Dynamic Proxy - Most Portable. Done at runtime. Your code asks JAX-RPC factory to create stub at runtime that implements SEI (Service Endpoint Interface).

3. Dynamic Invocation Interface (DII) - No Stub Necessary. Useful for tools - e.g. dynamically retrieve WSDL then show user on a GUI what services are available and allow user to select what should be called. Client sets URL, methods to invoke and required parameters.

Future of J2EE web services. JAX-RPC 2.0 (JSR 224) in the works. The goals of JAX-RPC 2.0 are several:

  • Make writing WS simpler by using metadata and annotations.
  • If you write an endpoint interface, your implementation class won't have to implement it.
  • Remove requirement to define a remote object.
  • Better support for document-centric web services.
  • Integration with JAXB.

Tom's presentation was quite good for his situation. There was a *ton* of technical issues and he had to show his presentation on Chris Huston's Powerbook. This meant no demos since he had JBoss 4.0 and everything else setup on his Windows laptop. After flailing about for the last hour - he admits its time to buy a Mac.

Apache Geronimo

1. Apache Software License
2. Uses other BSD-derived, open source projects
3. Initial manifestation as a J2EE 1.4 application server 4. J2EE 1.4 certified (in-progress)

Started a year ago in September. The main motivator for Geronimo was there was no BSD-derived license for an open-source application server. The GPL license requires you to contribute code back if you customize a product. BSD allows you to do anything, you just have to give credit back to the originator. Sounds like the proper license for AppFuse to me.

The heart of Geronimo (the kernel) knows nothing about J2EE. It's designed to do just about anything you want it to do - it's just a configuration away. Jakarta project at Apache makes up a huge portion of ASF projects. Many of these projects are pieces of the J2EE puzzle. However, there wasn't any glue to hold it all together. Geronimo re-uses a *lot* of existing (best of breed) open source projects.

Geronimo still doesn't support Tomcat. The main reason is because 3 of the Jetty committers are part of the Geronimo team. Jetty was the first component every deployed in Geronimo. According to Bruce, someone is working on integrating Tomcat right now. You'd think this would be pretty easy and only take a couple days to do. Maybe I'm wrong.

Geronimo is NOT another lightweight container, web framework, or AOP framework.

It IS designed for long running servers. Its designed to tolerate partial component failures. System oriented services.

Geronimo Kernel - Fundamental Core

  • Small memory consumption ~ 150KB code
  • Component Registration
  • Component Configuration
  • Integrated Repository
  • Lifecycle Control
  • Dependency Manager

Now Bruce is going on about Maven and how it works. ZZZzzzzz. Maven schmaven. He does have a good point though - it works great for building and managing multiple projects and their dependencies. Geronimo has 30 sub projects - yow.

A lot of concepts and architecture in Geronimo is derived from Maven. Hmmm, I wonder if that means it's slow. ;-)

What are GBeans? They're a J2EE managed component (a JMX MBean), which are basically simple objects plus some metadata. Used to bridge JSR-77 lifecycle requirements. GBean wrappers allow just about anything to be plugged into be plugged into Geronimo. Implement the GBeanLifecyle interface: doStart(), doStop(), and doFail().

Bruce is now showing us the DerbySystemGBean that's used to stop and start GBean w/in Geronimo. Bruce has a lot of good things to say about Derby and thinks it's a much better database than both MySQL and PostgreSQL. That's a pretty strong statement, but since he met with Derby's architect last week, I tend to believe him. I'm assuming since I got AppFuse working with DB2 that using it with Derby would be pretty easy too.

Bruce says there's supposed to be a Geronimo release this week. I thought they were supposed to be done with Geronimo by this year's ApacheCon?

Now we're looking at an XML file that's a GBean configuration file. It looks like Spring is going to get some competition for long class names. And if you thought Spring's XML was verbose - Geronimo puts it to shame! I'm not saying this is a bad thing - it's just an observation.

GBean Archive - A JAR file that contains persisted GBean instances, GBean metadata. The Java classes in the GBean can reside in the JAR or be dependencies in a central repository.

GBean Descriptor - dependencies and configuration are defined in XML.

Repository: Structured collection of JARs. Designed to work in conjunction with Maven (pluggable implementation). Every JAR has a unique group and artifact id. Default repository is local file system, others allow auto-download.

Observation: Bruce's presentation is interesting - he seems to be targeting folks that want to dig into Geronimo and customize it. I think most developers just want to use it and would be more interested in seeing a demo of deploying an app on Geronimo, rather than how to integrate Derby or Jetty into the server. If it's so easy to plugin a component, why hasn't Tomcat been integrated? Maybe it's just me, I want to see it run and deploy apps to it - that's about all I want to do. In most cases, I shouldn't need to customize it. It's nice to know that it's an option though.

Basic Configuration Builder: Deployers are J2EE specific (JSR-88). If you have standards-compliant deployment descriptors - your application should deploy on Geronimo. Rather than calling them deployers, Geronimo uses "Builders". The Builders /deployers create configuration objects containing GBeans. Most complex Builder is J2EE deployer. It implements a JSR-88 deployment specification and accepts JARs, WARs, EARs, and RARs. You can also add in a deployment plan in XML. From this, a Geronimo Configuration ARchive (.car) is created. The nice things about these builder is you can do deploy-time optimizations, before the application is started.

Everything above the System Services and Kernel is hot swappable. You can remove the J2EE Configuration and replace it with something else like Pico or Spring. This means that you'll be able to swap out servlet containers w/o shutting down the server. That's pretty damn cool. If the system services and kernel are stable, and no JVM dumps occur - this means that your Geronimo server could be running forever. Sounds awesome.

High-availability (clustering, etc.) has not been built into Geronimo yet. This is primarily because this is not part of the J2EE spec. Developers are focusing on gaining 1.4 compliance, then they'll start looking at the fancy features.

Wow - good presentation Bruce. I feel like I know more about Geronimo than I ever wanted to know.

As I was getting ready to post the above transcript, I noticed that Geronimo 1.0 M3 was released. According to Bruce's presentation, this is the last release before 1.0. Nice work gents.

Posted in DJUG at Nov 11 2004, 12:36:47 AM MST 3 Comments

Comparing Web Frameworks: Equinox, Ant and Maven

Next week I'll be putting together the sample apps for my Comparing Web Frameworks talk. They're going to be pretty simple. They'll be created using Equinox and will closely resemble the MyUsers app created in Chapter 2 of Spring Live. That is, they'll just be simple webapps that allow you to CRUD a database table. MyUsers just edits a user's first and last name, but I'll probably add a "birthday" field to demonstrate Date handling. Even though it's simple, it'll have a pageable/sortable list, validation and success messages - which is what most apps need. Of course, if I can't get X feature to work, I'll make sure and highlight that in my talk.

Equinox is based on Ant and works quite well. However, I have a Maven version of Equinox that I developed for Open Logic this summer. They've been gracious enough to let me release this as open source. BTW, if you're looking for a rich set of Maven sample apps - Blue Glue 3.1 will have a few (including multi-project). Blue Glue also contains detailed documentation on each of these sample apps I'm creating for this talk.

So the question is - should I release a Mavenized version of Equinox? Or should I modify Equinox to contain and allow you to use both Ant and Maven? The problem with allowing both is I'd likely give up everyone's favorite Maven feature - downloading dependencies. I personally have grown to loath this feature b/c repositories are hardly ever up-to-date and I spend a lot more time trying to get repositories updated (or creating my own) than I would downloading the JAR. Spring uses both and simply points Maven to its local JARs. That's probably what I'd do.

Of course, the easiest (and KISS) thing to do is to use Equinox with Ant and not complicate things. However, I'm willing to put in a couple hours to try and make Equinox allow both. Regardless, I'm willing to release a Mavenized version of Equinox - if there's interest.

P.S. Don't forget to thank the Open Logic guys for making this all possible. I wouldn't have been able to do this talk without their generous donation.

Posted in Java at Oct 21 2004, 02:57:52 PM MDT 3 Comments

[ANN] Cargo 0.2 Released

Download · Release Notes · Learn More · Project Weblog. I've been looking for something like Cargo for a while now - mainly so I could provide an easy way to test JSPs (and therefore the whole app) in-container. For the last couple of years, I've been using Cactus' <runservertests> task, but it requires you to configure your own startup and shutdown targets - which can be difficult for the different containers. Cargo makes this easy. So easy that I've added it as a topic to Chapter 8 of Spring Live. BTW, the MyUsers sample app shows you how to use jMock and Easy Mock for isolating Manager tests and Action/Controller tests - something that I might eventually move to with AppFuse.

In 1.5, AppFuse's build.xml is tightly coupled to Tomcat for running Cactus tests and Canoo WebTests. There are only a couple of Cactus tests in the Spring and WebWork versions - LoginServletTest and ActionFilterTest and I believe I can use Spring Mocks to refactor those and test them out-of-container.

Using Spring's ContextLoaderPlugin for Struts, I should be able start testing the Struts Actions using MockStrutsTestCase too. This means that the only in-container tests will be Canoo WebTests. As part of 1.6, hopefully you'll be able to run the "test-web" target sans container. Right now it sounds like quite a challenge, but being able to run Spring's Controllers and WebWorks Actions out-of-container is a really nice feature. Furthermore, removing Cactus as a dependency would open the doors for using JDK 5.0.

I'm also hoping to add support for switching containers - by running a simple script that nips and tucks the build.xml. For 1.6, I'll try to add an installer for Resin. If it's easy, I might take a stab at Jetty and Orion too.

Update: Cactus is gone - there's no need for it anymore as all actions/controllers, filters and listeners can be tested out-of-container. The best part is I didn't have to change any application code - just a few tests. Sweet!

Posted in Java at Oct 03 2004, 04:15:48 PM MDT 2 Comments

Rock Bottom Brewery

This evening, I met up with Dion, Christian and Bruce at the Rock Bottom Brewery. Topics discussed: OSCON, JavaOne, WebSphere, AOP, JBoss, Geronimo, Spring, Struts, SourceBeat, OpenLogic, TSS, ThoughtWorks, Ant, Maven, Digital Globe (of course), staying up late, getting up early and writing. Good stuff - thanks gents.

Rock Bottom Brewery

Posted in General at Aug 05 2004, 11:43:27 PM MDT 1 Comment

RE: Why use Maven

Warner has a post about why he likes Maven. He might not know it, but he's actually ripping on AppFuse, its directory structure, and build file. I like getting ripped on, so that doesn't bother me. What bother's me is that Warner has comments turned off so no one can get him back. ;-)

The main reason that AppFuse uses Ant over Maven is speed. Maven runs much slower than Ant. Period. Also, with an open source project like AppFuse - I try to appeal to the larger audience, who likely has Ant installed. Other OS projects I work on (displaytag and struts-menu) both use Maven and people have a lot harder time trying to build from source b/c of Maven issues. Lastly, I like having a complete download - rather than download-dependencies-after-you-download-the-project like Maven does. I realize if I did use Maven I could package the dependencies in the app - which is likely what I'd do anyway since the main repositories seem to be constantly out-of-date.

Recently, I had a similar experience to Warner. As part of my current contract, I was tasked to write a couple of Maven sample apps. Warner came to my rescue and helped me out a lot, but I felt like I was jumping through a lot of hoops to do simple stuff that was already done in the Ant version of my app. I guess I'm just not a Maven guy. A project that's done right, regardless of if it's done with Ant or Maven, should build by typing "ant" or "maven" - or at least provide you help on what you need to type. Some projects, like Spring and Struts, actually allow you to use either one out-of-the-box. That's a pretty cool idea and likely keeps everyone happy.

It sounds like Warner has re-worked AppFuse to work with Maven. Care to donate your couple hours of work? I wouldn't use it personally, but there has been interest in a Maven version. Some folks seem to like slow build tools.

Posted in Java at Aug 04 2004, 03:29:04 PM MDT 26 Comments

Eclipse Plugins Updated for 3.0

I finally got around to updating my Eclipse Plugins package for Eclipse 3.0 → Download or read the Release Notes. Below is a list of plugins included in this download. I dropped Lomboz and JSEditor b/c they didn't work at all with 3.0 on Windows - which I expect is the largest user base. Additions include CSS Editor and Doclipse.

Colorer and Jalopy don't work on OS X, so I wouldn't even bother installing them. Colorer has issues on Linux too. For OS X, I'd recommend buying a subscription to My Eclipse. It's only $30 and if you can afford a Mac, what's another $30? ;-) For a source code formatter on OS X, I recommend buying IDEA - it's only $200 - same cost principle applies. I tend to use IDEA a lot more on the Mac simply b/c it's faster and you don't need to install all these plugins. However, I've been stuck a lot in Eclipse-land lately because of it's multiple-project-in-one-pane support - as well as it copies and pastes code nicely into Word.

In addition to these plugins, I recommend installing the Spring IDE Plugin if you're using Spring [HowTo] - and Spindle if you're using Tapestry. Hopefully, distributions like this will become unnecessary with the introduction of the Web Tools project.

Posted in Java at Jul 23 2004, 03:31:57 PM MDT 13 Comments

My WebWork Experience

Yesterday I began converting a small application from Spring MVC to WebWork. By the end of the day I was pretty much finished, but shot an e-mail off the the user's list to figure out a few more things. Today was spent incorporating that knowledge and making the app follow more WW "best-practices". Below is a list of things I discovered:

  • WebWork's documentation is actually quite good. I was able to figure out most things just by reading it. I'm still surprised that most web app frameworks don't describe a simple CRUD operation as their first example. In my experience, CRUD is 80% of a webapp's job.
  • WebWork integrates with Spring quite nicely. It's interesting to see that Spring has most of its MVC Framework support as part of the core, but WW has its own. I wonder why? Who cares, it works!
  • WebWork is a bit better than Spring MVC in that they have a mechanism for saving/displaying success messages. However, it doesn't live past a redirect, so you're still stuck putting messages in the session. Struts (as of 1.2.1) allows you to use a saveMessages(session, messages) call - and subsequent JSP tag to display (and automagically remove). Like it or not, Struts seems like the easiest solution for developers to use.
  • There's no clean mechanism for cancelling validation when a user clicks on a "cancel" or "delete" button. Struts supports cancelling using it's <html:cancel> button and it's pretty easy to detect "delete" and cancel validation in a form's validate() method. I ended up using an onclick handler for my cancel button and not worrying about validation on delete. This is the way I did it with Struts for years. Spring is cool in that it has a processFormSubmission() method that you can override before validation kicks in.
  • With Commons Validator, I'm used to specifying generic validation messages like "errors.required={0} is required.". This is possible with WW by using "errors.required=${getText(fieldName)} is required.". However, WW is a bit unique in that validation rules and ResourceBundles are defined on a per-action basis. I like having a central location for all my messages - like Spring and Struts have. I know it's possible with WW, but I'm trying to develop a "best-practices" sample app.
  • I really dig that fact that you can use one JSP tag to render an entire <tr> in a table. This <tr> ends up having a label and an input field - which is very cool IMO. I did find some issues with the XHTML output, but found it very easy to submit patches. Good stuff.
  • The config files (xwork.xml and validators.xml) must be in WEB-INF/classes. This is because they're XWork configuration files, and XWork is a non-web framework. It would be nice if I could put these in WEB-INF - where the rest of my config files (Spring, SiteMesh, etc.) reside.
  • Many of the JSP tags require you to use "'literal value'" - where you put single and double quotes back-to-back. IMO, this is just ugly and I'd much rather put some sort of indicator that it's a dynamic value - i.e. ${...} or #.
  • I couldn't get client-side validation to work. Seems cool though.

My experience with WebWork has been quite pleasant. I received excellent support from the mailing list - even though it took me a while to subscribe. The mailing list archives are woefully out-of-date, but this is a general java.net problem - not a WW issue. Maybe they should create a forum until the mailing lists get back on track?

Hopefully this last day and a 1/2 will make it much easier to implement WebWork in AppFuse. Thanks for the support gents - now I'm off to learn Tapestry!

Posted in Java at Jul 21 2004, 03:41:58 PM MDT 8 Comments