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.

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

[Review] J2EE Design and Development

I finished reading Rod Johnson's J2EE Design and Development today. 700 pages took me a little over 2 weeks to knock out. This book is definitely targeted at experienced J2EE developers, which is nice. I tried to do the same with my Struts chapter in Pro JSP and I wish books would do more of it. However, the problem with targeting a more experienced audience is you lose a lot of potential buyers. Rod is definitely one sharp fellow and it shows throughout this book. Either that, or he's just got a lot of experience working with the J2EE stack in his career.

The framework described in this book eventually became Spring - and it's really just a culmination of all the things that Rod has used on his previous projects. In that respect, it's similar to AppFuse, which I created to assist me with my Java webapp projects. Like Spring, AppFuse contains all my learnings and choices over the last couple of years. Just to be clear, I don't mean to imply that AppFuse is anything close to Spring as far as functionality - but I do believe they're similar in their goals. Spring is designed to make J2EE easier, while AppFuse is designed to make project setup and testing easier. Hopefully, when I start using some Spring features in AppFuse, developing with AppFuse will become even simpler.

Back to the book. I found the first few chapters somewhat boring since they covered a lot of the stuff I already knew about J2EE applications. The middle part of the book was on Spring's simplified JDBC approach and it also covered EJBs. I tend to shy away from writing JDBC these days, especially since Hibernate suits my needs so nicely. If I'm working with an existing database and there's a lot of SQL code already, I'll use iBatis. And EJBs, blech - I've never had a need for them. Admittedly, a lot of my projects are small and don't require container-managed transactions. I've also heard rumors of CMT being a part of Spring - so who knows if there's any good argument for EJBs anymore. Anyway, I found the middle part of the book quite boring as well since I don't much care about JDBC or EJB.

The last part of the book, however, peaked my interest. It discussed MVC design, View Technologies (i.e. JSP, Velocity, XSLT, XMLC, PDF) and basically a lot of stuff related to the web tier. In this area, I was most impressed with XMLC, which allows you to write HTML pages - then use Java to manipulate it's contents. Very slick stuff for having a static prototype that also serves as the code for your app. I don't see myself switching from JSP to XMLC, but I dig the option. In the Performance Testing and Tuning chapter - great examples where given and seemingly real-world optimizations where made. This chapter could prove to be a handy reference for enhancing performance with simple caching.

Overall, I thought this was a great book, although a bit heavy on the EJB stuff for me. Now I'm motivated to learn more about Spring. In the process, hopefully I'll figure out how it makes iBatis and Hibernate easier to work with (links are most welcome). Next up is Java Open Source Programming(500 pages), which I expect to take another two weeks to polish off.

Posted in Java at Jan 18 2004, 01:38:52 PM MST 6 Comments

Alternative web frameworks for AppFuse

I've was thinking about the AppFuse Roadmap for a bit today - and it hit me. The hardest part of supporting frameworks like WebWork and Tapestry is going to be replacing the Struts features I'm confortable with. For WebWork, it should be fairly easy to replace Tiles with SiteMesh, but for Tapestry - does a templating framework even exist? Other things that might be hard to implement in Tapestry are the DisplayTag (although Erik Hatcher did mention it's easy to implement in Tapestry) and Struts Menu. I imagine doing something like implementing a menu with CSS/JavaScript isn't too hard in Tapesty - but can it be configured from an XML file and a Velocity template? Implementing these components into WebWork should be easy since it supports JSP, but Tapesty is a whole different animal. I've also heard that JSF already has a grid component - and the struts-faces library should allow me to use Struts Menu easily with JSF.

I guess the good news in all of this is that I will discover if this stuff is possible or not - instead of just wondering. If you do happen to know the answers off the top of your head - please let me know. The real question is - after all of this - which framework will I choose as my favorite. Stick around and read about my journey into these other frameworks from the perspective of a hardcore Struts developer and enthusiast. I don't plan on trying to prove that Struts is better - I just want to find the beauty of these other frameworks and report if it's all hype or actually true.

Posted in Java at Jan 17 2004, 09:24:47 PM MST 5 Comments

Win2VNC is very cool

I got the tip from Crazy Bob and decided to try it tonight. Win2VNC basically allows you to connect to a server (via VNC) and you can simply move your mouse onto that VNC-ed machine and voila - your mouse and keyboard are on that monitor. It's almost too cool to describe. The only issues I found where that it doesn't work well with multiple monitors. I have two monitors plugged into my XP desktop, and if I choose "West" as my direction (to switch to my PowerBooks monitor), then that works, but I can't get it onto my primary monitor - it only shows up on the 2nd monitor. The issue is better described on the user forums. The easy workaround is to go "North" to switch monitors. The other annoying bugs are no mouse wheel support and no Alt+Esc support. This thread has a few patches for this. The first patch I tried seems to work the best, with both Alt+Esc and wheel support. This other one has an installer, but Alt+Esc didn't work for me.

If you have a laptop sitting next to a desktop - you've got to try this software - it's what you've always wanted.

Posted in Mac OS X at Jan 16 2004, 08:38:46 PM MST 5 Comments