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 "servlet". 226 entries found.

You can also try this same search on Google.

AppFuse 2.0 Status

Better than Tots We're working hard on AppFuse 2.0. The good news is things are coming along really nicely. There's quite a few developers working on the project now and they've been a tremendous help. If I knew the move to Maven 2 would've inspired so much help, I would've done it a long time ago! We've got most of the archetypes created and we just need to work on documentation for the 2.0 release M1 release. As far as the roadmap is concerned, we've finished most of the code for an M2 release, but we still need to do documentation. I'm hoping to release 2.0 M1 on Thursday of next week.

If you want to try it, you can checkout the Hello World with AppFuse 2.0 video. After that, feel free to take it for a test drive using the QuickStart Guide.

New features in AppFuse 2.0:

  • Maven 2 Integration
  • Upgraded WebWork to Struts 2
  • JDK 5, Annotations, JSP 2.0, Servlet 2.4
  • JPA Support
  • Generic CRUD backend
  • Full Eclipse, IDEA and NetBeans support
  • Fast startup and no deploy with Maven Jetty Plugin
  • Testable on multiple appservers with Cargo and profiles

Speaking of goodies, I uploaded a bunch of AppFuse desktop backgrounds to Flickr. Thanks to Max Hays of Timberline Group for creating these.

Only 26 days left until the AppFuse 2.0 Release Party! Location TBD. :-D

Posted in Java at Jan 06 2007, 01:18:38 AM MST 3 Comments

[TSE] Spring-OSGI with Adrian Colyer

One of the first questions people ask about OSGi is "what the heck is it?"

Most people don't even know what it is. OSGi stands for Open Services Gateway initiative. From the very beginning, it was designed to be lightweight and dynamic. This is the major difference between it and other containers. It's always been designed to have things added and removed. Now it's tagline is: "The Dynamic Module System for Java".

It's designed to allow you to partition a system into a number of modules (a.k.a. bundles). There's strict visibility rules (similar to protected and private). There's a resolution process (dependencies are satisfied) and it understands versioning.

It's dynamic! Modules can be installed, started, stopped, uninstalled and updated - all at runtime.[Read More]

Posted in Java at Dec 09 2006, 02:29:58 PM MST 6 Comments

How do you get open source frameworks past the red tape?

From an e-mail I received earlier this month, with a subject of "Acceptance red tape":

After requesting permission to use the Spring Framework for the business logic and data access layers of an application, how do you fight something like this? Spring is not an approved Framework for the ********** environment. We understand the benefits of the framework. However, we have not certified it in our environment. Additionally, we have concerns that this framework will not gain long standing traction among the J2EE community. We would like to reduce the number of frameworks used in our environment, and do not want to be left with "legacy" frameworks that have little acceptance or support as is the case with the pico container. This is a response from one of our clients after asking about the use of a framework in our development after another vendor had used the PicoContainer without their permission. We have Spring experience and we love it. My responses have been to ask what they have certified that we could use and to ask their business staff to override their tech staff. I'm caught needing to redesign an aging J2EE application with an awfully over-architected original design confined to EJB 2.1, JSP 2.0, Servlet 2.4, and JDK 1.4.X in a very short amount of time. The additional responses were that they have only certified Struts and although both the business staff and the tech staff admit they know the benefits of Spring, neither of them are allowing us to use it.

My response:

Wow - I don't know what to say, especially when they say "Additionally, we have concerns that this framework will not gain long standing traction among the J2EE community." They're probably using Struts and they thinks it's wonderful, eh? ;-)

I could compose a long response with lots of details, but the fact that they prefer EJB over Spring is baffling. Spring is so much easier to program with, it's not even funny. Granted, EJB does have its place, but it's often used as a hammer for a problem that doesn't exist.

Have you experienced similar "Acceptance red tape" in your company? If so, how did you work around or work through it?

Posted in Java at Nov 16 2006, 08:04:24 AM MST 31 Comments

Is XMLC a dead project? Is anyone using it?

From an e-mail I received a while back:

I'm interested in hearing your opinion of XMLC? And when will we see it in AppFuse? ;-) Seems to me that with it's base in xml and all the ajax and SOA hubub that it could be primed for a resurgence. And what about BarracudaMVC as an AppFuse option?

[Read More]

Posted in Java at Nov 15 2006, 10:13:03 PM MST 14 Comments

Integrating Facelets and Ajax4JSF with MyFaces

I spent a few hours tonight integrating Facelets into an AppFuse-based application. The integrating was fairly easy thanks to the work Thomas Gaudin did back in January. For the most part, it was just a matter of 1) replacing <fmt:message> tags with #{text['key']} tags, 2) replacing the <%@ include file="/common/taglibs.jsp"%> at the top of each page with Facelet's namespace tags and 3) renaming the pages from *.jsp to *.xhtml. The only thing that tripped me up was I thought the "c" namespace was the same as JTLS's URI, but it's actually a whole new URI. Thanks to the Facelets developers for a much-needed fix for JSF.

After I got Facelets integrated and working, I dove into integrating Ajax4JSF. Two hours later and I have the simple repeater demo working. What took so long? I spent an hour staring at (and googling for) the solution to the following error:

PhaseListenerManager.informPhaseListenersBefore(74) | Exception in PhaseListener RENDER_RESPONSE(6) beforePhase.
java.lang.NullPointerException
        at com.sun.facelets.FaceletViewHandler.writeState(FaceletViewHandler.java:759)
        at org.ajax4jsf.framework.renderer.AjaxRendererUtils.writeState(AjaxRendererUtils.java:850)
        at org.ajax4jsf.framework.renderer.AjaxRendererUtils.encodeAreas(AjaxRendererUtils.java:740)
        at org.ajax4jsf.framework.renderer.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:128)
        at org.ajax4jsf.ajax.UIAjaxRegion.encodeAjax(UIAjaxRegion.java:210)

The solution turned out to be removing the FaceletsViewHandler from faces-config.xml:

<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>

Also, it seems the following is required in web.xml:

    <context-param>
        <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
        <param-value>com.sun.facelets.FaceletViewHandler</param-value>
    </context-param>

Hopefully this helps others googling for the exception above.

Posted in Java at Oct 12 2006, 02:41:24 AM MDT 9 Comments

New weather.com site built using AppFuse

From Jeff C (a Sr Developer for forgetaway.com, a new unit of weather.com) in Lightweight Java Development with Webwork, Spring, and iBatis:

Our new site, ForGetaway.com, launched 2 weeks ago, and its built on WebWork, Spring, and iBatis. Using those 3 frameworks as the backbone of the site was a great experience. I think that combination of frameworks can be considered lightweight, especially from a development standpoint.
...
Even the development/testing process is quick. Thanks to Matt Raible's AppFuse (which was used to get this app started), we have a sweet build.xml file that allows us (on our dev machines) to reload our app by having the build script talk to tomcat. So, even when a properties file or java class or static field changes, its just a matter of running the reload task in the build.xml file and tomcat reloads the app with all changes in under 5 seconds. Yeah, rails is probably quicker, but i can spare 5 seconds of my time to let my changes get reloaded by tomcat.

Reloading your application in Tomcat to see your changes sucks. However, AppFuse 2.0 will allow you to use the Maven 2 Jetty Plugin, which aims to eliminate the whole deploy cycle. This plugin is powered by Jetty 6, which has been rewritten for Continuations, NIO, Servlet 2.5. Hopefully we'll start to see more appserver plugins written for Maven 2.

I love hearing success stories like Jeff's. That's why I (and many others) work on AppFuse - to simplify Java web development. We know that it's more painful to develop web applications in Java than in scripting languages, but we continue to do it because tools like AppFuse make it enjoyable. Even though tools and languages are important for simplification, I believe that most project's success is determined by people. If you have good people, effective processes and a lack of politics - a project should have no problem being successful, regardless of the tools.

Did you know the new SourceBeat site is also powered by AppFuse? We chose the WebWork+Spring+Hibernate combination and were quite pleased at how easy it was to develop everything. We had 90% of the site done in the first two weeks of development.

In other AppFuse-related news, the demos have been running solid for 70 days straight. I'll admit that's not a very log time, but it does prove there's no memory or connection leaks in the software. ;-) The number of currently active sessions is as follows:

The default session timeout is set to 10 minutes in AppFuse.

Posted in Java at Sep 28 2006, 11:40:55 AM MDT 6 Comments

Spring Forward 2006 - The Keynote

After a 1 and a 1/2 hour cab ride, I arrived at Spring Foward 2006 just in time for the opening keynote. It looks like I'll be doing a 2nd talk this afternoon as Clark Richey was unable to make the show. I was given a choice of talks, and I chose "Comparing Web Frameworks" because that's a fun talk to do.

Thomas Risberg introduced the show (and the new Philadelphia Spring User group site), and now Colin Sampaleanu is talking about Spring. Spring 2.0 is fully backwards-compatible. There's a huge user base that demands full backwards compatibility so their old code still works. Spring 2.0 will run on your existing infrastructure: Java 1.3, 1.4 or 5. It'll run on all major application servers, as well as a simple servlet container.

The first major new features in Spring 2.0 are the simpler (extensible) XML configuration, as well as new AOP mechanisms.

XML Configuration in Spring 2.0

  • Ability to define new XML tags to produce one or more Spring bean definitions
  • Tags out of the box for common configuration tasks
  • Problem-specific configuration (easier to write and to maintain)
  • XML schema validation (better out of the box tool support, code completion for free)
  • Exploits the full power of XML (namespaces, tooling, etc.)
  • Backwards compatible (full support for <beans> DTD, complete interoperability b/w classic and extended configuration)

JNDI Lookup example (Spring 1.2.x):

<bean id="dataSource" class="...JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/StockData"/>
    <property name="resourceRef" value="true"/>
</bean>

In Spring 2.0:

<jee:jndi-lookup id="dataSource" jndiName="jdbc/StockData" 
    resourceRef="true"/>

AOP in Spring 2.0

  • Simplified XML configuration using <aop:*> tags
  • Closer AspectJ integration (pointcut expression language, AspectJ-style aspects in Spring AOP, @AspectJ-style aspects in Spring AOP that are fully interoperable with ajc compiled aspects)
  • Build on strengths, eliminate weaknesses
  • Preserve ease of adoption (still zero impact on development process/deployment, easier to adopt)
  • Benefit from the power of AspectJ
  • Spring and AspectJ are still separate projects, but work close together since both projects' leads work for Interface21

AOP is about pointcuts:

  • Pointcuts give us the tool to think about program structure in a different way to OOP
  • Without a true pointcut model, you only have trivial interception
  • By integrating AspectJ's pointcut expressions in Spring AOP, it's a much more powerful AOP framework

Hot on the heals of Spring 2.0, Spring Web Flow 1.0 will be released. It's a full Spring subproject and part of Spring's web stack. Using SWF, you can capture a logical flow of your web application as a self-contained module, at a higher level. Another interesting project is Spring LDAP. It's a Spring subproject that simplifies LDAP operations - based on the pattern of Spring's JdbcTemplate. It encapsulates nasty boilerplate plumbing code traditionally required for LDAP.

Finally, Spring 2.0+ will support OSGI. So what is OSGI? It's an industry driven framework specification, with multiple implementations. It has a dynamic omponent model, based around the idea of bundles. It's a full component model with classloading (for isolation and versioning), lifecycle control definition, etc. It's the foundation of Eclipse's plugin architecture.

Why do you need Spring-OSGi? Spring-OSGi is an integration library for Spring in OSGi environments. For those that need it, allows a more powerful component programming model. Without Spring having to re-invent the wheel, ApplicationContexts become bundles that are able to import and export services with full isolation and integration into OSGi lifecycles. The project is moving along rapidly, with large amounts of interest and involvement from vendors such as BEA, Oracle, IBM members of the OSGi foundation and the general public.

Finally, don't forget about The Spring Experience 2006. It's 3 days, 55 sessions across 5 tracks, including: Core Spring 2.0, Core Enterprise 2.0, Core Web 2.0, Domain-Driven Design and Just Plain Cool.

Posted in Java at Sep 26 2006, 08:14:01 AM MDT 2 Comments

Comparing Open Source Application Servers

With all the recent hubbub about GlassFish, I decided to do a quick performance test this morning. I downloaded all the most recent versions of the various open source application servers, deployed AppFuse 1.9.3 (Struts version) on them, and ran "ant test-canoo" to see if any of them were faster than the other. This was by no means a scientific, isolated test. It also didn't take into account any performance tuning you should do on these servers, I just used the out-of-the-box settings.

I ran these tests on my MacBook Pro (2.16 GHz Intel Core Duo, 2 GB DDR2 SDRAM) with my JAVA_OPTS set to:

-Xms768M -Xmx768M -XX:MaxPermSize=512m -Djava.awt.headless=true

When typing "java -version" at the command line, I got:

java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-103)
Java HotSpot(TM) Client VM (build 1.5.0_06-57, mixed mode, sharing)

Servers tested (in no particular order):

  • JBoss 4.0.4
  • GlassFish B48
  • JOnAS 4.7.6
  • Resin 3.0.21
  • Geronimo 1.1

I'm pleased to note that all servers allowed me to deploy appfuse.war without using a console or command-line tool. They all support dropping the WAR in some sort of auto-deploy directory. Very cool! Secondly, I was able to successfully deploy AppFuse on all of them with no changes to AppFuse nor the server. Quite impressive.

My test consisted of the following:

  • Copying appfuse.war into the appropriate directory
  • Starting the server
  • Running "ant test-canoo" from my $APPFUSE_HOME directory once
  • Running "ant test-canoo" 3 times, recording the numbers for each run

Here's what I found:

Server Name1st run (seconds)2nd run3rd runAverage
JBoss 4.0.424232323.33
GlassFish B4825242424.33
JOnAS 4.7.625252725.66
Resin 3.0.2123232323
Geronimo 1.128232324.66

Since I know you're going to ask about Jetty and Tomcat (the two main servlet-only containers), I ran the numbers on those too. First off, I tried Jetty 6 RC0. No dice - I got the following error when trying to start the server.

java.lang.IllegalStateException: Cannot initialize context because there is already a root application 
context present - check whether you have multiple ContextLoader* definitions in your web.xml!
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:173)

Since AppFuse deploys on all the above app servers, as well as Jetty 5.1.x, I'll chalk this up to a bug in Jetty 6. I used Jetty 5.1.11 for this test because I already had it installed on my machine.

Server Name1st run (seconds)2nd run3rd runAverage
Jetty 5.1.1124252424.33
Tomcat 5.5.1723232222.66

I don't know that these numbers mean anything, but it was a fun experiment. For those of you who think these numbers might mean something, here's the rankings:

  1. Tomcat 5.5.17
  2. Resin 3.0.21
  3. JBoss 4.0.4
  4. Jetty 5.1.11/GlassFish B48 (tie)
  5. Geronimo 1.1
  6. JOnAS 4.7.6

Of course, the better test would be hammering each server with 1000 concurrent users (or a number higher than that) and comparing how each server holds up.

Posted in Java at Aug 15 2006, 10:00:56 AM MDT 11 Comments

AppFuse 1.9.3 Released

This release is primarily a bug fix release, but also contains upgrades to several dependent libraries, including Acegi Security 1.0.1.

To install and configure AppFuse for development, see the QuickStart Guide. Thanks to all the sponsors who have contributed products and free hosting to the project.

To see how AppFuse works, please see the following demos (username: mraible, password: tomcat):

Comments and issues can be sent to the mailing list or posted to JIRA.

Note: If you're building AppFuse on Linux, you should be aware of some non-English encoding issues. The solution is to add the following to your ~/.bashrc file.

export LC_CENGINE=en_US
export LANG=en_US
export LANGUAGE=en_US

Posted in Java at Jul 11 2006, 08:20:45 AM MDT 12 Comments

RE: What Web Application framework should you use?

Tim O'Brien has an interesting post titled What Web Application framework should you use?. The first thing I noticed about this post is the permalink. It looks like he started with "Isn't Rails supposed to change...", which makes me wonder what the rest of the title was. In this post, he rags on Java Web Frameworks and the lack of a clear path for choosing one. He ends up predicting that many will stick with Struts 1.x (poor bastards) and those that aren't tied to Java should move to Rails. I don't have a problem with folks moving to Rails, but I would like to comment on the Java Web Framework space and Tim's comments.

He says:

Prediction: The confusion over what is happening over at Struts is going to discourage people from continuing to use it. The Struts team did the right thing in recognizing that Struts 1.x was a dead-end, but that project needs a single public message. Is it Struts Action or is it Struts Faces? Or is it two frameworks capitalizing on the Struts brand name?

I think what is going on in the Struts project is definitely two frameworks capitalizing on a brand name. That was a concious choice on the project's part when they chose to start creating sub-projects. The interesting thing about Struts Shale is it's largely a prototype for JSF 2.0. Furthermore, it was rejected by many Struts developers as becoming Struts 2.0. Why? Because JSF sucks. Especially when used with JSP - which is what most folks are doing.

JSF continues to be the most over-hyped under-used framework in Javaland. If you read the blogs of first-time users, you'll find many complaints and issues on how things work. Granted, most of these problems are with JSP and the implementation, but still. If I were in charge of JSF, I'd dump JSP altogether, bundle Facelets with it and allow more flexible page navigation (including controller-to-page). Don't get me wrong, I like the ideas behind JSF, I just don't like the implementation (or the fact I have to wait years for things to be fixed in the spec).

That being said, I've yet to meet an unhappy WebWork fan. If you find someone that still likes Struts, ask them if they've used WebWork. Chances are they'll say no. As far as Tapestry is concerned, the learning curve is too high. It's been rejected time and time again by my clients because of the learning curve. Are they going to fix this? Yep, they're going to re-write the whole damn thing - again! Every major point release of Tapestry throws backwards-compatibility out the window. Furthermore, I've heard once you get over the learning curve, it's a joy to work with. I've also met people at conferences that've used it over a year and say they're still struggling with its concepts.

Spring MVC - I wish I had bad things to say about it, but I don't. It (obviously) has the best Spring integration, but I've found WebWork much more pleasurable to work with. Sure, Spring has a ThrowawayController, but with a name like that, you can tell it's a second-class citizen.

Inspired by Tim's post, here's my prediction:

Struts Action 2 will be the best choice for developing Java-based web frameworks. Not only does it support JSF, but it's easy to learn, test and use. Furthermore, it seems to be the most often used framework in major software products and web sites.

How's that for a clear message? Struts Action 2 is the shiznit, now let's get back to developing applications.

Disclaimer: This is my opinion with a lot of stuff thrown in to get folks riled up. I've never put a JSF, Tapestry or Spring MVC application into production (except for AppFuse of course), so most of my opinions are likely without foundation. In wonder how many applications Mr. O'Brien has put into production with these frameworks?

Posted in Java at Jun 20 2006, 08:32:41 AM MDT 57 Comments