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 "java". 1,588 entries found.

You can also try this same search on Google.

Servlet 2.4 Specification

Damn, according to The Server-Side, the new XSD syntax for a web application's deployment descriptor (web.xml) has been removed. Or at least that's how I first read it. That would suck, only because it's one of the things I noted as a difference between 2.3 and 2.4. Where did I note it - in the chapters I wrote for Wrox. Doh - get those chapters back from the printing presses!

Posted in Java at Mar 09 2003, 08:44:10 PM MST Add a Comment

Hibernate Enhancements

For you Hibernate users/lovers, here's some good news for you (THANKS GAVIN!):

1. [Hibernate Forum] For XDoclet users its well-worth grabbing a CVS update now, I have fixed a bunch of issues and made improvements including Hibernate2 support (thanks to Matt Raible) and joined-subclass support.

2. [Hibernate Dev List]

 After a bit of research and thinking, I have settled on an approach to
 query by Criteria that hopefully is flexible enough for 80-90% of use
 cases, but still simple enough to fit in sufficiently few lines of code.
 
 The proposed new API is based loosely upon the Cayenne API. Queries may be
 expressed as follows:
 
 
 List cats = session.createCriteria(Cat.class)
     .add( Expression.like("name", "Izi%" ) )
     .add( Expression.between("weight", minWeight, maxWeight) )
     .add( Expression.eq( "mate", mate ) )
     .addOrder( Order.asc("age") )
     .setMaxResults(20)
     .list();
 
 
 Which is approximately equivalent to:
 
 from Cat cat
 where cat.name like 'Izi%'
 and cat.weight between :minWeight and :maxWeight
 and cat.mate = :mate
 order by cat.age
 
 
 This API is marked "experimental", but I would like to stabilize it fairly
 soon, so early feedback is very welcome. This is all in CVS.

Posted in Java at Mar 09 2003, 09:56:16 AM MST 3 Comments

Exceptions and Amazon.com

The March issue of Java Developers Journal has a great article on anti-patterns concerning exceptions (not published online yet). After reading it, I can see I need to improve my exception handling, as I'm tossing a DAOException in my database layer, and a plain ol' Exception in my services layer. Since all my services layer does is convert object types -> strings (and executing business rules), I should probably change it to throw a generic BusinessException and a ConversionException. Too bad there's no link, hopefully soon.

In other news, we stopped by Barnes and Nobles for a Starbucks today. While there, I noticed a book my sister gave me for Christmas and I said to Julie, "I should read that sucker while you're gone next week." She sheepishly admitted that she'd sold it on Amazon a few weeks ago! Since it was a gift (from my sister), and I really do want to read it, I decided to buy it. The line was long and slow, so rather than buying it there, I used my phone and bought it online from Amazon. I searched, selected, logged in and I was done. They had a great message after logging in:

Yes, it really was that easy. Your order will be shipped to your one-click address.

Fricken sweet! The Internet Rocks and it's only gonna get better...

Posted in Java at Mar 08 2003, 09:18:48 PM MST Add a Comment

RE: Debugging JUnit tests in Eclipse - how?

James provided me with the answer I was looking for this morning - use Run >> Debug As >> JUnit Test. Cool - it worked! I had to add a few additional JAR files to my project's classpath to make it run a test succesfully - but I'm stoked that it's working! A comment I left on James's weblog might interest you:

I don't *need* Ant to run JUnit tests, but as strange as this may sound - it's the only way I've ever done it. In fact, I've hardly written or run *any* Java classes with a main() method. ;-)

Crazy, huh? I guess that's what happens when you start out writing JSPs and Servlets vs. command-line or Swing apps.

Posted in Java at Mar 08 2003, 10:47:40 AM MST 1 Comment

Struts Training: Week 2

I'm planning on attending today's Struts training and will be reporting here again. I got up at 6, hoping to do the labs and discovered the first step was downloading the latest Basic Portal setup. Since it's 200 MB, I've been dicking around for the last hour and a half, waiting for it to download. Yikes - I thought struts-resume was bad at 10.5 MB! I guess the difference is that it includes JRockit, Mozilla, OpenOffice, Vim, Ant, Eclipse, JMeter, Jikes, PostgreSQL and Resin.

Today's session seems to be covering databases, SQL and database performance. Vic mentions that 90% of performance is in the data model design. If you can fit your database on a laptop, then performance will probably not be an issue. I agree with this. I did the first lab during the first half-hour of the preso. Pretty simple stuff: creating HTML files and accessing them through a browser. This is probably a good lab to get everyone going and stuff installed. Also proves that Resin is running. Of course, it took me two hours to complete this lab, including the download, so I guess it's not that short!

Commons SQL is a new version of Torque (a manual persistence layer). Vic uses RowSets a lot, has one site with 40,000 concurrent Struts users with sub-second response times. He attributes this to rowsets. He says, "To create high-scalable applications, you need to know SQL and use things like RowSet, Ibatis.com, Commons SQL and Scaffolding." I tend to disagree - I think that EJBs (and possibly Hibernate) are your best bet for highly scalable application (i.e. 10,000+ hits per second). If your EJBs are slow, it's probably your code or your appserver. Try EJBs on JBoss and I'm betting you will be pleased. Then again, I've never created a highly-scalable application, and Vic has, so I'm not much of an authority. He, he - he mentions that Castor has lost a lot of mindshare; "Great for development, but not very scalable in production." So true - or at least Roller seems to prove this. From the folks he's talked to, Vic says that TopLink has a horrible reputation.

Hmmmm, interesting. Vic puts all the database connections and CRUD in his ValidatorForms. This is not saying that his bean matches his database tables. I don't know that I'd recommend this, but it certainly might simplify things. However, personally, I'm more comfortable with keeping my POJOs and ActionForms pretty dumb (just getters and setters). He has a DAO that handles CRUD and population of the bean. I wonder where you'd put the business rules in this implementation? In the DAO? If it's in the DAO, what if you have to write a new DAO implementation. For instance, if we used this approach on Roller, we'd have to re-write our business rules for Hibernate and Castor. Ugh.

For testing, he puts a test() method on his beans and uses a Servlet or a plain class with a main() method. Personally, I'd recommend using JUnit and JUnitDoclet (and Ant) to generate and run your unit tests. It's much easier than writing a servlet to test - and can easily separate your tests from your real code. See struts-resume for examples. I'll be releasing AppFuse in the next couple of weeks. This (hopefully) will provide a nice starting point for creating web applications. In reality, if no one uses it, I'll probably be better off (less support). It's been working great for me on my current project and has easily saved us a month of startup time. Right now, appfuse == struts-resume.

Vic mentions using a BaseAction that dispatches to the appropriate method in your subclasses. He says that the only difference between this technique and DispatchAction (or LookupDispatchAction) is you can specify a default method. Here's a tip: use the unspecified method. Here's how to make your edit() method the default:

public ActionForward unspecified(ActionMapping mapping, ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
throws Exception 
{
    return edit(mapping, form, request, response);
}

Vic hints that the next iteration of Basic Portal will be written to use the iBATIS Database Layer and MySQL. Interesting, I thought iBATIS was a company, but nope: it's from the author (Clinton Begin) of JPetstore. On most days, I'd recommend Hibernate here, but I've spent the last 3 days wrestling like mad with it, so I won't. Of course, after leaving work last night, I think I might've figured out the problem. My brain is likely to blame more so than Hibernate.

Ted Husted chimed in at the end and mentioned that he is going to touch on Hibernate next week. Cool!

Posted in Java at Mar 08 2003, 08:13:11 AM MST 4 Comments

Resin plugin for Eclipse

Since I'm starting to learn more about Resin, I went searching for a Resin Plugin for Eclipse. I found ResinLauncher at improve-technologies.com. Trying it now with Resin 3.0.0 Beta.

Update: That plugin sucks, and I couldn't find any from my favorite plugins site that just worked. Maybe with a little more effort, but I don't have the patience. If anyone knows of a plugin that works as nice as the Tomcat Launcher, let me know. I think the Tomcat one b/c I don't really have to setup my project to be a "Tomcat Project", but rather I can simply run Tomcat in Eclipse and set breakpoints and such.

Posted in Java at Mar 08 2003, 07:19:33 AM MST 2 Comments

How do I remove duplicates in a List?

I have a List that may contain duplicates and I need to filter out the duplicates (so I don't get a foreign key violation when inserting records). Are there any Jakarta' Commons utilities to do this? I can see a few solutions to my problem:

  • Present it on the UI. This might be tough since I'm using a select box JavaScript library. Hmmm, I am using a custom setter for the String[] that gets sent in, maybe I can do it there - checking to see if the ArrayList I'm setting already contains the given String.
  • Filter it out in the business layer.
  • Use a type of List that doesn't allow duplicates, and just ignores a duplicate value when you try to add it.

I just thought of #1 while writing this post. It's cool how talking about your problems can help solve them - no wonder shrinks get paid so much. I'm still interested in any proposed utility classes.

Posted in Java at Mar 08 2003, 07:15:42 AM MST 5 Comments

Struts-JSF Demo

I've setup another demo - this time it's the struts-example app ported to use JSF and Struts. Nothing ground breaking here that I can tell, and after looking at the code, I don't know what to think of JSF. It seems to make it much harder to code a JSP page.

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="s" uri="http://jakarta.apache.org/struts/tags-faces" %>

<f:use_faces>
<s:html locale="true">
<head>
  <title><
    <s:message key="registration.title.edit"/>
    </title>
  <s:base/>
  <s:stylesheet path="/stylesheet.css"/>
</head>
<body bgcolor="white">

<s:errors/>

<s:form action="/saveRegistration" focus="username"
         onsubmit="return validateRegistrationForm(this);">

  <h:input_hidden id="action" modelReference="registrationForm.action"/>

  <h:panel_grid
           columns="2"
        panelClass="form-background"
       headerClass="form-header"
     columnClasses="form-prompt,form-field">
.
.
.

Ugh, a whole new set of Tag Libraries to learn? Seems like JSF is a lot of bloat, while JSP 2.0 has been made things simpler. One interesting thing is the use of the single-letter (i.e. "h", "s") for the tag libraries. I suggested this a while ago on the struts-dev list, and it looks like it's been implemented. Bravo! I doubt I'm the reason for it, but it's always nice to see your ideas implemented.

I apologize that this site was down most of the day today. It seems that the monitoring/restarting scripts were not running and this should/will be fixed shortly. I need a gig where I can restart this site when it goes down. Anyone know of a way to telnet/ssh via an HTTP Proxy?

Posted in Java at Mar 07 2003, 03:38:29 PM MST 1 Comment

Debugging JUnit tests in Eclipse - how?

Does anyone know how to run JUnit tests using Ant and debug them in Eclipse? I have the JUnit/Ant part figured out, it's the debugging I'm having issues with. I'm able to run debug (using breakpoints) in Eclipse while running Tomcat, but not while running a simple JUnit test from Ant. Man that would be cool. If I could run Ant (from w/in Eclipse or on the command line) and set breakpoints in Eclipse - I could sure speed up my development time.

Posted in Java at Mar 07 2003, 09:15:09 AM MST 3 Comments

[ANNOUNCE] Struts-JavaServer Faces Integration Library -- Early Access Version Now Available

I'm happy to announce the immediate availability of an integration library
that allows you to use the recently published EA3 release of JavaServer
Faces with a recent Struts build (nightly build 20030216 or later, or 
the upcoming 1.1-rc2 or finalrelease).  Nightly builds of this package are 
available at:

 http://jakarta.apache.org/builds/jakarta-struts/nightly/struts-faces/

The sources for this package are in the  "contrib/struts-faces"
subdirectory of the  "jakarta-struts" CVS repository.

You should take note of the following important points:

* The design goal of this library was to allow Struts application
 developers to migrate the view tier of their applications from the
 existing Struts tags, to pages that use corresponding JavaServer Faces
 component tags, with no changes to the corresponding business logic.
 This goal has been substantially achieved for simple applications
 so far; additional work will be necessary for more advanced apps.
 As a proof of concept, the JavaServer Faces based version of the
 canonical  "struts-example" web application is included in the
 distribution, so that you can see for yourself how little had to be
 changed.

* The integration library has been tested under Tomcat 4.1.18 and
 the Java Web Services Developer Pack (version 1.0_01), although in
 principle it should run on any Servlet 2.3/JSP 1.2 container.
 (It will not run on Servlet 2.2/JSP 1.1 containers).

* There is a known issue when trying to run JavaServer Faces EA3
 under the recently released Java Web Services Developer Pack
 (version 1.1).  Watch the JavaServer Faces web page (at the URL
 listed above) for up-to-date information on workarounds.

* The JavaServer Faces distribution is an EA release, not suitable for
 use in production environments.  In addition, the license terms
 under which it can be downloaded prohibit redistribution.  Therefore,
 you will need to download your own copy of JavaServer Faces EA3 and
 integrate it with the example application before it can be deployed.

* The integration library should also be considered to be of alpha
 quality, not suitable for production use.  There are a set of known
 issues and limitations at the bottom of the README.txt file.  Please
 file bugs against this package in the usual Bugzilla location:

   http://nagoya.apache.org/bugzilla/

* For generic questions about JavaServer Faces (i.e. not related to this
 integration library), your best resource is the JavaServer Faces forum
 (free registration required) at:

   http://forum.java.sun.com/forum.jsp?forum=427

See the README.txt file in the top-level subdirectory for more information
about installing and using this release.

Craig McClanahan

Posted in Java at Mar 06 2003, 09:29:06 PM MST Add a Comment