Matt RaibleMatt Raible is a Web Developer and Java Champion. 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.

Poor Open Source Developers

Richard seems to think that most open source developers are like starving artists:

While a few make really good money selling consulting and training and other services, the vast majority of open source developers don't make anything.

For some reason, I don't believe this. The open source projects I participate in, as well as the ones I admire and use - all seem to have developers that are gainfully employed and making money. Of course, this may just be a Java open source phenomenon.

To do open source, you have to have a day job. You can't expect open source to feed your family or even your cat for that matter. As I said there are exceptions, but most open source developers do it for the love of writing software. While commercial software developers do a great job of feeding their families, open source developers do a better job of feeding their minds. In the end, you have to ask yourself which is more important: The things you own or freedoms you have.

Very good points. I dig working on AppFuse, as well as Roller, Struts Menu, and the Display Tag because I can do whatever I want. I can implement silly features like Clickstream and I don't have to ask anyone if it's a good idea (I'm still debating this).

Back to my point though. I firmly believe that most Java Open Source Developers are gainfully employed and not starving artists. Part of this comes from the fact that most of the big projects I work with (i.e. Struts and Hibernate) have some smart folks on staff, and the popularity of their projects has provided them with more opportunity, hence they're employed.

Personally, I do open source because I want to learn. I want to write code that gets scrutinized by the masses. As an independent consultant, I rarely get another person looking at my code - so I turn to the community by opening my code (that I use on a daily basis) to other developers. Overall, having others look at my code has resulted in much higher quality software for my clients, and has helped me learn a lot in the process as well.

I also look at open source development as a good marketing campaign - here's what I can do, hire me. This has proved very successful so far. Hence, my formula: Open Source Development = good marketing = gainful employment.

Posted in Java at Jan 22 2004, 06:42:57 AM MST 4 Comments

Mock Shmocks!

Let me start this post by saying that I've never used Mock Objects in my JUnit tests. Simon digs it, crazybob is an advocate and so is the gang that wrote Open Source Programming. In fact, the OSP book says that your unit tests should only take a couple of seconds to run! A couple of seconds!? Mine aren't that fast, which definitely makes me think I should look at Mocks to try to speed things up.

However, there is a method to my madness. Almost all my tests depend on a database connection and use DBUnit to populate the database before running. This can be time consuming, but it's not too bad for what I'm getting: real tests that verify the environment, not just the code. I just ran all tests in the application - 8 minutes 7 seconds - for 165 JUnit/Cactus tests and ~25 WebTest (JSP) tests.

If I did use Mocks, I wouldn't have discovered all the bugs in my code this week. When migrating from MySQL to DB2, I found that some things worked on MySQL, but they didn't on DB2. I modified the code, doing some tweaks to make Hibernate happy, and voila - now everything works on DB2 and MySQL. Furthermore, all my errors occurred when running my app in the container, and when I used simple JUnit tests (on my Managers) to test the same logic, it worked.

Who knows, I'm definitely learning new stuff everyday. Maybe it's possible that Mocks could do all this, but testing the production environment seems pretty important to me.

Posted in Java at Jan 21 2004, 06:34:28 PM MST 5 Comments

Coldtags - I dig the product and the support

I noticed from reading JavaLobby's Weekly News that Coldtags has a new version:

Coldbeans Software announced the major new release of Coldtags suite. This suite provides 160+ custom JSP tags for common programming tasks faced by JSP developers. And now this suite includes custom tags similar to web controls in .NET framework.

Find out more here: http://www.servletsuite.com/jsp.htm

I currently use the Country tag and the State tag and they're awesome (simple, but still something I needed). One feature I'd like to see is XHTML compliance for these tags, so I send them an e-mail.

Any chance of making this (and statetag) XHTML compliant? It would basically involve allow assigning an "id" attribute ("style" would be great too) and changing SELECTED to selected="selected".

Lo and behold, I got a quick reply less than an hour later:

Hello Matt,

it will be done.

Best regards,
Coldbeans support

P.S. I would like to note that the wish list for any component is open. So, feel free to suggest new features/options etc. you or your clients need and we will add them to upcoming release. Your suggestions for new components are more than welcome also.

Sweet! Note the P.S. - send your suggestions if you have any.

One Hour Later: Both tags have been updated with new attributes, and it's now XHTML-compliant. ;-D

Posted in Java at Jan 21 2004, 08:39:56 AM MST 1 Comment

Velocity's DataSourceResourceLoader

In the current project I'm on, one of the major requirements is to have the ability to send job postings to job boards such as Monster.com, CareerBuilder.com, etc. - as well as local newspapers. When I first started this project, I went about contacting all of these advertisers and explained that we'd like to automate the process of talking to their system. I found that many of them preferred a simple e-mail with the job posting, but others wanted us to FTP a pre-formatted document to them.

I figure the easiest way to handle this is to use Velocity. By using Velocity, and storing templates in the database, users of the system can either (1) use a default template or (2) customize a template for a specific advertiser. This was all easy enough since we're using Struts Resume as a baseline for this project, and Velocity is already built-in.

I remembered seeing that Velocity had some sort of database ResourceLoader, so I went searching and found the DataSourceResourceLoader:

This loader will load resources from a DataSource such as a database. This loader is not built as part of the standard build as it requires J2EE support. To build this loader, please download the J2EE distribution, move the j2ee.jar into the build/lib directory, and then build the new velocity jar with the jar-j2ee build target. For more information on this loader, please see the javadoc for DataSourceResourceLoader.

After checking out Velocity 1.4.1 RC1 (are they ever going to release this thing?) from CVS, I was able to build a new Velocity JAR. To compile using J2EE 1.4, you have to modify the VelocityServletTest, or delete it. I then replaced velocity-1.4-rc1.jar with this new JAR (which is actually 4KB smaller), configured velocity.properties and Voila - it worked! Clean and easy integration - just the way I like it.

Posted in Java at Jan 21 2004, 06:28:50 AM MST 3 Comments

AppFuse vs. Spring

I received an interesting e-mail this morning. The writer said his team is comparing AppFuse and Spring in terms of kick starting a project. This struck me as odd, especially since these two applications are quite different. Here's my response:

I think AppFuse and Spring are two completely different animals. IMO, Spring is excellent for wiring components together (i.e. Interfaces and Implementations) as well as simplifying J2EE's APIs. Of course, it has its own web framework too, but it also integrates nicely with Struts, WebWork and Tapestry. AppFuse is designed to be an application that helps you get *up and running* with your J2EE web application in the minimal amount of time. Its power is in the directory structure, Ant integration (build.xml) and testability. Also, XDoclet is heavily leveraged for code generation and maximizing developer's productivity. In essence, it's really just a packaging of other open source projects, including: Ant, XDoclet, Hibernate, JUnit, Cactus, StrutsTestCase, Canoo's WebTest, Struts Menu, Display Tag Library, JSTL and Struts (including Validator and Tiles). But rather than just packaging these together, it's also got Security and User Management built-in and contains tutorials on how to develop and test the different layers.

Here are some links on integrating Spring with other Java-based web frameworks:

Struts: http://struts.sourceforge.net/struts-spring/
WebWork: http://wiki.opensymphony.com/space/Spring+Framework+Integration
Tapestry: http://www.springframework.org/docs/integration/tapestry.html

And here are a couple of good simple descriptions of Spring:

http://test.javaranch.com/wiki/view?SpringFramework
http://barracudamvc.org/lists/archives/barracuda/2003-December/007156.html

I do plan on integrating Spring into AppFuse in the next release - so it might be awhile until I release 1.4. I basically plan on using it to wire my Managers together, as well as my DAOs. Currently, I don't think I'll use its web framework, but who knows. In the latter half of this year, I hope to add support for WebWork and Tapestry as web frameworks.

Posted in Java at Jan 20 2004, 06:05:11 AM MST 2 Comments

Struts' MappingDispatchAction

I stumbed upon Struts' MappingDispatchAction this morning. It's basically the same thing as the LookupDispatchAction (which I use as my BaseAction in AppFuse), but you specify the method name in the action-mapping - rather than with request parameters (i.e. ?action=methodName). At first, this would seems tedious, but I usually end up creating a lot of action-mappings for a single action anyway, so this might be the way to go. There's really no need to change this in AppFuse now, but it is available in AppFuse's struts.jar (nightly from Dec 2, 2003).

In other news, the Open Source book is humming right along. I've finished the Hibernate, WebWork and Sitemesh chapters. I like what I see. IMO, this book is excellent for Hibernate, WebWork and Sitemesh newbies like me.

Posted in Java at Jan 20 2004, 05:38:43 AM MST 2 Comments

JavaBlogs really likes me...

JavaBlogs seems to really like my RSS feed - I keep showing up on the main page twice. This means that something is probably wrong with my feed, so I've done the right thing and disabled my Java feed for the time being. I'll add it in when I rev to the next Roller version - which will hopefully only be a week or two. I'll leave this in the Java category to see if it shows up over there. If so, I guess I'll have to delete the feed entirely instead of just disabling it.

Posted in Java at Jan 19 2004, 03:15:19 PM MST 2 Comments

How blogging has helped me this morning

My early-morning blog reading comes through once again. First off, Charles explains how I should implement Remember Me. If understand him correctly, I basically need to create a new table (i.e. user_cookie) that has two columns: username and cookie_id - where cookie_id is a random 128 bit number. The key to his strategy is replacing the number with a new one everytime the user logs in. Why didn't I think of that? Thanks Charles!

Secondly, this Tweaking MySQL Primer (via Erik) has some good tips on MySQL. I'd prefer a more generic "tweak your database" howto that covered many databases, but this will have to do for now. I'm going to try a little OPTIMIZE tablename on this site in a few - it's it's down all morning, now you know why...

Lastly, what the hell are Erik and Rick Ross cooking up?

I spent five hours on the phone with Rick Ross (of Javalobby) on Saturday afternoon. I think we effectively fixed everything that is wrong in the world. Stay tunned. ;-)

WTF? 5 hours on the phone? I don't think I've spent 5 hours on the phone with anyone in my entire life. It must be good - or they're not very good communicators... ;-)

Posted in Java at Jan 19 2004, 07:55:51 AM MST 2 Comments

RE: AppFuse (Getting started with...)

Rick Hightower has started using AppFuse. It looks like he had a couple of issues, so I figured I'd post some solutions here for all to see (also because typing in comments w/o HTML on JRoller sucks).

Rick - I don't know why you're getting the first error with CATALINA_HOME. I just tried removing that as an environment variable on my PowerBook and I'm able to run "ant setup-db" just fine. If you've setup the MySQL database with the default settings, you should end up with a "root" user and a blank password. These settings are both specified in properties.xml, where database.admin.username=root and database.admin.username=(nothing). Of course, you can change these properties values by editing properties.xml, or by specifying them in your build.properties file. From the following error on your site:

db-load:

BUILD FAILED
C:\source\appfuse\build.xml:931: java.sql.SQLException: Invalid authorization sp
ecification,  message from server: "Access denied for user: 'rick@localhost' (Us
ing password: YES)"

It looks like you have an administrator named "rick", but that your password was incorrect. YES is not the password you provided - that's just MySQL saying that you did provide a password.

The database creation script is at metadata/sql/mysql-create.sql and it simply creates an "appfuse" database and gives a user named "test" access to it.

create database if not exists appfuse;
grant all privileges on appfuse.* to test@"%" identified by "test";
grant all privileges on appfuse.* to test@localhost identified by "test";

The next error about j2ee.jar should be self explanatory and it looks like you figured that one out. I wish I didn't have to include the entire j2ee.jar in the classpath, but XDoclet requires javax.ejb.* JARs be in the classpath for generating Struts ActionForms from POJOs.

The last thing you did - ant -Dapp.name=sampleApp -Ddb.name=database - was to merely run the "package-web" target. It's the default target in build.xml. It simply compiles everything and packages into an appfuse-1.3.war file. In this scenario, the app.name and db.name mean nothing. If you want to create a new AppFuse project, you need to specify the new target. This will create a new project.

foxxy:~/dev/appfuse mraible$ ant new -Dapp.name=test -Ddb.name=test
Buildfile: build.xml

clean:
     [echo] Cleaning build and distribution directories
   [delete] Deleting directory /Users/mraible/workspace/appfuse/build
   [delete] Deleting directory /Users/mraible/workspace/appfuse/dist
   [delete] Deleting: /Users/mraible/workspace/appfuse/database.properties

new:
     [echo] Creating new application named 'test'...
     [copy] Copying 318 files to /Users/mraible/workspace/test
     [copy] Copying 1 file to /Users/mraible/workspace/test

BUILD SUCCESSFUL
Total time: 21 seconds

I just tried this, followed by the commands specified below and all seems to be working just fine (BUILD SUCCESSFUL - Total time: 5 minutes 13 seconds).

cd ../test
ant setup-db
ant setup-tomcat
ant test-all

Just to be clear, here's a breakdown of what the above targets do:

  • setup-db: creates a database for the project, assigns users, creates all the tables and populates it with test data.
  • setup-tomcat: copies a context.xml file to $CATALINA_HOME/webapps and copies the database driver to CATALINA_HOME/common/lib.
  • test-all: runs all the tests to verify the functionality of the app. These include test-ejb for the DAO layer, test-canoo for all the JSPs and test-web for all the StrutsTestCase/Cactus tests and business layer tests (*ManagerTest).

The first steps after creating a new AppFuse project are probably to rename the packages to fit your company's naming convention - i.e. org.appfuse -> com.company.appname. In Eclipse (and propably IDEA), this is fairly easy. Just make sure to do it in the "src" and "test" directories, as well as search for it - it might be specified in a few XML files (i.e. hibernate.cfg.xml). You'll also need to modify the "javadoc" target to ensure that it looks for the write package names. Currently, it's set to "org.*".

Hope this helps!

Posted in Java at Jan 19 2004, 05:55:25 AM MST 1 Comment

Simon must be a smooth talker

Simon must be a smooth talker to get an instance of JIRA for Pebble. Why? Because I asked Mike for a JIRA instance for the DisplayTag and he replied "negatory - your project is too small." This was a few months ago, but if you compare the statistics between Pebble and DisplayTag - it's obvious that Pebble is much smaller than the DisplayTag. Maybe I should take some smooth talking lessons from Simon? ;-)

Posted in Java at Jan 18 2004, 09:32:44 PM MST 3 Comments