David R. Heffelfinger
Spring to Java EE Migration, Part 2
Part 2 of my Spring to Java EE migration series has been published.
This part of the article shows off NetBeans Java EE capabilities, such as automatically generating JSF pages, JSF managed beans and Data Access Objects (DAO's) implemented as EJB session Beans.
Posted at 06:57AM Dec 17, 2011 by David R. Heffelfinger in Java | Comments[1]
New Spring to Java EE Migration Article Series
For the past few weeks I've been working on a new article series for the Oracle Technology Network. The topic of the series is Spring to Java EE migration using the NetBeans IDE.
Part 1 of the series was just published. In this part we begin migrating Spring's sample Pet Clinic application to standard Java EE APIs such as JavaServer Faces (JSF) and the Java Persistence API (JPA), while showcasing time saving NetBeans features such as JPA entity generation.
Posted at 06:41AM Nov 02, 2011 by David R. Heffelfinger in NetBeans | Comments[4]
Ordered a Sony Xperia Play from Amazon
Amazon has a deal going on for the Sony Xperia Play for one cent ($0.01) with a two year contract with Verizon Wireless.
I was already with Verizon and fairly happy with them, and my old Motorola Droid was starting to show it's age (the power button sometimes doesn't work, I have to press it multiple times to turn the phone on or off), so I decided to give it a go.
For those that don't know, the Xperia Play is the so called "Playstation Phone", that has a built in game pad and several exclusive titles. The XPeria play also has stock Android 2.3 (Gingerbread). I'm not a fan of Android skins like Sense UI and others, since having those skins make the phones harder to upgrade for the manufacturer, since they have to update their skins for every new version of Android.
As far as the Sony Xperia Play goes, I am primarily interested in getting a Stock Android Gingerbread device for 1 cent, plus it is a nice hardware upgrade for me. The fact that it has a built in gamepad and exclusive games is just gravy, at least it will give me something to do during my daily bus and train commute.
Posted at 09:04AM Sep 04, 2011 by David R. Heffelfinger in General |
Kevin Mitnick's "Ghost in the Wires"
I just finished reading Kevin Mitnick's new book, Ghost in the Wires, on my Kindle.
I remember learning about Mitnick by reading about him on Slashdot via the "Free Kevin" movement several years ago.
Mitnick's life story is quite interesting, and the book is full of several interesting anecdotes.
He explains how he was able to figure out a way to travel for free on the bus as a kid; illustrating how he had an ability for social engineering from a young age.
Mitnick then goes on to tell the story explaining how some friends from high school introduced him to phone phreaking, making long distance phone calls for free.
He also tells a story on how he was able to defeat the security of the computer systems in the college he was attending, and how his professors asked him to secure the system as an "honors project" or face expulsion.
The book is full of several stories detailing how he was able to break into several computer systems, steal cell phone service, monitor phone calls (including FBI lines), obtain new identities and other clever and "less than legal" activities. Mitnick had an ability for social engineering, that is, he could easily dupe people into giving him information that he shouldn't have. He would call companies and pretend to be a coworker or customer, and more often than not he could convince the other person on the line to do something for him or provide some confidential information, including usernames and passwords.
All in all, Ghost in the Wires is a very interesting read, and very much worth it for anybody interested in computers or security.
Posted at 07:07PM Sep 01, 2011 by David R. Heffelfinger in General |
James Gosling, Father of Java, Leaves Google
A while back, there were news all over the blogosphere about James
Gosling, father of Java, leaving Oracle shortly after the database giant
bought Sun Microsystems.
Gosling was unemployed for a while, but in March 2011, he went to work for Google. Today he published a new blog entry, announcing that he left Google to join a company called Liquid Robotics, a company that makes an unmanned ocean vehicle called the Wave Glider.
I'm
surprised that Mr. Gosling decided to leave Google after less than six
months of employment; nevertheless I wish him the best of luck in his
new endeavors. I'm sure Liquid Robotics will benefit greatly from the
positive public relations of having the father of Java join their
company, and I'm sure they are hoping his tenure will be longer than the
one he had at Google.
Posted at 06:51PM Aug 31, 2011 by David R. Heffelfinger in Java |
Java EE 6 Development With NetBeans 7
A new edition of my NetBeans book has recently been published by Packt Publishing.
The book covers NetBeans 7's support for all major Java EE 6 APIs,
including JSF 2.0, EJB 3.1, JPA 2.0, CDI 1.0 and Servlets 3.0. The book
also covers NetBeans support for PrimeFaces, a very popular high quality
JSF 2.0 component library.
Development of web applications taking advantage of new Servlet 3.0 and JSF 2.0 features is covered. New
JSF 2.0 features such as XML-less configuration, project stages, new
JSF 2.0 conventions, resource directories, Facelets templating
(including predefined templates included with NetBeans) are covered as
well. The book also explains how NetBeans can help application
developers build JSF 2.0 components using markup only, without having to
develop any Java code.
The book explains how to develop sophisticated JSF 2.0 applications with PrimeFaces.
New EJB 3.1 features such as the new EJB timer service are covered.
The book also covers NetBeans 7 support for JPA 2.0, including the new
Criteria API, and how to use NetBeans to automatically generate JPA code
from existing databases; as well as generating complete Java EE CRUD
applications from an existing database schema.
Contexts and Dependency Injection (CDI) is covered as well, including coverage of CDI
named beans, scopes, CDI Qualifiers, Stereotypes and Interceptor
Binding Types are covered as well.
After finishing the book, readers not only will be well versed in the latest Java EE technologies,
but they will also be able to take advantage of NetBeans 7
functionality that allows developing Java EE applications in record
time.
Posted at 07:03PM Jun 29, 2011 by David R. Heffelfinger in NetBeans | Comments[1]
Reports of Java's Demise Have Been Greatly Exaggerated
It seems like every other day a new article or blog post comes out declaring Java as a dead language. Every time I read one of these articles, I scratch my head in confusion. Are these people serious? If Java is so dead then why is there so much demand for it?
What does it mean for a language to be dead anyway? Is it that there is no demand for programmers with expertise in the language? If this is the case, then Java is definitely not dead since I routinely get emails out of the blue from companies looking for Java developers. I have been doing contract work since the late 1990's, and I move from one project to the next with ease, in most cases I have several offers before my current project is over. Therefore in this sense, Java is not dead.
Is a programming language dead if it's not evolving? If that's the case Java is certainly not dead. JDK 7 is just around the corner, and there are so many Java libraries out there, which release new versions periodically. Java is still very much evolving and improving, therefore in this sense Java is definitely not dead.
I can't think of any other reason why a programming language may be considered "dead", other than lack of demand for expertise or lack of evolution, therefore I'm pretty certain that Java is very much alive and well.
Perhaps the bloggers and reporters declaring Java's demise are actually doing us Java developers a favor, the less Java developers out there, the less competition for Java projects, which would in turn increase the demand (and billing rate) of us Java programmers. Keep stating that Java is dead folks, me, my colleagues (and our bank accounts) will thank you.
Posted at 07:15PM Mar 16, 2011 by David R. Heffelfinger in Java | Comments[5]
GlassFish Book Giveaway Winners
Over the last few weeks, we have been having a giveaway for my latest book, Java EE 6 with GlassFish Application Server.
The giveaway is now over, and we have randomly selected three winners.

Without further ado, here are the winners:
Congratulations to all the winners!
Obtaining a copy of the book
If you would like a copy of the book and you are not one of our lucky winners, I encourage you to purchase it directly from Packt Publishing.
Thanks to everybody that participated and congratulations once again to our winners!
Posted at 12:00AM Sep 10, 2010 by David R. Heffelfinger in GlassFish | Comments[1]
Win a Free Copy of Java EE 6 with GlassFish 3 Application Server
As some of you know, my latest book, Java EE 6 with GlassFish Application Server, was recently published by Packt Publishing.
Packt Publishing was kind enough to offer me three copies of the book to give away.
About the Book
The book covers all aspects of Java EE 6 development using GlassFish 3, some of the topics include:
- JavaServer Faces (JSF) 2.0
- Java Persistence API (JPA) 2.0
- Enterprise JavaBeans (EJB) 3.1
- Contexts and Dependency Injection (CDI) 1.0
- Java API for RESTful Web Services (JAX-RS) 1.1
- Java API for XML Web Services (JAX-WS) 2.1
- Servlet 3.0
How to Enter for a Chance to Win
All you have to do is answer one (or both) of the following questions in a comment below:
- What would you like to learn from the book?
- Why would you like to win a copy of the book?
If you prefer a certain book format and you are a USA or Europe resident, please note that in your comment as well, and we'll do our best to accommodate you (paperbacks are only available for USA and Europe residents).
Giveaway Details
The duration of this giveaway is 20 days. The giveaway ends on Monday, September 6th, 2010 after which comments will be disabled on this post.
Three winners will be randomly selected to win a copy of Java EE with GlassFish 3 application Server, authored by David Heffelfinger (yours truly) and published by Packt Publishing. Make sure you use a valid email address in the comments so that we can contact you if you win. Winners will be announced on Friday, September 10th, 2010 and also contacted via email. Good luck!
Update: The giveaway is now over. Thanks to all that participated. Winners will be announced this Friday, September 10th.
Posted at 12:00AM Aug 17, 2010 by David R. Heffelfinger in GlassFish | Comments[22]
Groovy Script to find Java classes in JAR files
We've all been there at some point or another. We just inherited a big pile of legacy Java code that we need to maintain. This code likely is using some big convoluted ANT script to be built. This being legacy code, it does not use a dependency manager like Ivy or the one included with Maven.
We, of course, want to be able to build using our favorite Java IDE, be it Eclipse, NetBeans or IntelliJ IDEA. Our Java IDE, of course, has no idea of what our project dependencies are, therefore our code is riddled with squiggly red lines due to missing dependencies all over. We are going to manually add dependencies to our project, oh joy. In many cases, these dependencies are scattered across multiple directories, we may have to inspect the contents of most of our JAR files to find many of our dependencies, especially those built in-house.
I was recently in this situation myself, to ease my pain, I came up with a Groovy script that recursively inspects every JAR file in the current directory and every subdirectory. It takes a single parameter, the name of the class to look for (case sensitive), then recursively checks every JAR file in the current directory all subdirectories. It's only requirement is that the "jar" executable be in the PATH, which should be the case for most Java programmers anyway.
Without further ado, here is the script. Enjoy
#!/usr/bin/env groovy
def cDir = new File(".");
def jarContents;
cDir.eachFileRecurse{file ->
if (file.name =~ /.*\.jar$/)
{
jarContents = "jar tvf ${file}".execute().text;
jarContents.eachLine{line ->
if (line.contains(args[0])){
print "*** found in ${file.canonicalPath}:";
println line;
}
}
}
}
Posted at 10:48AM Feb 13, 2010 by David R. Heffelfinger in Groovy | Comments[4]
Groovy Script to SFTP files using AntBuilder and Grapes
Recently I needed to write a Groovy script to SFTP a file to a server. With a little bit of googling, I came to the conclusion that the easiest way to do that was to use AntBuilder ANT's scp task.
Since this script is going to be used by several people, I wanted to use groovy Grapes to pull the dependency automatically.
Turns out that AntBuilder doesn't see dependencies pulled with the Grab annotation, after a little bit of some more googling I found the solution. Instead of using the @Grab annotation, use the static grab() method of the Grape class to pull the dependencies, this allows us to specify that we need the rootLoader as the class loader, which AntBuilder can see.
Without further ado, here is the script in it's entirety for your copying and pasting pleasure:
#!/usr/bin/env groovy
import groovy.grape.Grape;
Grape.grab(group:"ant", module:"ant-jsch", version:"1.6.5", classLoader:this.class.classLoader.rootLoader)
Grape.grab(group:"com.jcraft", module:"jsch", version:"0.1.42", classLoader:this.class.classLoader.rootLoader)
def ant = new AntBuilder();
def pw;
print "password: ";
//the following line does not work under Cygwin, System.console() returns null
pw = System.console().readPassword();
def pwStr = new String(pw);
ant.scp(trust:'true',file:"/path/to/file.txt",
todir:"user@host:/home/user",
password:"${pwStr}",verbose:"true");
Posted at 10:33PM Feb 02, 2010 by David R. Heffelfinger in Groovy |
PDF Unlock Utility Tutorials in Youtube
Lately I've been noticing some referrals from YouTube in my server logs. Curious about it, I looked into it and turns out there is not one, but two video tutorials explaining how to use my free online PDF unlock utility, both of them in Spanish.
Posted at 08:36PM Oct 08, 2009 by David R. Heffelfinger in General |
Ogling Android Phones
I'm a long time BlackBerry user, however for a while I've been tempted by the Android platform. The openness of the platform seems very attractive to me.
The other day I went to the T-Mobile store to try the MyTouch 3G, unfortunately I wasn't very impressed with it. The problem I had was with the virtual keyboard, the wrong letters would show up when I pressed most keys. I looked around online to see if this was a common complaint about the device, and couldn't find much about it. Maybe the unit I tried at the T-Mobile store was defective. Nevertheless, I figured the MyTouch's virtual keyboard would be a recipe for frustration, so I stuck to my BlackBerry Bold for the time being.
Browsing around the web I learned that Sprint will get two new Android phones soon. The HTC Hero, which got a glowing review from ZDNet is coming out this Sunday, October 1st. Based on the review I got really tempted to get one.
While doing some more research I also found out that another Android phone, the Samsung Moment will be released on November 1st, three weeks after the Hero.
I've been researching both devices and at this moment I think I would prefer the Samsung, since it has a much faster processor (800 Mhz, vs 528 Mhz for the Hero) and a physical keyboard. It also seems to come with a more "Standard" Android OS, which I think would make it easier to upgrade the device with future versions of Android.
The Hero comes with "value added" software from HTC, which, although it may be very nice, it may make it harder to upgrade the OS in the device, if nothing else for fear of losing the HTC specific software. Other advantages of the Hero include slightly more memory (288 MB vs the 256 MB that the Moment has), and a 5 megapixel camera (vs the 3.2 megapixel that the Moment has). On the flip side, the Moment's camera has a flash but the Hero's doesn't.
Both seem like very nice devices, but the much faster processor and the physical keyboard of the Samsung Moment, plus the apparent ease of upgradability of the Hero tilt the scale in favor of the Samsung device, at least in my book.
I also looked at Sprint's plans and they seem to have some good ones. I like AT&T's rollover minutes which Sprint lacks, however Sprint's data plan includes GPS functionality, which AT&T charges extra for; and live streaming video through Sprint TV, which as far as I know AT&T lacks. Also, with Sprint I can make and receive any domestic cell phone number from any carrier. Most of the calls I make and receive are to/from mobile phones anyway, so this is a big plus for me.
I'll be dropping by my local Sprint store in about three weeks to test the Samsung Moment out.
Posted at 05:54PM Oct 08, 2009 by David R. Heffelfinger in General | Comments[1]
Maven pom.xml configuration for Servlet 3.0
Good old servlets are getting a facelift in the next major version of Java EE after been somewhat neglected for so long.
One of the major changes of the new Servlet 3.0 API is that a web.xml is no longer required. Instead, servlets can be configured directly in the source code via annotations.
I wanted to try out this new feature, deploying in GlassFish 3 preview, which is the only Java EE 6 compliant application server at the moment.
As usual, I created a Maven project to test out this functionality, unfortunately, nobody has told Maven that a web.xml is no longer required. My build was failing with Maven complaining about the lack of a web.xml.
After some research, I found out how to configure Maven to avoid it complaining about this non issue.
Here is my pom.xml in it's entirety.
<project xmlns="http://maven.apache.org/POM/4.0.0"Notice that I'm using the Maven war plugin version 2.1 (in beta at the moment), since previous versions of the plugin (like the default 2.0) do not support the <failOnMissingWebXml> tag yet.
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.ensode.glassfishbook</groupId>
<artifactId>simpleapp</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>simpleapp</name>
<url>http://maven.apache.org</url>
<build>
<finalName>simpleapp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-beta-1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>java.net</id>
<url>http://download.java.net/maven/2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Posted at 08:13PM Sep 22, 2009 by David R. Heffelfinger in Java | Comments[1]
JasperReports 3.5 For Java Developers Published
I'm proud to announce that the second edition of my JasperReports book, JasperReports 3.5 for Java Developers has been published.
The book has been updated to cover the latest features added to JasperReports since the first edition was published. Here is the table of contents:
Chapter 1: An Overview of JasperReports
Chapter 2: Adding Reporting Capabilities to our Java Applications
Chapter 3: Creating your First Report
Chapter 4: Creating Dynamic Reports from Databases
Chapter 5: Working with Other Datasources
Chapter 6: Report Layout and Design
Chapter 7: Adding Charts and Graphics to Reports
Chapter 8: Other JasperReports Features
Chapter 9: Exporting to Other Formats
Chapter 10: Graphical Report Design with iReport
Chapter 11: Integrating JasperReports with Other Frameworks
The full table of contents can be found here.
I also added JPA integration as part of the chapter on JasperReports integration with other frameworks.
An article based on the book can be found at the Packt Publishing web site, it covers the most common use for JasperReports, which is generating reports from database data.
Also, chapter 10, Graphical Report Design with iReport, is available for free, no registration required.
Posted at 06:08PM Aug 13, 2009 by David R. Heffelfinger in Java |




