David R. HeffelfingerSoftware Development Noteshttp://mail.ensode.net/roller/dheffelfinger/feed/entries/atom2022-05-31T09:53:37+00:00Apache Roller (incubating)http://mail.ensode.net/roller/dheffelfinger/entry/java_ee_9_may_doJava EE 9 may do away with application servers,should app server vendors be worried?David R. Heffelfinger2016-10-06T23:22:38+00:002017-07-16T19:53:29+00:00
<p><p>In my recent article, <a href="https://jaxenter.com/a-glimpse-at-java-ees-future-129340.html">A glimpse at Java EE’s future</a>, I stated that "Java EE 9 may do away with the concept of application servers completely". This generated some interest on Twitter.</p><h2>Background - Project Jigsaw and Java Modularity <br /></h2><p>Some background for those not in the loop, Java 9 will introduce <a href="http://openjdk.java.net/projects/jigsaw/">Project Jigsaw,</a> which will bring modularity to the Java platform. Java has been around for some 21 years or so, the JDK includes libraries that are not used a whole lot anymore, for example, libraries to support <a href="https://en.wikipedia.org/wiki/Common_Object_Request_Broker_Architecture">CORBA</a>, which was popular in the mid to late 90's but is seldom used anymore. However, the JDK team at Oracle is hesitant to remove these libraries because doing so would potentially break compatibility with existing applications that may be using them, therefore newer JDK's need to keep including these old libraries.</p><p>Project Jigsaw provides a solution to this problem, instead of including everything in the JDK, from Java 9 and beyond, the JDK will become modular. Applications will use only the modules that they use. Going back to our CORBA example, the few applications out there still using CORBA won't break, but all other applications not using CORBA won't have this unused library lying around. Project Jigsaw will work similarly to the way Maven handles dependencies today, however this functionality will be build right in the JDK.</p><p>Project Jigsaw won't be limited to eliminating "cruft" from modern versions of Java, in general, any dependencies an application may have could be declared as a module. Library authors may publish their libraries as modules, which will then be downloaded by any applications that require them at compile time when the application is built. </p><h2>Modular Java EE<br /></h2><p>I had the opportunity to attend a Birds of a Feather session titled <a href="https://oracle.rainfocus.com/scripts/catalog/oow16.jsp?event=javaone&search=BOF7984&search.event=javaone">"Enterprise Java for the Cloud"</a> during JavaOne 2016. During this session is when I heard that there is a possibility that Java EE 9 may do away with the concept of application servers, in favor of Java 9 modules. A very interesting concept and quite a change from the way we have been developing enterprise Java applications since J2EE was released back in 1999. Great news for application developers, but, should application server vendors be worried?</p><p>The answer is a resounding no. The way this would work is that vendors would provide their Java EE APIs as modules, then applications would include them as dependencies. Potentially, this could even benefit application server vendors, let me explain.</p><p>As most of you reading this blog probably know, Java EE is a series of specifications, with multiple implementations. For example, Hibernate, EclipseLink and OpenJPA are all implementations of the JPA specification. Similarly, Weld and OpenWebBeans are implementations of the CDI specification. Each application server ships with one implementation of each Java EE specification. As application developers, we are more or less stuck with the implementation that the application server vendor provides (there are ways around this, but they require jumping through hoops). If Java EE 9 adopts the modularity features of Java 9, then we as application developers may be able to pick and choose Java EE API implementations as we please, for example, we could use Hibernate as our JPA implementation, and OpenWebBeans as our CDI implementation (as far as I know, no application server currently provides this combination of CDI and JPA implementations). We as application developers benefit by picking our favorite implementations of each API, and vendors benefit by an increased pool of potential users for their Java EE API implementations.<br /></p><p><br /></p><p><br /></p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/javaone_2016_day_3_fromJavaOne 2016, Day 3, from a Java EE PerspectiveDavid R. Heffelfinger2016-09-21T12:38:35+00:002016-09-21T12:38:35+00:00
<p><p>Yesterday was day 3 of JavaOne 2016. Oracle and the Java community is planning new features for the upcoming Java EE 8. I've been attending as many Java EE related sessions as I can, to see what the current plans are. All the speakers have made a point to state that nothing is carved in stone, all of this may change as it is still in planning stages.</p><p>I started the day attending "Cloud Native Java EE", a tutorial by <a href="http://www.payara.fish/">Payara</a> engineers Mike Croft (<a href="https://twitter.com/croft">@croft</a>) and Ondrej Mihályi (<a href="https://twitter.com/OMihalyi">@OMihalyi</a>). The talk was very good and explained how to deploy Java EE applications to the cloud using <a href="http://www.payara.fish/payara_micro">Payara Micro</a>.</p><p>I then headed over to Antoine Sabot-Durand's (<a href="https://twitter.com/antoine_sd">@antoine_sd</a>) session on CDI 2.0. Antoine is the CDI spec lead and obviously knows his stuff. He covered several new features coming to CDI 2.0 such as support for Java SE, asynchronous events, and the ability to add interceptors at runtime to CDI beans. That last one I thought was very impressive, I hadn't ever imagined that would even be possible.</p><p>Next I went to a JAX-RS 2.1 session by Ed Burns (<a href="https://twitter.com/edburns">@edburns</a>) and Pavel Bucek (<a href="https://twitter.com/pavel_bucek">@pavel_bucek</a>). The session covered several new JAX-RS features such as non-blocking I/O, server sent events and a reactive client API.</p><p>After that I attended "Portable Cloud Applications with Java EE" by Rajiv Mordani, Joe Dipol, Josh Dorr. This session covered how Java EE 9 will standardize the ability to deploy Java EE applications to different cloud providers.</p><p>The next session I attended was on Servlet 4.0, delivered by Ed Burns (<a href="https://twitter.com/edburns">@edburns</a>), discussing new features of this new version of the Servlet specification. This session started with a brief overview of network programming, Ed took some of us old timers in a trip down memory lane, mentioning things like <a href="https://en.wikipedia.org/wiki/Common_Gateway_Interface">CGI</a> and <a href="https://en.wikipedia.org/wiki/Gopher_(protocol)">Gopher</a>. Of particular interest in this session was Servlet 4.0 support for the HTTP/2 protocol. Ed was very good at explaining how this new version of HTTP addresses several limitations of the current HTTP 1.1 protocol supported by most browsers.</p><p>The last session I attended was "Security for Java EE 8 and the Cloud", by Kk Sriramadhesikan. The session covered security challenges posed by cloud environments and how the Java EE spec plans to address it. The new version of the Java EE Security API aims to make it easy for application developers to secure their cloud applications, leaving the details to security experts.</p><p>As evidenced by all of these great sessions, major changes are coming to Java EE in the not so distant future, looks like we will have some exciting times ahead. <br /></p><p><br /></p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/javaone_2016_day_2_impressionsJavaOne 2016, Day 2 ImpressionsDavid R. Heffelfinger2016-09-20T05:12:10+00:002016-09-20T05:12:10+00:00
<p><p>This morning I attended Gaurav Gupta's JPA Modeler session, the tool is certainly very impressive and I wanted to learn more about it.</p><p>After Gaurav's session, I headed to the Franciscan C/D room to prepare for my own Hands-On Lab, "Java EE, Beyond the Basics". I had some materials (slides, manual, code samples, etc) to copy to the virtual machine's on the laptops and <a href="https://en.wikipedia.org/wiki/Murphy%27s_law">Murphy</a> reared his ugly head. The lab's virtual machines were not booting. I googled the error and learned that as a workaround I had to disable USB on the VMs. With the help of a couple of technicians, we disabled USB on each and every virtual. But I had the files I needed to copy on a thumb drive, how could I copy them with USB disabled? Luckily, I had the files online, therefore we were able to download them and copy them to each and every VM. By the way, all class materials can be downloaded <a href="http://www.ensode.net/files/javaee.zip">here</a>. Luckily we were able to finish on time, by the time the students showed up the VM's were ready to go.</p><p>The session went very well, I covered JSF and EJB, my co-speaker <a href="https://www.linkedin.com/in/rwlarsen">Bob Larsen</a> covered CDI. We were planning to cover JAX-RS as well, but unfortunately we ran out of time. I got some good feedback from the students both face to face and over Twitter, I think the session was well received.</p><p>After my session, I attended <a href="https://www.linkedin.com/in/lindademichiel">Linda DeMichiel's</a> session on Java EE 8 Update. Linda, for those that don't know her, is one of the specification leads for the Java EE platform. She covered current plans for Java EE 8, currently scheduled to ship sometime in 2017. A controversial proposal is to drop the MVC API from Java EE 7, as well as JMS 2.1 (JMS 2.0, the current version, would be delivered with Java EE instead).</p><p>I then attended "Enterprise Java for the Cloud" by Rajiv Mordani, Josh Dorr and Dhiraj Mutreja. This session was about what is planned for Java EE 9. Againn lots of speculation here, as everything is in early planning stages. One thing that I found interesting is the addition of a standard Java EE API for NoSQL databases, at this moment it is not clear if it will be a completely new API or an enhancement to JPA.</p><p> The next session I attended was on <a href="http://json-b.net/">JSON-B</a>, the new Java API for JSON Binding. This is a new API scheduled to be included with Java EE 7, this new API will populate Java objects from JSON strings, and vice-versa.</p><p>I then skipped the JCP party to attend the "Java EE for the Cloud" Birds of a feather (BOF) session. This BOF session was surprisingly well attended, it started at 7:00 pm, usually night sessions are not that well attended, they compete with parties and with tired, jet-lagged attendees, looks like many people, like myself, care deeply about the future of Java EE. There were very good questions in this session, for example, there is a new security API proposed for Java EE 7, one of the attendees asked about integrating applications using the existing security APIs with the new proposed Java EE 8 API. In this session the comment was made that, although speculation at this time, it is possible that Java EE 9 will do away with the concept of application servers, in favor of <a href="http://openjdk.java.net/projects/jigsaw/">Java 9 modules</a>.</p><p>There are lots of sessions on Java EE 8 and Java EE 9 during the conference, I will do my best to attend as many as I can, to try and pick the brains of the individuals working on the new specifications for these future Java EE versions.</p><p><br /></p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/the_coolest_things_i_veThe Coolest things I"ve seen at JavaOne 2016 so farDavid R. Heffelfinger2016-09-19T12:26:02+00:002016-09-19T12:26:02+00:00
<p><p>Day one of JavaOne 2016 is in the books. Day 1 is typically JavaOne's NetBeans Day, and this year was no exception. Yesterday I had the opportunity to attend several sessions showcasing NetBeans capabilities, I saw features present in the current version of <a href="https://netbeans.org/downloads/">NetBeans</a>, some features are available in the upcoming <a href="https://netbeans.org/community/releases/82/">NetBeans 8.2</a>, others, Java 9 features specifically, will be available in a future version of NetBeans, but you can start experimenting with them today by downloading the <a href="http://wiki.netbeans.org/JDK9Support">NetBeans Java 9</a> build.</p><p>In no particular order, here are some of the coolest things I saw yesterday on day one of JavaOne 2016.</p><ol><li><b>Adding new refactoring capabilities to NetBeans on the fly.</b><br />Michael Nascimento Santos (<a href="https://twitter.com/mr__m">@mr__m</a>) demoed how to add refactoring capabilities to NetBeans on the fly with <a href="http://wiki.netbeans.org/Jackpot">Project Jackpot</a>. The specific example he showed was to add the capability for NetBeans to provide warnings when using <a href="http://www.joda.org/joda-time/">Joda-Time</a>, and suggest that the code use <a href="http://www.oracle.com/technetwork/articles/java/jf14-date-time-2125367.html">Java 8's Date/Time API</a> instead. Java 8, for those that don't know, introduced an improved Date / Time API which is much nicer than was what available with Java in earlier versions. Before Java 8, your best bet when working with dates was to use the Joda-Time library. You can see a video of Michael's demo <a href="https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&uact=8&ved=0ahUKEwjWh4HjspvPAhWHkh4KHY19AQoQtwIIMjAD&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DYlE_SinDWb0&usg=AFQjCNGHzUCtfd7eO_ZGdHVRT3PE2lYBjw&sig2=x4NgpyRu9J-296QDnolw7w&bvm=bv.133178914,d.dmo">here</a>. <br /></li><li><b>Create complete Java EE applications with JPA Modeler.</b><br />Gaurav Gupta (<a href="https://twitter.com/jGauravGupta">@jGauravGupta</a>) demonstrated a very cool NetBeans plugin called <a href="http://jpamodeler.github.io/">JPA Modeler</a>. JPA Modeler can generate database tables, JPA artifacts (entities, DAO's etc), and even complete Java EE applications just from a database model. The tool works like those graphical applications that DBA's use to create the database (i.e things like ERWin), but goes beyond the capabilities of these tools by generating a scaffold of your Java EE application. Gaurav is JPA Modelers project lead.</li><li><b>NetBeans JShell Integration</b><br /><a href="https://blogs.oracle.com/java/jshell-and-repl-in-java-9">JShell</a> is a new upcoming feature of Java 9, it allows to write "low ceremony Java", which means, to develop a "Hello World" program, you would just have to type <font face="courier new,courier,monospace">System.out.println("Hello, World")</font>, instead of having to declare a class, create a main() method, etc. The NetBeans Java 9 build includes built-in support for JShell, you can open a JShell window from NetBeans, experiment with your Java code, then automatically create a Java class with your JShell code snippets. Geertjan Wielenga (<a href="https://twitter.com/GeertjanW">@GeertjanW</a>) demoed all this, it was jaw droppingly cool. You can read a blog post explaining NetBeans JShell integration in <a href="https://blogs.oracle.com/geertjan/entry/learning_java_with_jshell_in">Geertjan's blog</a>.<br /></li></ol></p>
http://mail.ensode.net/roller/dheffelfinger/entry/javaone_2015_java_ee_handsJavaOne 2015 Java EE Hands-on LabDavid R. Heffelfinger2015-10-27T03:10:16+00:002015-10-27T18:08:13+00:00
<p><p>Earlier today I delivered my JavaOne Java EE Hands-On Lab session with <a href="https://twitter.com/reza_rahman">Reza Rahman</a> and <a href="https://www.linkedin.com/in/rwlarsen">Bob Larsen</a>. The session was completely packed and well received. We covered topics such as JavaServer Faces (JSF), Contexts and Dependency Injection (CDI), the Java Persistence API, and Enterprise JavaBeans (EJB). </p>
<p></p><p>I delivered the same talk last year, it was so popular that this year we're scheduled to deliver it twice, both sessions are completely packed. I'll be delivering the same talk tomorrow morning at 8:30 am in the Hilton Franciscan B/C/D room.<br /></p><p>The session is actually based on a week-long class I taught for one of my clients. The JavaOne version is compressed to fit in a 2 hour session. I'll be happy to teach the full course for anyone that would like to get more in-depth training, contact me at dheffelfinger at ensode dot com for details, my <a href="https://www.packtpub.com/application-development/java-ee-7-glassfish-4-application-server">Java EE with GlassFish</a> and <a href="https://www.packtpub.com/application-development/java-ee-7-development-netbeans-8">Java EE with NetBeans</a> books also contain additional material.</p><p> Some of the students requested a copy of the materials, and I'm happy to oblige. <a href="http://ensode.net/roller/dheffelfinger/resource/JavaOne2015JavaEE_HOL.zip">Click here</a> to download a zip file containing all the materials, including the slides, exercise manual, source code for the demo and exercise solutions.<br /></p><p> </p><p><br /></p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/javaone_2014_trip_reportJavaOne 2014 Trip ReportDavid R. Heffelfinger2014-10-04T14:29:58+00:002014-10-05T00:13:01+00:00
<p><p><br/>
I just came back from my annual trip to JavaOne. As usual, the conference was great. This year I had two talks, I participated in a panel at NetBeans day on Sunday right after the Technical Keynote. The title of the session was "Get Productive with Free Java Tools". I had the pleasure of presenting with Tony Epple (@monacotony), who was moderating the panel and gave a quick demo on <a href="http://dukescript.com/">DukeScript</a>, Sven Reimers (@SvenNB), who showed how to integrate the NetBeans IDE with JavaFX's SceneBuilder, Michelle Chamberlin, who explained the cool things she is doing at Boeing with the NetBeans platform, and Bernd Ruehlicke, who presented how the NetBeans platform is being used in the oil industry.<br /><br />My other session was a Java EE Hands-On Lab I co-presented with Mark Heckler (@MkHeck). Many thanks to Josh Juneau (@javajuneau), Sven Reimers (@SvenNB) and Bob Larsen, who helped us proctor the lab. The session was packed to the brim, there was a waiting list and many couldn't make it inside. </p><p><img border="0" hspace="0" align="bottom" vspace="0" src="https://lh5.googleusercontent.com/-QX9Gi9nzGRY/VC_wW3FABNI/AAAAAAAABDw/9ohJQHd2_yo/w506-h900/20141001_094831.jpg" /><br /><br />Feedback for the Hands-On Lab was great, attendees were stopping me in the hallway to tell me how much they enjoyed it, made my day. If you were one of those who couldn't make it in, or if you couldn't make it to the conference, all the materials for the lab can be found at <a href="http://ensode.net/downloads/JavaEE_Hands_On_Lab.zip">http://ensode.net/downloads/JavaEE_Hands_On_Lab.zip</a>.<br /><br />In addition to my own sessions, I attended several sessions by some of the other great speakers. Sunday morning I attended the GlassFish community panel, with John Clingan (@jclingan), Cameron Purdy (@cpurdy) and Anil Gaur (@annilgaur), moderated by Reza Rahman (@reza_rahman), in this session, the panelists reiterated Oracle's commitment to GlassFish. </p><p> </p><p><img border="0" hspace="0" align="bottom" vspace="0" src="https://lh4.googleusercontent.com/-2mfF__X6AGk/VChGk8uEmgI/AAAAAAAAAyg/wIsHIhRci_s/w946-h532-no/20140928_103402.jpg" /> </p><p>During the GlassFish Adoption session Mohamed Taman (@_tamanm) talked about a large scale deployment in Egypt, in which he used GlassFish on a UN project. His company won the contract, and by the time they started to work on it most of the work was already in place, readily impressing his client. Mohammed also briefly talked about this project during the community keynote. Martin Mares (@MartinJMares) also talked during this session, showing some cool things he is doing with the GlassFish command line administration tool, asadmin.</p><p><br />I then attended the technical keynote, which included speakers from IBM and Oracle. The keynote was running behind schedule, I had to leave early since I had a session right after, as I'm sure you've heard by now, Brian Goetz (@BrianGoetz) was kicked out of the stage towards the end. I missed when it happened live, but I plan to watch <a href="https://www.oracle.com/javaone/live/on-demand/index.html#javaone">the recording</a>.<br /><br />Later on Sunday I attended a session on using NetBeans for teaching, with Ken Fogel (@omniprof), Johannes Weigend (@JohannesWeigend), Paul Anderson (@Paul_ASGTeach), Gail Anderson (@gail_asgteach), Zoran Severac (@neuroph) and Andreas Stefik (@AndreasStefik). In addition to my daytime job as a Java EE software developer, I sometimes teach short courses on Java EE using NetBeans, I picked some good tips from this session that I'm sure to use in future courses.</p><p>John Ament (@JohnAment) gave a talk on Monday morning about building RESTful web services outside an application server.<br /><br />On Monday, there were many sessions about the future of Java EE, <a href="https://www.java.net/jcp/communityspotlight/linda-demichiel">Linda DeMichiel</a> had a very interesting presentation about the future of the platform as a whole. Pavel Bucek (@pavel_bucek) had a session about the future of the Java API for WebSocket. Martin Grebac (@mgrebac) had a session on the JSONB specification that is slated to be included in Java EE 8. </p><p>Geertjan Wielenga (@GeertjanW) and JB Brock (@peppertech) had a great <br/>
session on Monday about Coding for Desktop and Mobile with HTML5 and Java EE 7. In <br/>
this session they showed the NetBeans / Chrome integration, in which <br/>
changes to the markup in NetBeans result in an instant refresh on the <br/>
browser, greatly speeding up web application development, very <br/>
impressive. <br /></p><p>On Monday night I attended a couple of GlassFish Birds-of-a-Feather <br/>
(BOF) sessions. The first GlassFish BOF was the GlassFish Community BOF <br/>
and was led by John Clingan (@jclingan), I had the pleasure of meeting <br/>
Manfred Riem @mriem, JSF and MVC co-spec lead during this BOF. The <br/>
second GlassFish BOF was about contributing to GlassFish, it was led by <br/>
Reza Rahman (@reza_rahman), GlassFish and Java EE evengelist at Oracle, <br/>
and Steve Millidge. Steve is the CEO <br/>
of C2B2 consulting, a consulting firm in the UK, and is <br/>
also the man behind Payara, a new supported distribution of GlassFish, <br/>
if you are using GlassFish for your Java EE project, you should check Payara out.<br /><br />I also attended a JSF BOF on Monday night, in which <br/>
Kito Mann (@kito99) and another JSF expert group member explained their <br/>
ideas for future features in JSF.</p><p>On Tuesday, Arun Gupta (@arungupta) had an interesting talk about <br/>
lessons learned in real-life Java EE 7 projects. In this session he <br/>
described several Java EE 7 already in production, including Mohamed <br/>
Taman's project that was featured in the technical keynote on Sunday.</p><p><img border="0" hspace="0" align="bottom" vspace="0" src="https://lh5.googleusercontent.com/-q0k6lGsiQ_s/VCsKrhvWhZI/AAAAAAAAA2E/6jIQC-sLdZk/w299-h532-no/20140930_125518.jpg" /></p><p>Also on Tuesday, David Delabassee (@delabassee) had a very interesting talk about <br/>
implementing home automation with JavaEE. He was actually controlling <br/>
the lights in his home office in Belgium live from the session, which <br/>
was being held in San Francisco, very cool stuff.<br /><br /><img border="0" hspace="0" align="bottom" vspace="0" src="https://lh6.googleusercontent.com/-r6eUaaYbl2g/VCtPiZ3gWSI/AAAAAAAAA2s/vOtBKbildaY/w299-h532-no/20140930_174906.jpg" /><br /><br />Tuesday night there was a BOF on meeting with the Java EE specification leads with Bill Shannon, Linda DeMichiel, Ed Burns (@edburns), Manfried Riem (@mriem), Pavel Bucek (@pavel_bucek), and all other Java EE specification leads. It is always an honor to be in the same room with those to work so hard to bring us the latest Java EE specs.</p><p><img border="0" hspace="0" align="bottom" vspace="0" src="https://lh4.googleusercontent.com/-dIAIoHS9VA0/VCtvx_KrhaI/AAAAAAAAA28/Bdlkozekldc/w946-h532-no/20140930_200643.jpg" /><br /><br /><br />Josh Juneau (@javajuneau) had a session Wednesday afternoon about Concurrency Utilities for Java EE, a new API that was introduced in Java EE 7.</p><p><img border="0" hspace="0" align="bottom" vspace="0" src="https://lh3.googleusercontent.com/-Gp83ldB8DGE/VCyOh1pPICI/AAAAAAAAA7Y/sLOyw0CiWj0/w946-h532-no/20141001_163003.jpg" /><br /><br />On Thursday morning I attended the community keynote, it started with <span class="_dwd st s std">Michael Greene</span> from Intel, we saw some of the stuff that Intel is doing with Java on the server side, also, there was an announcement about Intel joining the OpenJDK project. During the community keynote, there was a lot of very interesting coverage about Java powered robots, including automated cars from Perrone Robotics, a company based in Charlottesville, Virginia, not too far from my neck of the woods. There were several community members on stage at one point or another. The community keynote wrapped up with no other than James Gosling, the father of the Java language, talking about how Java has come full circle, it started as an "Internet of Things" language, and is currently used more and more in that realm.<br /><br />An annual tradition during JavaOne keynotes is that at one point or another, they start throwing t-shirts at the audience. This year there was a twist, they were using a rubber catapult contraption to be able to throw t-shirts to members of the audience that are sitting farther back (side note, Sven Reimers, which was sitting two seats away from me, got hit in the face with one of these t-shirts thrown using the contraption, Sven, if you are reading this, I hope you are ok, but that was very funny). Every year I try very hard to catch one of these t-shirts, to no avail, this year, I finally was able to catch one.</p><p><img border="0" hspace="0" align="bottom" vspace="0" src="https://lh5.googleusercontent.com/-9RcwCaiuXmM/VC2Xx9bRHoI/AAAAAAAABCE/uRRokcoWOT4/w299-h532-no/20141002_112106.jpg" /><br /></p><p>On Thursday right after the community keynote there was a very <br/>
interesting Java EE 8 community panel, with representatives from all <br/>
major Java EE application servers, including [dude's name] from IBM, <br/>
Mark Little [twitter] from Red Hat, David Blevins (@dblevins) from Tomee<br/>
[spelling], Cameron Purdy representing GlassFish, John Clingan <br/>
(@jclingan) representing the Avatar project. And Adam Bien representing <br/>
himself as a member of the Java EE community.</p><p>Bruno Borges (@brunoborges) had an interesting session Thursday afternoon on implementing JavaFX clients for Java EE server side code.<br /><br />Also on Thursday, Adam Bien (@abien) had a cool session about using Nashorn, the JavaScript implementation included in the Java Development Kit (JDK) 8, in Java EE applications. Adam is a great speaker, make sure you check his AirHacks online seminars.<br /><br /><br />I tend to focus on Java EE sessions when I go to JavaOne, but this year I went to a couple of sessions covering other very cool stuff. Tony Epple (@monacotony) and Jaroslav Tulach (@JaroslavTulach) had a very funny and informative session about DukeScript, DukeScript applications are plain Java applications that internally use HTML5 technologies and JavaScript for rendering.<br /><br />Baruch Sadogursky and Yoav Landman , another great comedic duo, had a great session on Groovy puzzlers.<br /><br />Venkat Subramaniam (@venkat_s) delivered a fast paced, humorous and interesting talk on Groovy closures, this was late in the day on Thursday, a great way to end the conference.<br /><br />A major part of the conference is the vendor's booths. This year I dropped by the Tomitribe booth, Tomitribe provides support for the Apache TomEE application server. I also visited the CodeName One booth, these guys make a product that allows you to develop applications in Java for both Android and Mac OS. I also dropped by the IDR solutions booth, this company makes a product that converts PDF documents to HTML5, and the Payara booth, who provides technical support for GlassFish.<br /><br />Wednesday afternoon I had a book signing at the JavaOne bookstore, my first time signing books at JavaOne, great experience.<br /><br />In addition to sessions, booths and book signings, JavaOne always has plenty of social activities. This year I attended the NetBeans party on Saturday night, the Java EE community appreciation event on Sunday night, and the JCP party on Monday night. I also attended the Oracle appreciation event, this year they had none other than Aerosmith playing at the event. </p><p><img border="0" hspace="0" align="bottom" vspace="0" src="https://lh4.googleusercontent.com/-EOyB2VT4W5I/VCjfSjKHrcI/AAAAAAAAAyE/SC0iQs1FUHs/w946-h532-no/20140928_212533.jpg" /><br /><br />As always, JavaOne was awesome, great sessions, great social activities and above all the opportunity to rub shoulders with the greatest minds in the Java community. Every year I meet new great people from all over the world, and even though I don't see them often, when I run to them at the conference it is always as if I'm meeting with old friends.<br /><br />Next year marks the 20th anniversary of the Java language, I'm sure JavaOne 2015 will be out of this world, I can't wait.<br/>
</p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/java_ee_course_trip_reportJava EE Course Trip ReportDavid R. Heffelfinger2014-06-03T17:01:05+00:002014-06-03T17:01:06+00:00
<p>I just came back from teaching a Java EE class in San Francisco.<br /><br />The course lasted two days, and it covered the most commonly used Java EE technologies and API's such as JavaServer Faces (JSF), Contexts and Dependency Injection (CDI), Enterprise JavaBeans (EJB), the Java Persistence API and the Java Message Service(JMS). The course also touched on Bean Validation and the Java API for RESTful Web Services (JAX-RS).<br /><br />The students were veteran Java developers and architects, ranging from around 5 to 18 years of experience. There were a few students that had use EJB's back in the J2EE era, some that had used earlier versions of JSF (1.x) and some that had been focusing on Spring for their server side Java development.<br /><br />None of the students had use modern versions of EJB or JSF, they were very impressed on how much easier modern versions of these frameworks are compared to their Java EE counterparts.<br /><br />Since we had only two days, we only covered the basics of each technology, such as Facelets markup for JSF. For CDI, we covered context (scope) annotations and dependency injection for CDI. We mentioned additional CDI features such as qualifiers, stereotypes and interceptor binding types.<br /><br />The different Bean Validation annotations were covered, pointing out how simple it is to do validation using just a few simple annotations. As far as EJB's go, I covered the different type of session beans, such as Stateless, Stateful, and Singleton session beans; as well as Message driven beans. For EJB's we went a bit deeper, covering things such as transaction management, interceptors for Aspect Oriented Programming (AOP) and the EJB timer service.<br /><br />When talking about JPA, the class covered basic JPA annotations such as @Table and @Column, as well as one-to-many, many-to-one, many-to-many and one-to-one entity relationships. We also covered eager vs lazy fetching, and the advantages and disadvantages of each approach. We ended the JPA topic with a discussion of the Java Persistence Query Language (JPQL) and the JPA Criteria API.<br /><br />I overheard some comments from the students, for example, one mentioned "EJB's are cool", which I completely agree. Another student noted that there isn't anything in Java EE that he cannot accomplish with Spring, which, while it may be true that the end result is the same, fails to take into account that the amount of work to get this end result tends to be a lot less with Java EE.<br /><br />There were hands-on labs for the students to practice the concepts taught in class. I chose NetBeans as the IDE for the exercises, since it comes bundled out of the box with everything needed to build complete applications, such as a Java EE compliant application server (GlassFish), and a fully functional RDBMS (JavaDB). Not many of the students had previous NetBeans experience, however most of them were able to finish the exercises (which were simple, but complete Java EE applications) in about 30 minutes or so.<br /><br />While discussing the hands-on labs, I provided some NetBeans tips, such as the ability to generate boilerplate code (Alt-Ins), generate JPA entities from an existing database, and the NetBeans JPQL editor, which provides code completion when developing JPQL queries.<br /><br />All in all, a great experience. I don't get to teach as often as I'd like, it is a nice change of pace from my day to day job developing real-life Java EE applications.</p>
http://mail.ensode.net/roller/dheffelfinger/entry/javaserver_faces_jsf_in_aJavaServer Faces (JSF) in a HurryDavid R. Heffelfinger2014-04-04T00:21:28+00:002014-04-06T01:10:46+00:00
<p><p>Need to learn JSF in a hurry? I'm here to help! </p><p>Assuming you already have some Java experience, as well as some HTML experience, there is nothing to JSF, you can learn the basics in a few minutes. I also assume that you are familiar with packaging and deploying Java code to an application server such as GlassFish, WildFly, JBoss, Weblogic or Websphere, or to a servlet container such as Tomcat or Jetty.</p><p><br />JSF has evolved over the years, this blog post covers the best practices in JSF 2.0 or newer, specifically, Facelets is used to develop the front end (as opposed to JSP) and CDI Named beans are used to develop the server side code (as opposed to managed beans).</p><p><br /></p><h4>Step 1: Develop Java class(es) that will hold information (the Model in the MVC pattern)</h4><p>Your Java class will be a Plain Old Java Object (POJO), it will consist of private properties public setters and getters.<br /></p><p>package com.ensode.jsfinahurry.model;<br />import javax.enterprise.context.RequestScoped;<br />import javax.inject.Named;<br /><br />@Named<br />@RequestScoped<br />public class Person {<br /><br /> private String firstName;<br /> private String lastName;<br /> private Short age;<br /><br /> public String getFirstName() {<br /> return firstName;<br /> }<br /><br /> public void setFirstName(String firstName) {<br /> this.firstName = firstName;<br /> }<br /><br /> public String getLastName() {<br /> return lastName;<br /> }<br /><br /> public void setLastName(String lastName) {<br /> this.lastName = lastName;<br /> }<br /><br /> public Short getAge() {<br /> return age;<br /> }<br /><br /> public void setAge(Short age) {<br /> this.age = age;<br /> }<br /><br />}<br /></p><p>The @Named annotation designates the class as a CDI managed bean, gives it a name, which by default is the class name with its first character switched to lowercase (“person”, in our case). This annotation allows JSF pages to access our Java class.<br /></p><p>The @RequestScoped annotation gives our CDI bean a scope of request. If you have developed web applications in Java before you should be familiar with bean scopes by now.</p><p>The following table shows the most commonly used scopes for CDI named beans:</p><p><table border="1" cellspacing="1" cellpadding="1" style="width: 100%;"><tbody><tr><td style="width: 50%;"><b> Annotation</b></td><td style="width: 50%;"> <b>Scope</b></td></tr><tr><td style="width: 50%;"> @RequestScoped</td><td style="width: 50%;"> Request</td></tr><tr><td style="width: 50%;"> @SessionScoped</td><td style="width: 50%;"> Session</td></tr><tr><td style="width: 50%;"> @ApplicationScoped</td><td style="width: 50%;"> Application</td></tr><tr><td style="width: 50%;"> @ConversationScoped</td><td style="width: 50%;"> Conversation</td></tr><tr><td style="width: 50%;"> @FlowScoped</td><td style="width: 50%;"> Flow</td></tr><tr><td style="width: 50%;"> @Dependent</td><td style="width: 50%;"> Dependent pseudo scope<br /></td></tr></tbody></table><br />The first three should be self-explanatory, the last two (@ConversationScoped and @FlowScoped) are both meant for the bean to live throughout two or more requests, but not last through the whole session. Since we're in a hurry, I can't explain these in detail, but suffice to say that @FlowScoped was introduced in JSF 2.2 as part of Java EE 7 and is the preferred way to achieve this functionality if you are using JSF 2.2 or newer. @Dependent just means that the bean will be created as needed.<br /></p><h4>Step 2: Develop a controller class</h4><p>This is the controller in the Model-View-Controller (MVC) design pattern. As far as plumbing, there is not much to do for controllers, just use the @Named annotation and an appropriate annotation.<br />package com.ensode.jsfinahurry.controller;<br /><br />import javax.enterprise.context.RequestScoped;<br />import javax.inject.Named;<br /><br />@Named<br />@RequestScoped<br />public class PersonController {<br /> public String processData(){<br /> <br /> //in a real application, we would process user-input here<br /> //more than likely saving data to a database<br /> <br /> return "confirmation";<br /> }<br />}<br /></p><p>Our JSF pages will invoke the processData() method when the user clicks on a button, via a method binding expression (next section). By convention, the next page to render in the browser will match the return value of the invoked method (processData(), in our case). For our example, we will develop a page named confirmation.xhtml (matching the return value of “confirmation”) that will be rendered after our processData() method is invoked.<br />Step 3: Develop the pages<br />Now that we have our Java code in place, we need to develop the user interface. JSF pages are developed using Facelets, a JSF specific view technology. Facelets pages are nothing but standard XHTML pages using some JSF specific name pages.<br />A page used to allow the user to enter person data (to be stored in our Person class) may look like this:<br /></p><p><?xml version='1.0' encoding='UTF-8' ?><br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <br /> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><html xmlns="http://www.w3.org/1999/xhtml"<br /> xmlns:h="http://xmlns.jcp.org/jsf/html"><br /> <h:head><br /> <title>Enter Person Data</title><br /> </h:head><br /> <h:body><br /> <h3>Enter Person Data</h3><br /> <h:form id=”personForm”><br /> <h:panelGrid columns="2"><br /> <h:outputLabel for="firstName" value="First Name"/><br /> <h:inputText id="firstName" label="First Name" value="#{person.firstName}"/><br /> <h:outputLabel for="lastName" value="Last Name"/><br /> <h:inputText id="lastName" label="Last Name" value="#{person.lastName}"/><br /> <h:outputLabel for="age" value="Age"/><br /> <h:inputText id="age" label="Age" value="#{person.age}"/><br /> <h:panelGroup/><br /> <h:commandButton value="Submit" action="#{personController.processData()}"/><br /> </h:panelGrid><br /> </h:form><br /> </h:body><br /></html><br /></p><p>If you know even basic HTML, you should have a pretty good idea of how the above Facelets markup works. Before explaining the markup, notice that most JSF specific tags on the page have an id attribute. This attribute is optional, but it is a good idea to set it, for starters, it allows us to link labels to input fields (explained below), but also, when things don't work as expected it is much easier to identify which tag is causing trouble, as most JSF error messages will display the id of the component (if we don't set it, JSF will assign one, that will be meaningless to us).<br /></p><p>The <h:head> and <h:body> tags are drop-in replacements for HTML <head> and <body> tags.<br /><h:form> is equivalent to the HTML <form> tag, notice that for JSF we don't need to specify the method and action attributes (method will always be “post” and the action will always point to the JSF servlet, which is automatically used when developing with JSF).</p><p><br />The <h:panelGrid> component lays out JSF tags on the page, similar to using a table to lay out HTML tags. Its column attribute specifies how many tags will be placed in each column.<br /><h:outputLabel> renders an HTML <label> tag, its “for” attribute must match the id attribute of the input component the label is meant for.</p><p><h:inputText> is equivalent to an HTML <input> tag with a type of “text”. A nice thing about JSF is that it automatically converts user-entered values to the appropriate type in the corresponding CDI named bean. The value of the value attribute is what is known as a value binding expression, we can recognize these since they are encapsulated in curly braces and preceded by a hash (i.e. #{..}). Value binding expressions are used to automatically populate the corresponding attribute in a CDI named bean with the user-entered value for the corresponding input text. Remember the @Named annotation? “person” inside each value attribute corresponds to the name of our Person bean. The value after the dot corresponds to the corresponding property in the Person bean. For example, #{person.firstName} corresponds to the firstName property of the Person bean.<br /></p><p><h:panelGroup> is used to group JSF tags together in a single cell. In our case, all we wanted to do was have an empty cell so that our button would vertically align with the rest of the input fields, so we placed an empty <h:panelGroup> tag at the appropriate location in our <h:panelGrid>.</p><p><br />Finally, <h:commandButton> submits our form, its value attribute sets the label for the button, its action attribute indicates which CDI named bean method to execute when the button is clicked (processData(), in our case). This is what is called a method binding expression. The method must be public, return a String and take no arguments. What we implemented here is what is referred to as dynamic navigation, although our simple example always returns the same String, there is nothing stopping us from returning different values depending on some conditions, we can then take the user to different pages depending on these conditions (picture a switch statement or if/then/else, with different return values for different conditions).<br />If we don't need to do any processing after the user clicks the button and we always will display the same page, we can use static navigation, in which case the value of the action attribute can be hardcoded, like this:</p><p><br /><h:commandButton value=”Submit” action=”somepage”/><br /></p><p>We know that the value is hardcoded and not an expression since it is not surrounded by curly braces preceded by a pound sign (“#{...}”). In this case a page named somepage.xhtml would be rendered on the browser every time the user clicks on the button.<br />The markup for our confirmation page simply displays the values the user entered on the previous page.<br /></p><p><?xml version='1.0' encoding='UTF-8' ?><br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <br /> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><html xmlns="http://www.w3.org/1999/xhtml"<br /> xmlns:h="http://xmlns.jcp.org/jsf/html"><br /> <h:head><br /> <title>Confirmation Page</title><br /> </h:head><br /> <h:body><br /> <h3>You entered the following data</h3><br /> <b>First Name:</b> ${person.firstName}<br/><br /> <b>Last Name:</b>${person.lastName}<br/><br /> <b>Age:</b>${person.age}<br /> </h:body><br /></html></p><p><br />The only thing new on this page is the use of curly braces preceded by a dollar sign (“${...}”) to retrieve a named bean's properties. When the page is displayed the value of the corresponding property is displayed on the page.<br /></p><h4>Our application in action</h4><p>Once we package our application in a WAR file and deploy it to our application server of choice (I'm using GlassFish), our input page will be rendered. Here is what it would look like after a user entered some data:<br /><img vspace="0" hspace="0" border="0" align="bottom" src="http://ensode.net/roller/dheffelfinger/resource/input_screen.png" /><br />Notice that we didn't have to specify any mappings in web.xml (as a matter of fact, web.xml is optional in modern JSF applications). By default, JSF pages are mapped to the /faces prefix.<br />When the user clicks on the Submit button, the processData() method on our PersonController class is executed, which takes us to the confirmation screen.<br /><img vspace="0" hspace="0" border="0" align="bottom" src="http://ensode.net/roller/dheffelfinger/resource/confirmation_screen.png" /><br /></p><h4>What I left out</h4><p>This post is meant as a quick introduction to JSF, so I obviously did not cover every JSF nook and cranny. There are lots of additional JSF tags that I didn't cover, there are JSF specific equivalents to every HTML input tag.<br /></p><p>JSF also has input validation built-in, we can make fields required and also accept only specific formats, for example. For application specific cases, we can develop our own custom validators.<br /></p><p>JSF has built-in data conversion, we saw this in action by adding a property of type short and having the user-entered value automatically converted to the appropriate type. JSF also allows us to develop custom data converters.<br /></p><p>JSF also has Ajax integration built in, a topic that I obviously didn't cover.<br />Finally, almost nobody develops “raw” JSF applications, the beauty of JSF is that allows the creation of component libraries. Most JSF applications employ one of these component libraries. Some of the most popular include PrimeFaces, RichFaces and IceFaces.<br /></p><h4>Where to go from here</h4><p>After reading this short blog post, you should have a pretty good idea of the basic mechanics of JSF. To learn more about it, I'd be very grateful if you purchased one my books, <a href="http://www.packtpub.com/java-ee-7-with-glassfish-4-application-server/book">Java EE 7 Development With GlassFish 4</a> or <a href="http://www.packtpub.com/java-ee-6-development-with-netbeans-7/book">Java EE 6 Development With NetBeans</a>, or, if you need personalized training, I can help you with that as well, just head over to my company web site: <a href="http://www.ensode.com">http://www.ensode.com</a> for my contact information.<br />Of course, there is a ton of free information on the web as well, now that you know the basics other tutorials out there that assume basic knowledge should make more sense, just use your favorite search engine to find out more. </p><p> The source code for the example shown in this post can be downloaded <a href="http://ensode.net/roller/dheffelfinger/resource/jsfinahurry.zip">here</a>.<br /></p><p><br /></p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/java_lingo_for_non_javaJava Lingo for Non-Java PeopleDavid R. Heffelfinger2013-11-16T18:59:59+00:002013-11-16T19:43:03+00:00
<p><p><br/>
This post is meant for managers, business analysts, recruiters, and anyone else who needs to interact with Java developers but is not a Java developer him/herself.<br />Just like any other discipline, Java development is full with lingo that may be intimidating to those not in the field.</p><p><b>Java</b><br />Java itself is a programming language that is platform independent, which means that Java code can run unmodified on a variety of operating systems such as Windows, Linux/Unix, and Mac OS. Traditionally source code needs to be compiled for each specific platform, this is not the case for Java.</p><p><b>The Java Virtual Machine</b><br />But Java is not only a programming language, it is also a platform. Java code runs on the Java Virtual Machine (JVM), which translates Java bytecode (compiled Java code) into native code for each platform. There are several other languages that run in the JVM, such as JRuby, Clojure, Groovy, Ceylon and many others.</p><p><b>Eclipse, NetBeans, IDEA</b><br />Java applications are typically developed using an Integrated Development Environment (IDE), the three most popular IDEs are Eclipse, NetBeans and IntelliJ IDEA.</p><p><b>ANT, Maven, Gradle</b><br />Java applications also typically use a build tool to help compile, build and deploy applications, the three most popular build tools are ANT, Maven and Gradle.</p><p><b>Java EE, JEE, J2EE</b><br />Java is extremely popular for developing enterprise server side applications, these types of applications typically use a web based user interface, with the business logic running on a server. Java Enterprise Edition (Java EE) is a set of Application Programming Interfaces (APIs) used to develop server side applications. Sometimes Java EE is referred to as JEE, however the officially sanctioned name is Java EE and the use of the term JEE is discouraged by Oracle, the company behind the Java platform (Oracle bought Sun Microsystems, the original company behind Java, back in 2010). Java EE was formerly known as J2EE, the J2EE term was so popular that it is still commonly used to refer to Java EE.</p><p><b>Spring</b><br />The Spring framework is an alternate set of APIs used to develop server side applications. In general, server side Java developers belong to either the Java EE or Spring camps, rare is the developer that is a fan of both.<br /></p><p><b>GlassFish, Weblogic, Websphere, JBoss, Tomcat, etc</b><br />Server side Java applications are deployed to an application server. Application servers provide functionality that is common to all enterprise applications so that application developers don't have to concern themselves with implementing this functionality. For example, application servers take care of transaction management, security and scalability. Some examples of application servers include GlassFish, JBoss, WildFly, Weblogic and Websphere. Tomcat can be thought of as an application server as well, however strictly speaking, it is a servlet container, that is, it provides less functionality out of the box than full fledged application servers. Java applications written using Spring typically don't require a full fledged application server and can be deployed to Tomcat. Another popular servlet container is Jetty.</p><p><b>JSF, Struts, GWT, Etc</b><br />There are several Java web frameworks that are used to ease and accelerate the development of web based applications. JavaServer Faces (JSF) is the standard Java EE framework for web development. There are several JSF component libraries that run on top of JSF, these libraries make it easy to develop nice looking JSF based web applications. Some examples of these libraries include PrimeFaces, RichFaces and IceFaces. In addition to JSF, there are several other Java web frameworks such as Struts (considered by many to be a legacy framework), the Google Web Toolkit (GWT), Struts Web MVC and Wicket.</p><p><b>EJB</b><br />On the server side, Enterprise JavaBeans (EJBs) provide transactions, security and scalability out of the box. This frees Java developer from having to implement this functionality and allows them to focus on implementing the business logic.</p><p><b>JPA, Hibernate, MyBatis</b><br />There are Java APIs (Application Programming Interfaces) that help developers write code to interact with a database, the Java Persistence API (JPA) is the standard Java EE API used for this purpose. Hibernate and MyBatis (formerly known as iBatis) are two other popular libraries used for this purpose.<br /></p><p><br />So there you have it, my friend, after reading this post you'll have some idea of what the heck those Java guys are talking about or what it is that is needed for that Java developer position your company is hiring for.</p><p>Anything I missed? Leave a comment. <br /></p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/why_is_it_so_hardWhy is it so hard to find Java talent?David R. Heffelfinger2013-10-19T14:27:13+00:002013-10-19T14:27:13+00:00
<p><p>One common complaint that I hear from my clients and recruiter friends is that it is very hard to find good Java talent.</p><p>I am fortunate enough to be on the other side of the coin, I have been working with Java for several years now, I have authored several <a href="http://www.amazon.com/David-R.-Heffelfinger/e/B0034O0CIE">books</a> on Java and have been a speaker at Oracle's JavaOne conference on more than one occasion, so I'd like to think I'm one of those hard to find good Java developers.</p><p>Being on the other side of the coin, I am bombarded every day with emails from recruiters interested in my services, I am fortunate enough to be able to be selective about the projects I work with. In my experience there are three things that drive me away from accepting a project. Here are my suggestions on things you can do to attract top Java talent.</p><p><b>Make it easy to apply</b> </p><p>It is mind boggling to me the number of companies that require me to go fill out some long, convoluted form just so that I can apply for a job with them. I have several other companies that are dying to hire me, don't make it a hassle for me to apply for a job for you. On a similar note, many companies require me to fill out some form made in Word that duplicates all the information that already exists in my resume. </p><p>If you want me to work for you, don't make it a hassle for me to apply.</p><p><b>Be flexible with your tax terms</b></p><p>For quite a few years now, I've been an independent consultant, in order to do this, I had to incorporate, hire a payroll service, and get insurance for my business. I already have an infrastructure in place to run my business, therefore I only take Corp-to-Corp (C2C) contracts. A lot of companies do W2 only, or want a permanent employee only. Again, I have several potential clients that want to hire me and agree to my terms, your chances of hiring me are slim to none if you are unwilling or unable to do a C2C contract.</p><p><b> Your project has to be interesting</b></p><p>I'm not going to pull any punches here, a lot of the Java projects out there just suck, plain and simple. If what you want me to do is maintain an old J2EE application using Struts 1 and Spring 1 or 2, I'm not going to be very interested in your project. You need to modernize your infrastructure if you want to attract top Java talent. I have actually researched the topic on modernizing legacy server side Java web applications, and wrote a <a href="http://www.oracle.com/technetwork/articles/java/springtojavaee-522240.html">series of articles</a> for the Oracle Technology Network (OTN) a while back on the topic. The articles focus on Spring to Java EE migration, but the same concepts apply to J2EE to Java EE migration. If you need help modernizing a legacy project, <a href="http://www.ensode.com/">drop me a note</a>, this will certainly be an interesting project and I'll be happy to help.<br /></p><p><br /></p><p><br /></p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/trying_to_keep_an_openTrying to keep an open mind in the Spring Vs Java EE DebacleDavid R. Heffelfinger2012-04-29T12:38:13+00:002012-04-29T12:38:13+00:00
<p><p>One common criticism of my Spring to Java EE Migration article series (see <a href="http://www.oracle.com/technetwork/articles/java/springtojavaee-522240.html">part 1</a>, <a href="http://www.oracle.com/technetwork/articles/java/springtojavaee2-1414289.html">part 2</a>, <a href="http://www.oracle.com/technetwork/articles/java/springtojavaee3-1569377.html">part 3</a> and <a href="http://www.oracle.com/technetwork/articles/java/springtojavaee4-1592643.html">part 4</a>) is that the article uses an old version of Spring against a modern version of Java EE. There's a reason for that, since project using older versions of Spring are the most likely ones to be looking to migrate to a newer technology stack, be it a newer version of the Spring Framework, Java EE or something else.</p><p>Nevertheless, truth be told, I've been focusing on Java EE projects for the last few years, and the times I've used Spring have been when maintaining legacy applications that don't use modern versions of the Spring framework.</p><p> Trying to keep an open mind, I bought <a href="http://www.amazon.com/gp/product/1449306403/ref=as_li_ss_tl?ie=UTF8&tag=ensode-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=1449306403">Just Spring</a> by Madhusudhan Konda for my <a href="http://www.amazon.com/gp/product/B0051VVOB2/ref=as_li_ss_tl?ie=UTF8&tag=ensode-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B0051VVOB2">Kindle Fire</a>. The book uses Spring 3.0, versus Spring 2.5 in my article series. I decided to go for this book since it is a quick read (just over 60 pages), I didn't want to have to go through a 300+ behemoth of a book just to see if my opinion of Spring was outdated.</p><p>Quite frankly, the book did little to change my opinion in the Java EE vs Spring debacle. Although annotations get a brief mention in Konda's book, most of the examples still use XML configuration, and the seemingly endless XML needed to do anything nontrivial in Spring is one of the main reasons I'm not a fan of the framework. <br /></p><p> </p><p>To learn more about Java EE development, please check out my own books, <a href="http://www.amazon.com/gp/product/1849510369/ref=as_li_ss_tl?ie=UTF8&tag=ensode-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=1849510369">Java EE 6 with GlassFish 3 Application Server</a> and <a href="http://www.amazon.com/gp/product/1849512701/ref=as_li_ss_tl?ie=UTF8&tag=ensode-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=1849512701"> Java EE 6 Development with NetBeans 7</a>.<br /></p><p> </p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/spring_to_java_ee_migration2Spring to Java EE Migration Article, Part 4David R. Heffelfinger2012-04-28T17:20:11+00:002012-04-28T17:20:12+00:00
<p><p>The fourth and final part of my Spring to Java EE migration article series has been published.</p><p><a href="http://www.oracle.com/technetwork/articles/java/springtojavaee4-1592643.html">Spring to Java EE Migration, Part 4</a> </p><p>Part 4 compares equivalent functionality in Java EE and Spring, covering topics such as MVC design pattern implementation, data access, transaction management, and dependency injection. </p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/spring_to_java_ee_migrationSpring to Java EE Migration, Part 2David R. Heffelfinger2011-12-17T11:57:46+00:002011-12-17T11:57:46+00:00
<p><p><a href="http://www.oracle.com/technetwork/articles/java/springtojavaee2-1414289.html">Part 2</a> of my Spring to Java EE migration series has been published. </p><p>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. </p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/james_gosling_father_of_javaJames Gosling, Father of Java, Leaves GoogleDavid R. Heffelfinger2011-08-31T22:51:19+00:002011-09-01T13:22:26+00:00
<p><p>A while back, there were news all over the blogosphere about James <br/>
Gosling, father of Java, leaving Oracle shortly after the database giant<br/>
bought Sun Microsystems.</p><p> Gosling was unemployed for a while, but in March 2011, he went to work for Google. Today he published a <a href="http://nighthacks.com/roller/jag/entry/i_ve_moved_again">new blog entry</a>, announcing that he left Google to join a company called <a href="http://liquidr.com/">Liquid Robotics</a>, a company that makes an unmanned ocean vehicle called the Wave Glider.</p><p>I'm<br/>
surprised that Mr. Gosling decided to leave Google after less than six <br/>
months of employment; nevertheless I wish him the best of luck in his <br/>
new endeavors. I'm sure Liquid Robotics will benefit greatly from the <br/>
positive public relations of having the father of Java join their <br/>
company, and I'm sure they are hoping his tenure will be longer than the<br/>
one he had at Google.<br /></p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/reports_of_java_s_demiseReports of Java's Demise Have Been Greatly ExaggeratedDavid R. Heffelfinger2011-03-16T23:15:17+00:002011-03-17T12:48:50+00:00
<p><p>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?</p><p>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.</p><p>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.</p><p> 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.</p><p>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. <br /></p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/maven_pom_xml_configuration_forMaven pom.xml configuration for Servlet 3.0David R. Heffelfinger2009-09-23T00:13:57+00:002009-09-23T00:21:52+00:00
<p><p>Good old servlets are getting a facelift in the next major version of Java EE after been somewhat neglected for so long.</p><p>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.</p><p> 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.</p><p>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.</p><p>After some research, I found out how to configure Maven to avoid it complaining about this non issue. </p><p>Here is my pom.xml in it's entirety.</p><pre><span class="xml-tag"><project</span> <span class="xml-attribute">xmlns</span>=<span class="xml-value">"http://maven.apache.org/POM/4.0.0"</span><br /> <span class="xml-attribute">xmlns:xsi</span>=<span class="xml-value">"http://www.w3.org/2001/XMLSchema-instance"</span><br /> <span class="xml-attribute">xsi:schemaLocation</span>=<span class="xml-value">"http://maven.apache.org/POM/4.0.0 http://maven.apach</span><span class="xml-value">e.org/maven-v4_0_0.xsd"</span><span class="xml-tag">></span><br /> <span class="xml-tag"><modelVersion</span><span class="xml-tag">></span>4.0.0<span class="xml-tag"></modelVersion</span><span class="xml-tag">></span><br /> <span class="xml-tag"><groupId</span><span class="xml-tag">></span>net.ensode.glassfishbook<span class="xml-tag"></groupId</span><span class="xml-tag">></span><br /> <span class="xml-tag"><artifactId</span><span class="xml-tag">></span>simpleapp<span class="xml-tag"></artifactId</span><span class="xml-tag">></span><br /> <span class="xml-tag"><packa</span><span class="xml-tag">ging</span><span class="xml-tag">></span>war<span class="xml-tag"></packaging</span><span class="xml-tag">></span><br /> <span class="xml-tag"><version</span><span class="xml-tag">></span>1.0<span class="xml-tag"></version</span><span class="xml-tag">></span><br /> <span class="xml-tag"><name</span><span class="xml-tag">></span>simpleapp<span class="xml-tag"></name</span><span class="xml-tag">></span><br /> <span class="xml-tag"><url</span><span class="xml-tag">></span>http://maven.apache.org<span class="xml-tag"></url</span><span class="xml-tag">></span><br /> <span class="xml-tag"><build</span><span class="xml-tag">></span><br /> <span class="xml-tag"><finalName</span><span class="xml-tag">></span>simpleapp<span class="xml-tag"></final</span><span class="xml-tag">Name</span><span class="xml-tag">></span><br /> <span class="xml-tag"><plugins</span><span class="xml-tag">></span><br /> <span class="xml-tag"><plugin</span><span class="xml-tag">></span><br /> <span class="xml-tag"><groupId</span><span class="xml-tag">></span>org.apache.maven.plugins<span class="xml-tag"></groupId</span><span class="xml-tag">></span><br /> <span class="xml-tag"><artifactId</span><span class="xml-tag">></span>maven-war-plugin<span class="xml-tag"></artifactI</span><span class="xml-tag">d</span><span class="xml-tag">></span><br /> <span class="xml-tag"><version</span><span class="xml-tag">></span>2.1-beta-1<span class="xml-tag"></version</span><span class="xml-tag">></span><br /> <span class="xml-tag"><configuration</span><span class="xml-tag">></span><br /> <span class="xml-tag"><failOnMissingWebXml</span><span class="xml-tag">></span>false<span class="xml-tag"></failOnMissingWebXml</span><span class="xml-tag">></span><br /> <span class="xml-tag"></configuration</span><span class="xml-tag">></span><br /> <span class="xml-tag"></plugin</span><span class="xml-tag">></span><br /> <span class="xml-tag"><plugin</span><span class="xml-tag">></span><br /> <span class="xml-tag"><groupId</span><span class="xml-tag">></span>org.apache.maven.plugins<span class="xml-tag"></groupId</span><span class="xml-tag">></span><br /> <span class="xml-tag"><artifactId</span><span class="xml-tag">></span>maven-compiler-plugin<span class="xml-tag"></ar</span><span class="xml-tag">tifactId</span><span class="xml-tag">></span><br /> <span class="xml-tag"><configuration</span><span class="xml-tag">></span><br /> <span class="xml-tag"><source</span><span class="xml-tag">></span>1.6<span class="xml-tag"></source</span><span class="xml-tag">></span><br /> <span class="xml-tag"><target</span><span class="xml-tag">></span>1.6<span class="xml-tag"></target</span><span class="xml-tag">></span><br /> <span class="xml-tag"></configuration</span><span class="xml-tag">></span><br /> <span class="xml-tag"></plugin</span><span class="xml-tag">></span><br /> <span class="xml-tag"></plugins</span><span class="xml-tag">></span><br /> <span class="xml-tag"></build</span><span class="xml-tag">></span><br /> <span class="xml-tag"><repositories</span><span class="xml-tag">></span><br /> <span class="xml-tag"><repository</span><span class="xml-tag">></span><br /> <span class="xml-tag"><id</span><span class="xml-tag">></span>java.net<span class="xml-tag"></id</span><span class="xml-tag">></span><br /> <span class="xml-tag"><url</span><span class="xml-tag">></span>http://download.java.net/maven/2<span class="xml-tag"></url</span><span class="xml-tag">></span><br /> <span class="xml-tag"></rep</span><span class="xml-tag">ository</span><span class="xml-tag">></span><br /> <span class="xml-tag"></repositories</span><span class="xml-tag">></span><br /> <span class="xml-tag"><dependencies</span><span class="xml-tag">></span><br /> <span class="xml-tag"><dependency</span><span class="xml-tag">></span><br /> <span class="xml-tag"><groupId</span><span class="xml-tag">></span>junit<span class="xml-tag"></groupId</span><span class="xml-tag">></span><br /> <span class="xml-tag"><artifactId</span><span class="xml-tag">></span>junit<span class="xml-tag"></artifactId</span><span class="xml-tag">></span><br /> <span class="xml-tag"><v</span><span class="xml-tag">ersion</span><span class="xml-tag">></span>3.8.1<span class="xml-tag"></version</span><span class="xml-tag">></span><br /> <span class="xml-tag"><scope</span><span class="xml-tag">></span>test<span class="xml-tag"></scope</span><span class="xml-tag">></span><br /> <span class="xml-tag"></dependency</span><span class="xml-tag">></span><br /> <span class="xml-tag"><dependency</span><span class="xml-tag">></span><br /> <span class="xml-tag"><groupId</span><span class="xml-tag">></span>javax<span class="xml-tag"></groupId</span><span class="xml-tag">></span><br /> <span class="xml-tag"><artifactId</span><span class="xml-tag">></span>javaee-api<span class="xml-tag"></artifa</span><span class="xml-tag">ctId</span><span class="xml-tag">></span><br /> <span class="xml-tag"><version</span><span class="xml-tag">></span>6.0-SNAPSHOT<span class="xml-tag"></version</span><span class="xml-tag">></span><br /> <span class="xml-tag"><scope</span><span class="xml-tag">></span>compile<span class="xml-tag"></scope</span><span class="xml-tag">></span><br /> <span class="xml-tag"></dependency</span><span class="xml-tag">></span><br /> <span class="xml-tag"></dependencies</span><span class="xml-tag">></span><br /><span class="xml-tag"></project</span><span class="xml-tag">></span><br /><br /></pre>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<span class="xml-tag"><span style="font-family: monospace;"> </span><failOnMissingWebXml</span><span class="xml-tag">> </span>tag yet.<style type="text/css"><!--<br/>
body {color: #000000; background-color: #ffffff; font-family: Monospaced}<br/>
table {color: #000000; background-color: #e9e8e2; font-family: Monospaced}<br/>
.xml-attribute {color: #009900}<br/>
.xml-value {color: #ce7b00}<br/>
.xml-tag {color: #0000e6}<br/>
--><br/>
</style></p>
http://mail.ensode.net/roller/dheffelfinger/entry/jasperreports_3_5_for_javaJasperReports 3.5 For Java Developers PublishedDavid R. Heffelfinger2009-08-13T22:08:18+00:002009-08-13T22:14:00+00:00
<p><p>I'm proud to announce that the second edition of my <a href="http://www.packtpub.com/jasperreports-3-5-for-java-developers/book">JasperReports book, JasperReports 3.5 for Java Developers</a> has been published.</p><p>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:<br /></p><p>Chapter 1: An Overview of JasperReports<br />Chapter 2: Adding Reporting Capabilities to our Java Applications<br />Chapter 3: Creating your First Report<br />Chapter 4: Creating Dynamic Reports from Databases<br />Chapter 5: Working with Other Datasources<br />Chapter 6: Report Layout and Design<br />Chapter 7: Adding Charts and Graphics to Reports<br />Chapter 8: Other JasperReports Features<br />Chapter 9: Exporting to Other Formats<br />Chapter 10: Graphical Report Design with iReport<br />Chapter 11: Integrating JasperReports with Other Frameworks</p><p>The full table of contents can be found <a href="http://www.packtpub.com/article/jasperreports-3-5-for-java-developers-table-of-contents">here</a>.<br /></p><p> I also added JPA integration as part of the chapter on JasperReports integration with other frameworks.</p><p>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 <a href="https://www.packtpub.com/article/creating-dynamic-reports-from-databases-jasperreports-3.5">generating reports from database data</a>. </p><p>Also, chapter 10, <a href="http://www.packtpub.com/files/8082-jasper-reports-3-1-2nd-edition-sample-chapter-10-graphical-report-design-with-iReport.pdf">Graphical Report Design with iReport</a>, is available for free, no registration required.<br /></p><p><br /></p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/apache_derby_insecure_by_defaultJava DB / Apache Derby: Insecure By DefaultDavid R. Heffelfinger2009-08-08T02:14:57+00:002009-08-08T21:24:21+00:00
<p><p>Both JDK 1.6 and GlassFish come bundled with Java DB, which is nothing but a rebranded Apache Derby RDBMS. If you have ever done anything with Derby, you know that a database can be created by simply by passing the <code>create</code> attribute with a value of <code>true</code>. For example, to create a database on a server called myserver.com, all that is needed is to use the following JDBC URL:</p><p><code>jdbc:derby://myserver.com:1527/mydb;user=foo;password=bar;create=true</code></p><p>The above JDBC URL will create a database called "mydb", and, in Derby/Java DB, the default schema matches the user name, so the above URL will create a schema called "foo" and set it as the default schema. <br /></p><p>This is great in the sense that creating a database is very easy, but it is not so great in the sense that it allows anybody to create a database on the server and do whatever they want with it. </p><p>If this wasn't bad enough, by default passwords are ignored, therefore, with the default configuration in place, anybody can connect to the database as user "foo", for example, the following JDBC URL would connect you just fine:</p><p> <code>jdbc:derby://myserver.com:1527/mydb;user=foo;password=aaa</code></p><p>Notice that in this second JDBC URL, the password is different than the one we used when we created the database, it doesn't matter, in the default Derby configuration, the password is ignored, it is as if it didn't exist, therefore this URL would allow us to log in just fine. <br /></p><p>Standalone Derby / Java DB only listens for connections from localhost, so in this case the default behavior is not too bad (there is still some security risk in a server with multiple users, however random people cannot connect through the network and create databases/log in to a database willy nilly).</p><p>However, GlassFish comes bundled with Java DB/Derby. When starting the database through GlassFish's asadmin utility:</p><p><code>asadmin start-database</code></p><p>The database by default listens accepts network connections. Unfortunately all other (lack of) security defaults stay in place, therefore with GlassFish's JavaDB's default configuration, random Joe's out there can connect to our databases without using a password, and can also create their own databases. This is a major security hole.</p><p>Luckily, Java DB/Derby can be easily configured to require valid user credentials, it is unfortunate that it is not configured this way by default. There are various ways to configure authentication in Derby/Java DB, it can be "hooked up" to an LDAP server, additionally, custom code can be written to handle authentication, and finally, a property file can be written set up authentication. The <a href="http://db.apache.org/derby/docs/10.5/devguide/devguide-single.html#cdevcsecure42374">Derby Developer's Guide</a> has all the details, in this entry, I'll just explain the simplest way, in case you are panicking because I just made you realized your database is exposed to the world.</p><p>The property file to create to enable authentication has to be called <code>derby.properties</code> it should look something like this:</p><p><code>derby.connection.requireAuthentication=true<br />derby.authentication.provider=BUILTIN<br /><br /># Users definition<br />derby.user.someusername=password1<br />derby.user.john=doe</code><br /></p><p><code>derby.connection.requireAuthentication=true</code> tells Derby/Java DB that authentication is required.</p><p><code>derby.authentication.provider=BUILTIN</code> sets up Derby to use its internal, built-in authentication mechanism.</p><p>After setting the above two properties, we need to add some users, they are added as shown in the above sample <code>derby.properties</code> file, properties preceeded by "derby.user." are understood to be users, the user name is the string immediately following "derby.user.", and the password is the value to the right of the equal sign. For example, if we wanted to add another user with a username of "joe", and a password of "secret", we would add the following line to <code>derby.properties</code>:</p><p><code>derby.user.joe=secret</code></p><p>Once we have created this file, we need to put it in <code>$DERBY_HOME/bin</code> if we are using the standalone Java DB/Derby or the Java DB version that is bundled with JDK 1.6. Java DB is placed under <code>$JAVA_HOME/db</code> in in Linux and under <code>C:\Program Files\Sun\JavaDB</code> in Windows.</p><p>If we are using the Java DB version that is included with GlassFish, then the <code>derby.properties</code> file needs to be placed under <code>$GLASSFISH_HOME/databases</code>, where <code>$GLASSFISH_HOME</code> is the directory where GlassFish is installed.</p><p>After copying the file to the appropriate location, the Java DB/Derby needs to be restarted for the changes to take effect.<br /></p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/a_slightly_biased_comparison_betweenA Slightly Biased Comparison Between Wicket and JSFDavid R. Heffelfinger2009-06-07T15:32:57+00:002009-06-26T12:51:14+00:00
<p><p>Recently I will start working on a project using <a href="http://wicket.apache.org/">Wicket</a>. I used Wicket briefly in the past, I wrote an <a href="http://www.ensode.net/wicket_first_look.html">article</a> about it and even worked as a technical reviewer for a <a href="http://www.amazon.com/gp/product/1590597222?ie=UTF8&tag=ensode-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=1590597222">book on Wicket</a>, but I have never used it in production systems.</p><p>On the other hand, I have written <a href="http://www.packtpub.com/java-ee5-development-with-netbeans-6/book/mid/300409j09bxs">two</a> <a href="http://www.packtpub.com/Java-EE-5-GlassFish-Application-Servers/book/mid/3004097xp943">books</a> that cover JSF, I also teach a <a href="http://www.learningtree.com/courses/936.htm">class</a> that covers JSF development, and I have worked on some projects that use JSF in production. As the author of two books that cover JSF, I have a vested interest in having JSF remain popular, therefore I am obviously somewhat biased, however I'll try to be as objective as possible when making this comparison. </p><p>All of my Wicket experience happened a few years ago, I haven't used it much in about three years, so for the past few days I've been refamiliarizing myself with this framework.</p><p>When comparing Wicket with plain vanilla JSF wicket is the clear winner. The fact that the markup in Wicket is plain HTML (with special wicket specific attributes) makes Wicket much more accessible, since no special knowledge of Wicket components is needed to come up with the markup. This allows web designers to do what they do best, design their user interfaces with their preferred tools such as Dreamweaver or other web design tools. The changes to the markup to make it work with Wicket are minimal, the wicket specific attributes need to be added to HTML tags that will be replaced at runtime with Wicket components. However, very few people use "vanilla" JSF. Most JSF developers use a component library such as ICEFaces or RichFaces. Furthermore, Facelets is a very popular view technology that can also use standard XHTML to develop JSF views. When component libraries and Facelets enter the picture, picking a winner is not so easy.</p><p>The fact that Wicket uses standard HTML for its markup may be an advantage or a disadvantage depending on your situation. If you are working with a professional web designer, then having straight HTML as markup is a real advantage. However, if your team consists primary of Java developers with little or no web design skills, then using a JSF component library that renders its pages using predefined CSS and Javascript, then in this case JSF may have the advantage.</p><p>Wicket reminds me a lot of working with Facelets, when using Facelets, we can develop pages that are plain XHTML, however we are not prohibited from using JSF specific tags. When previewing a Facelets page in the browser, the JSF specific tags are simply ignored.</p><p>Wicket also has some Wicket specific tags, however they are used to ignore parts of the HTML when it is rendered in the browser and other functionality, they are not really meant to be rendered. On the other hand, HTML tags in Wicket can have an wicket id corresponding to a component that renders HTML on the page, for example, a <code><span></code> tag could map to a custom Wicket component, therefore, a Wicket page may not preview exactly like it will be rendered when the application is deployed, which is the case with Facelets as well.</p><p>My impression on which one is better is, like in most cases, it depends. If a professional web designer is available, then Wicket may be the better choice, however if most of the development team are backend Java developers, then using JSF with Facelets plus a component library such as IceFaces or RichFaces may be a better choice.<br /></p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/confessions_of_a_java_snobConfessions of a Java SnobDavid R. Heffelfinger2009-05-23T12:34:21+00:002009-06-26T11:47:24+00:00
<p><p>For the past couple of months I've been working on porting a PHP application to Java EE using JSF, JPA and EJB 3 (in case you are wondering, yes, I've been using <a href="http://www.packtpub.com/java-ee5-development-with-netbeans-6/book/mid/300409j09bxs">NetBeans</a> and <a href="http://www.packtpub.com/Java-EE-5-GlassFish-Application-Servers/book/mid/3004097xp943">GlassFish</a>). </p><p>I've never had any real exposure to PHP, so this is a new experience for me. I'm not sure if what I'm seeing is typical PHP code, but comparing this legacy system to the typical enterprise Java system shows some striking differences in architecture. When analyzing the PHP code, it became obvious to me that the mindset of PHP developers is very different from your typical Java developer. </p><p>In the Java world, we love our design patterns, we can't live without our DAO's and MVC. In PHP, it seems to be no big deal to mix presentation, business logic and data access in a single file.</p><p>Having worked with Java for over 13 years and Java EE/J2EE for about 10 years, I have to confess that the architecture (if you can call it that, more like "lack of architecture") seemed appalling to me. In the enterprise Java world, we've been conditioned to think that separation of concerns is a good thing. </p><p>Our presentation logic should contain presentation only, that way if in the future we want to switch say, from straight JSPs and servlets to JSF, the rest of the code shouldn't be affected. Additionally, if we want to convert our web application to a desktop application using Swing, it should be fairly straightforward to do so.</p><p>Data access logic should be done via Data Access Objects (DAO's), that way if today we are using straight JDBC and tomorrow we want to use an object relational mapping tool such as JPA or Hibernate, all we need to do is change the data access layer, the rest of the code should not be affected.</p><p>Communication between layers in our applications should be done via Value Objects, which shouldn't really change if we change our data access layer or presentation layer.</p><p>Controllers should manage flow from one page to another, again these should only be rewritten if we change our presentation layer. Most Java web application frameworks provide their own controllers, however they are not self sufficient, for example, in Struts we need to use Actions and in JSF we need to write managed beans, therefore changing the presentation layer would usually involve changing the controller as well.</p><p>After analyzing the code for the legacy system I got the impression that PHP is a language for amateurs and Java/J2EE/Java EE is for professional software engineers and architects. Am I right? Or I am just a Java snob? Feel free to set me straight.<br /></p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/solving_jasperreports_dependencies_with_ivySolving JasperReports Dependencies with IvyDavid R. Heffelfinger2009-02-27T04:04:20+00:002009-06-26T11:46:44+00:00
<p><p>Lately, I've been doing some work with <a href="http://www.amazon.com/gp/product/1904811906?ie=UTF8&tag=ensode-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=1904811906">JasperReports</a>. On my previous JasperReports projects, I've either used Maven, which automatically takes care of resolving dependencies, or I have simply downloaded the project's dependencies by hand.</p><p>Using Maven is nice, since it resolves dependencies, however, JasperReports comes with a series of useful ANT tasks to compile reports, preview them etc. I wanted access to these tasks and I also wanted dependency management.</p><p>There were a couple of ways I could achieve both. I know ANT targets can be called from Maven, this could be one approach. Also, there is a dependency manager for ANT called <a href="http://ant.apache.org/ivy/">Ivy</a>. I had briefly used Ivy before, I thought I would try this approach.</p><p>Ivy works by adding a series of custom ANT tasks, installing Ivy is very simple, all that needs to be done is to copy the Ivy jar file to <code>${ANT_HOME}/lib</code>. Once Ivy is installed, custom Ivy tasks are available in our ANT build files.</p><p>Some additional configuration needs to be done in an Ivy specific XML file, named <code>ivy.xml</code>. In this file is where we actually specify our dependencies.</p><p>I set up my project to depend on JasperReports and tried to have Ivy automatically download all of JasperReports dependencies, unfortunately the build failed, complaining about some missing dependencies, specifically mondrian and commons-javaflow.</p><br/>
<code><br/>
</code><pre>[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::<br />[ivy:retrieve] :: UNRESOLVED DEPENDENCIES ::<br />[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::<br />[ivy:retrieve] :: commons-javaflow#commons-javaflow;20060411: not found<br />[ivy:retrieve] :: mondrian#mondrian;2.3.2.8944: not found<br />[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::<br />[ivy:retrieve] <br />[ivy:retrieve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS<br /><br /></pre><br/>
<p>After some googling, some head scratching (and some hair pulling and banging on the table for good measure), I found out what was going on.</p><p>JasperReports has some optional dependencies declared in its pom.xml, these dependencies are not downloaded by default when using Maven, however Ivy attempts to download them. For some reason these dependencies do not exist in the repository, because of this the ANT build fails.</p><p> After some research, I found out the necessary modifications to ivy.xml to make the build succeed:</p><br/>
<pre><code><br /><ivy-module version="2.0"><br /> <info organisation="ensode" module="mymodule"/> <br /> <dependencies><br /> <dependency org="jasperreports" name="jasperreports" rev="3.1.2" conf="*->default"/><br /> </dependencies><br /></ivy-module></code></pre><p>What I had to do was to use the conf attribute of the <dependency> tag to specify that I wanted that configuration for this particular dependency. The *-> default means that all your module configurations depend on the 'default' configuration of JasperReports, as explained by Xavier Hanin in <a href="http://marc.info/?l=ivy-user&m=117535946700563&w=2">this message</a> of the Ivy users mailing list.<br /></p><p>After making this change, Ivy was able to successfully download all JasperReports dependencies.</p><pre><code>[ivy:retrieve] commons-beanutils#commons-beanutils;1.8.0 by [commons-beanutils#commons-beanutils;1.7.0] in [runtime]<br /> ---------------------------------------------------------------------<br /> | | modules || artifacts |<br /> | conf | number| search|dwnlded|evicted|| number|dwnlded|<br /> ---------------------------------------------------------------------<br /> | runtime | 14 | 12 | 12 | 2 || 11 | 11 |<br /> ---------------------------------------------------------------------<br /></code></pre><br/>
<p>I figured I would document this procedure in case others are having similar issues.<br /></p>
<p></p></p>
http://mail.ensode.net/roller/dheffelfinger/entry/common_jpa_questionsCommon JPA QuestionsDavid R. Heffelfinger2009-02-21T18:30:10+00:002009-06-26T12:49:38+00:00
<p><ol><br/>
<li>How can I have a composite primary key in JPA?<br /><br/>
There are several ways to do it, <a href="http://download.oracle.com/docs/cd/B32110_01/web.1013/b28221/cmp30cfg001.htm">this page</a> explains them.<br /><br/>
</li><li>How can I prevent users from overwriting each other's changes to the database?<br /><br/>
Use the <a href="http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html#Version">@Version</a> annotation.<br /><br/>
</li><li>Is there a way to do bulk updates and/or deletes with the Java Persistence Query Language (JPQL)?<br /><br/>
<a href="http://download.oracle.com/docs/cd/E11035_01/kodo41/full/html/ejb3_langref.html#ejb3_langref_bulk_ops">Yes</a>.<br /><br/>
</li></ol></p>
http://mail.ensode.net/roller/dheffelfinger/entry/upgraded_to_roller_4_0Upgraded to Roller 4.0.1David R. Heffelfinger2009-02-21T16:29:38+00:002009-06-26T12:49:22+00:00
<p>Since I <a href="http://ensode.net/roller/dheffelfinger/entry/java_db_apache_derby_upgraded">just upgraded JavaDB</a>, I figured this was a good time to upgrade to the latest version of <a href="http://roller.apache.org/">roller</a> as well. I was using roller 4.0, which is fairly up to date, but I figured it wouldn't hurt to upgrade to the latest, 4.0.1.</p>
<p>I simply downloaded roller 4.0.1, created a war file from the roller directory and deployed it to GlassFish, but for some reason the upgrade didn't go smoothly, I kept getting a "Roller Weblogger has not been bootstrapped yet" error.</p>
<p>I tried various ways of deploying, using <code>asadmin</code>, copying the war file to the autodeploy folder, etc, but I kept getting the same error. I restarted GlassFish several times, I restarted the database (JavaDB/Derby) several times, nothing seemed to solve the problem.</p>
<p>I then decided to reinstall roller 4.0 (thank goodness I made a backup), and it came back up successfully. After doing this, I then redeployed roller 4.0.1 using a different temporary context root, and this time, it installed successfully, asking me to upgrade the database. I did upgrade the database (the only thing that needs to be done when going from roller 4.0 to roller 4.0.1 is change the version number), and I had both roller 4.0 and 4.01 running in parallel with different context roots.</p>
<p>I then undeployed roller 4.0, and changed the context root of 4.0.1 to match the one I had in 4.0 (/roller), I am now in business.</p>
<p>Why wouldn't roller 4.0.1 just install over 4.0 is anyone's guess, however I was glad I was able to work around the issue.</p>
http://mail.ensode.net/roller/dheffelfinger/entry/java_ee_5_reference_materialJava EE 5 Reference MaterialDavid R. Heffelfinger2009-02-15T17:29:07+00:002009-06-26T13:06:39+00:00<div style="float: left; margin-right: 10px;">
<iframe frameborder="0" scrolling="no" src="http://rcm.amazon.com/e/cm?t=ensode-20&o=1&p=8&l=as1&asins=1847195466&md=10FE9736YVPPT7A0FBG2&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width: 120px; height: 240px;" marginwidth="0" marginheight="0"></iframe>
<br />
<iframe frameborder="0" scrolling="no" src="http://rcm.amazon.com/e/cm?t=ensode-20&o=1&p=8&l=as1&asins=1847192602&md=10FE9736YVPPT7A0FBG2&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width: 120px; height: 240px;" marginwidth="0" marginheight="0"></iframe>
<br />
</div><p>
<b>My Books</b></p><p>Two of my books cover Java EE 5, one focuses on GlassFish deployment, the other focuses on developing using NetBeans. <br /></p><li><a href="http://www.amazon.com/gp/product/1847192602?ie=UTF8&tag=ensode-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=1847192602">Java EE 5 Development using GlassFish Application Server</a><img height="1" border="0" width="1" style="border: medium none ! important; margin: 0px ! important;" src="http://www.assoc-amazon.com/e/ir?t=ensode-20&l=as2&o=1&a=1847192602" /> -
<a href="http://java-ee-5-glassfish.packtpub.com/GlassFish-Sample-Chapter-Chapter-6-JavaServer-Faces.pdf">free chapter on JSF</a></li>
<li><a href="http://www.amazon.com/gp/product/1847195466?ie=UTF8&tag=ensode-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=1847195466">Java EE 5 Development with NetBeans 6</a><img height="1" border="0" width="1" src="http://www.assoc-amazon.com/e/ir?t=ensode-20&l=as2&o=1&a=1847195466" style="border: medium none ! important; margin: 0px ! important;" />
- <a href="http://www.packtpub.com/files/java-ee-5-development-with-netBeans-6-sample-chapter-chapter-4-developing-web-applications-using-javaserver-faces.pdf">free chapter on JSF</a></li><p><b>Java EE</b> </p><p>The Java EE 5 Tutorial covers most aspects of Java EE 5. Examples can be downloaded as NetBeans projects. <br /></p>
<li><a href="http://java.sun.com/javaee/5/docs/tutorial/doc/">Java EE 5 Tutorial</a></li>
<li><a href="http://blog.rueedlinger.ch/2008/11/ejb-31-and-jsf-20-with-glassfish-v3-prelude/">Java EE 6 (JSF 2.0, EJB 3.1)</a></li><p><b>JSF</b> </p><p>JavaServer Faces is the standard component framework for Java EE 5.<br /></p><li><a href="http://www.exadel.com/tutorial/jsf/jsftags-guide.html">JSF HTML Tag reference</a>
</li>
<li><a href="http://www.ibm.com/developerworks/java/library/j-jsf3/">JSF Custom Conversion and Validation</a> <br /></li>
<li><a href="http://www.comesolvego.com/2008/04/30/jsf-phaselisteners-in-action-image-rendering-back-button-simple-security/">JSF Phase Listeners</a> </li>
<li><a href="https://facelets.dev.java.net/nonav/docs/dev/docbook.html">Facelets</a></li><li><a href="http://www.jsfmatrix.net/">JSF Component Library Matrix</a></li>
<li><a href="http://www.laliluna.de/javaserver-faces-message-resource-bundle-tutorial.html">JSF Localization</a></li>
<p><b>JPA</b> </p><p>The Java Persistence API is the standard Object Relational Mapping (ORM) tool for Java EE 5. It takes the best ideas from Hibernate and other ORM tools and incorporates them into the standard.<br /></p>
<li><a href="http://download.oracle.com/docs/cd/B32110_01/web.1013/b28221/cmp30cfg001.htm">JPA Composite Primary Keys</a>
</li><li><a href="http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html#Version">JPA Optimistic Locking using <code>@Version</code> annotation</a>
</li><li><a href="http://download.oracle.com/docs/cd/E11035_01/kodo41/full/html/ejb3_langref.html">JPQL Reference</a></li><br />http://mail.ensode.net/roller/dheffelfinger/entry/openportal_first_impressionsOpenPortal First ImpressionsDavid R. Heffelfinger2008-11-01T14:04:02+00:002008-11-01T14:05:36+00:00<p>I recently got involved in a project that may need some portlet development. The project is a completely new application to be built from the ground up.</p>
<p>
The customer has been using <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2FDevelopment-using-GlassFish-Application-Server%2Fdp%2F1847192602%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1225544166%26sr%3D8-2&tag=ensode-20&linkCode=ur2&camp=1789&creative=9325">GlassFish</a><img src="http://www.assoc-amazon.com/e/ir?t=ensode-20&l=ur2&o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> as their application server and they are very pleased with it, therefore it just makes sense to continue using it.
</p>
<p>
The <a href="https://portlet-container.dev.java.net/">OpenPortal Portlet Container</a> can be installed in <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2FDevelopment-using-GlassFish-Application-Server%2Fdp%2F1847192602%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1225544166%26sr%3D8-2&tag=ensode-20&linkCode=ur2&camp=1789&creative=9325">GlassFish</a><img src="http://www.assoc-amazon.com/e/ir?t=ensode-20&l=ur2&o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> from its update tool, therefore it made sense to try it out.
</p>
<img src="http://www.ensode.net/roller/dheffelfinger/resource/gf_update_center_portlet_container.png" alt="GlassFish Update Center"/>
<p>
Once installed, I also installed the <a href="http://portalpack.netbeans.org/">NetBeans Portal Pack</a> plugin from NetBeans 6.5 RC2, that can be installed directly from the NetBeans Plugin Manager.
</p>
<img src="http://www.ensode.net/roller/dheffelfinger/resource/nb_plugin_manager_openportal.png" alt="NetBeans Plugin Manager"/>
<p>
The plugin makes deploying portlets to OpenPortal a breeze, as can be seen in this <a href="http://portalpack.netbeans.org/demos/ospc20-nb6-beta1/index.html">flash demo</a>.
</p>
<p>
My main complaint? The default look and feel of the portlet is, let's just say, not the best looking.
</p>
<img src="http://ensode.net/roller/dheffelfinger/resource/openportal_default_look.png" alt="OpenPortal default look"/>
<p>
As far as I can tell the only way to change the default look is to hack the CSS and JSPs by hand. I noticed the icons to minimize a portlet, maximize it, edit it, etc had transparent backgrounds, therefore it gave me some hope that they should be able to be used when simply changing the background color of the portlet bar. I made a simple modification to the CSS to test this, unfortulately it seems like some of the pink background creeped into the icons.
</p>
<img src="http://ensode.net/roller/dheffelfinger/resource/openportal_modified_look.png" alt="OpenPortal modified look"/>
<p>
Also, as far as I can tell, modifying the available tabs to match our application requirements will involve some customizations of the JSPs included with OpenPortal, there is no tool to create or modify tabs as necessary.
</p>
<p>
Even with these disadvantages, I'm leaning towards using OpenPortal if we in fact turn out to need portlets for this project. The tight integration with GlassFish and NetBeans is a great advantage and I can live with having to do some CSS and JSP hacking to make it look the way we need it to look.
</p>http://mail.ensode.net/roller/dheffelfinger/entry/jre_6u12_to_include_javaJRE 6u12 to include Java Plugin for 64 bit LinuxDavid R. Heffelfinger2008-10-17T22:02:39+00:002009-06-26T12:59:56+00:00
<p>For the longest time, 64 bit versions of the Java Runtime Environment (JRE) and Java Development Kit (JDK) have not included a Java Plugin.</p>
<p>This fact has let us 64 bit Linux users out in the cold when it comes to running Java applets in our operating system of choice. There are workarounds, but they involved downloading a 32 bit browser and a 32 bit JRE, a less than ideal solution.</p>
<p>There has been a <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4802695">bug in Java's bug parade</a> reporting this issue (submitted in 2003!), finally, today I got notice that this issue will finally be addressed.</p>
<p>According to the comments in the bug report, JRE 6u12 will include a Java plugin for 64 bit Linux, freeing us from jumping through hoops to be able to execute Java applets under 64 bit Linux.</p>
<p>JRE 6u12 is scheduled to be released early 2009.</p>
http://mail.ensode.net/roller/dheffelfinger/entry/installing_the_java_plugin_onInstalling the Java Plugin on Ubuntu 64 bitDavid R. Heffelfinger2008-10-17T16:55:36+00:002009-06-26T11:52:36+00:00
<p>Recently I acquired a new client that has a lot of client side Java technology as part of their infrastructure. A lot of this infrastructure is in the form of Java applets.</p>
<p>My primary operating system is Ubuntu Hardy 64 bit. Unfortunately there is still no Java plugin for the 64 bit Linux version of Firefox, therefore, I was finding myself having to boot to Windows to be able to use some of these utilities.</p>
<p>Since I am much more comfortable in a Unix environment, I wanted to find a solution to run this software on my Linux laptop. I knew from past experience that a 32 bit version of Firefox can be installed under 64 bit Linux, and a 32 bit JRE can be installed as well, and the 32 bit firefox can be made to work with the 32 bit JVM.</p>
<p>I searched around and found <a href="http://ubuntuforums.org/showthread.php?p=1174435">this thread</a> in the Ubuntu forums, which provides a link to a script that will install the 32 version of Firefox, along with the 32 bit version of the Java plugin and other plugins such as Flash. I downloaded the script and ran it, but unfortunately Java applets were still not working, at least I had 32 bit Firefox in place.</p>
<p>In order to get the Java plugin under Firefox 32, I had to download the 32 bit JRE from <a href="http://www.java.com">java.com</a>, since Ubuntu is a deb based distribution (as opposed to RPM based), the right version to download is the self extracting file.</p>
<p>After downloading the JRE, it needs to be installed, which can be done by simply executing the downloaded shell script as root. I installed mine under <code>/opt</code>.</p>
<p>Once the JRE is installed, I had to <code>cd</code> to my home directory, then <code>cd to <code>.mozilla. At this point, I had to create a <code>plugins</code> subdirectory, and <code>cd</code> to it. </p>
<p>Then I needed to create a symlink for the Java plugin in the downloaded JRE to the <code>~/.mozilla/plugins</code> directory: <code>ln -s /opt/jre32/jre1.6.0_10/plugin/i386/ns7/libjavaplugin_oji.so ~/.mozilla/plugins</code>.</p>
<p>At this point I started the 32 bit version of Firefox, navigated to a <a href="http://java.com/en/download/installed.jsp?detect=jre&try=1">test page</a> and verified that my Java plugin was working properly.</code></code></p>
http://mail.ensode.net/roller/dheffelfinger/entry/facelets_to_be_integrated_inFacelets To Be Default View Technology in JSF 2.0David R. Heffelfinger2008-10-15T23:53:19+00:002008-11-05T23:36:56+00:00
<p>By default, JSF 1.2 uses JSP as its view technology, however JSF was designed to be very modular, allowing defaults to be swapped out for alternative technologies.</p>
<p>Facelets, by Jacob Hookom, is an alternate view technology for JSF. The main advantage of Facelets is that pages are written using standard XHTML, which allows web designers to freely design the pages, using design tools such as Dreamweaver. Using Facelets allows a true separation of concerns, with web designers designing the user interface of the system, and Java developers implementing the functionality.</p>
<p>Another advantage of Facelets is that it provides templating for JSF. Facelets templating is similar in functionality to tools such as <a href="http://www.opensymphony.com/sitemesh/">Sitemesh</a> and <a href="http://tiles.apache.org/">Apache Tiles</a>. Using Facelets templates, common areas of all pages in the application, such as headers, footers and navigation menus, can be placed in in separate files, and they are "included" by all pages in the application. Templating allows us to make changes to these common areas in a single file, and they are "inherited" by all pages in the application, greatly simplifying maintenance.</p>
<p>Until now, in order to take advantage of Facelets additional dependencies had to be added to our project, since Facelets was non standard. Well, according to <a href="http://blogs.sun.com/arungupta/entry/totd_48_converting_a_jsf">Arun Gupta</a> and <a href="http://weblogs.java.net/blog/edburns/archive/2008/08/facelets_jsf_20.html">Ed Burns</a>, Facelets will become the default JSF technology as of JSF 2.0. This will be a great step in simplifying JSF application development.</p>
<p>Arun Gupta has a <a href="http://blogs.sun.com/arungupta/entry/totd_48_converting_a_jsf">very nice tutorial<a/> explaining how to get started developing JSF 2.0 applications under GlassFish today.</p>
http://mail.ensode.net/roller/dheffelfinger/entry/excel_unlock_utilityExcel Unlock UtilityDavid R. Heffelfinger2008-10-11T14:57:23+00:002008-10-11T14:57:23+00:00
<p>After I implemented and deployed the <a href="http://www.ensode.net/pdf-crack.jsf">PDF Unlocking Tool</a>, I was fortunate to find out it became very popular. Apparently I had written and deployed a useful tool.</p>
<p>It's popularity got me thinking, what else I could write that would be helpful to others? Then it hit me, just like PDF files are sometimes restricted, preventing users from copying and pasting their content, sometimes Excel spreadsheets contain locked, uneditable cells.</p>
<p>I started looking around for Java libraries to manipulate Excel spreadsheets, and found <a href="http://jexcelapi.sourceforge.net/">JExcelAPI</a>. I started researching this library and sure enough, I found a way to unlock cells in an Excel spreadsheet.</p>
<p>Using this API, I developed an online utility to unlock cells in a spreadsheet, which can be found at <a href="http://www.ensode.net/xls-crack.jsf">http://ensode.net/xls-crack.jsf</a>. It soon became a very popular destination on my site.</p>