Wednesday Oct 22, 2014

Themes/Resource Library Contracts in JSF 2.2/Java EE 7

Resource Library Contracts are one of the big ticket features in JSF 2.2. There's actually quite a bit to the feature - it allows for logical organization and packaging of the theme/look-and-feel/template for JSF pages. Beyond enabling better modularity, the feature makes it possible to switch page themes at runtime (much like PrimeFaces, RichFaces, etc did in the past). Huseyin Akdogan explains the details of resource library contracts in a code-intensive post. You should also checkout the video below from the GlassFish Videos YouTube channel in which specification lead Ed Burns covers the feature along with JSF 2.2 generally (the video is pretty short - just about fifteen minutes).

The official Java EE 7 Tutorial has a decent section on the basics of  resource library contracts as well.

Tuesday Oct 21, 2014

New book: RESTful Java Patterns and Best Practices

RESTful Java Patterns and Best Practices” written by ’Bhakti Mehta' has been recently published. One of the great thing about this book is that it is not a theoretical book covering the JAX-RS API 2.0. As its title suggest, this book is talking about different best practices that are relevant when it comes to build efficient, scalable and secure RESTful services. So the focus of the book is really on REST best practices. It then shows how you can apply the practices and patterns using the JAX-RS 2.0 APIs.

Some of the covered practices discussed are:

  • How to design and expose your resources
  • Error handling 
  • API versioning
  • Testting
  • Security
  • Caching
  • Asynchronous behaviours, etc.

Another aspect I particularly like about this book is that it also covers features that are not yet part of the standard. It should be mentioned that some of those features (e.g. SSE, JSON-Pointers, ...) will high likely be introduced in Java EE 8. So the book give some useful background material to understand why it would make sense to add those capabilities to the platform.

Finally, the book is really trying to not overload you with too many details, with too much information. For each of the discussed topic, a technical solution is presented and explained. Pointers to additional ressources are then also suggested in case you need to dig into a specific topic in more details.

All in all, this book is a nice reading for anybody designing RESTful based applications... and who isn't?

To celebrate this, Packt Publishing will raffle 10 copies of  “RESTful Java Patterns and Best Practices” (5 eBook copies and 5 paper copies). To participate, just leave a comment about the book on your preferred social media using the 'http://bit.ly/1uUs7QR' URL and the '#JavaBhakti' hashtag. PackT will randomly select 10 lucky persons.

Please do note that Oracle is not involved in this raffle, we are just relaying this information. For any question about this raffle, please contact Packt Publishing directly.

Monday Oct 20, 2014

Why Another MVC Framework in Java EE 8?

Some of you may be aware that MVC 1.0 was launched as JSR 371. Targeted for Java EE 8 the goal of the JSR is to provide a standards based action-oriented web framework for Java EE. 'Why' and 'why now' are two perfectly reasonable questions to explore carefully with regards to this JSR. After all JSF has long been included in Java EE as a standards based MVC web framework. In addition although JSF is a component-oriented web framework there are myriad Java web frameworks that are action-oriented including ones that are very Java EE/CDI friendly such as VRaptor (indeed we had a session on VRaptor at JavaOne 2014).

There's little doubt the web framework space in Java has long been hyper-competitive. There are myriad camps each of which insist their way is the "right" way. Nonetheless in most reliable analysis two schools of thought have consistently come out on top for a number of years - component-oriented frameworks (led largely by JSF) and action-oriented frameworks (lately led by Spring MVC but long dominated by Struts). As a result it has been an open question whether Java EE should support both models much in the same way that .NET has done with ASP.NET and ASP.NET MVC. To put this question to rest we included it in the Java EE 8 survey. Despite all the factors above it turned out that the core Java EE community does in fact see the need to include a standard action-oriented web framework in Java EE, which brings us where we are with MVC 1.0. To answer some of the questions that should naturally arise none other than JSF specification lead Ed Burns put together a very nice analysis piece on OTN that's well worth a read. Red Hat's MVC 1.0 expert group representative Joshua Wilson has done the same as well.

It's obviously not  possible to construct an entirely unbiased pro/con analysis matrix for choosing between these two perhaps equally valid major approaches to Java server-side web frameworks. That being said I've tried to encapsulate some of the salient concerns in the graphic below.

I have years of real world development experience with both approaches in case you are wondering; I also favor JSF personally in case you were wondering but see both perspectives. In my view, component frameworks like JSF do extremely well in offering the closest approximation to Smalltalk's original MVC concept, reduce boilerplate to the bare minimum by almost entirely automating controllers/navigation/state handling/event dispatch and truly enable writing re-usable web components. These characteristics shine particularly bright with purpose-built component libraries like PrimeFaces that do a lot of the HTML, JavaScript, CSS heavy lifting for you. However because JSF is a higher level framework that cleverly abstracts away a lot of the underlying HTTP life-cycle there is an initial learning curve. In my view this leaning curve is fairly minimal with JSF 2+ and is only a serious problem with relatively inexperienced developers from a web-development heavy background and no desktop UI development experience.

Action-oriented frameworks try to accomplish far less in comparison. They provide a thinner MVC-like facade that leaves a lot of the work of writing controllers, HTTP handling, navigation, state maintenance, HTML/JavaScript/CSS authoring to the developer. There is really no concept of components beyond relatively elementary templating. As a result these frameworks do not generally have component or plug-in ecosystems. These characteristics make learning the framework easier for beginners that perhaps have a background in vanilla web development, PHP, JSP, ASP classic and the like. Because the framework does not alter the HTTP life-cycle or HTML rendering much it is easier to integrate arbitrary HTML, JavaScript and CSS tools.

To apply a very broad generalization the way I have seen this play out is that heavily form/workflow driven applications where Java developers do a lot of the UI work tends to be written in JSF. There are exceptions (such as eBay - they presented on their JSF usage at JavaOne 2014) but these applications usually reside behind corporate firewalls. More public facing web applications often dominated by web developers tend to be written using action-oriented frameworks.

I hope this helps answer some of the questions you may have had. JSF is here to stay and continues to have a strong community behind it. JSF 2.3 was launched as JSR 372 and is also targeted for Java EE 8. MVC 1.0 will join JSF as a first class peer in Java EE for folks that prefer an action-oriented web framework.

If either of these technologies strongly interest you and you have the time to spare, now is the time to apply to join the respective expert group. Note that you can always participate in a JSR without officially being part of the expert group by simply subscribing to the JSR user alias. Also remember that you can contribute on an even more lightweight format through Adopt-a-JSR.

Please note that any views expressed here are my own only and certainly does not reflect the position of Oracle as a company.

Friday Oct 17, 2014

Calling All REST/JAX-RS Enthusiasts: Join JAX-RS 2.1!

As you might be aware, the initial wave of Java EE 8 JSRs are now launched, including the platform JSR itself, CDI 2, JSON-B, JMS 2.1, Servlet 4, JAX-RS 2.1, MVC and JSF 2.3. Most of these JSRs are now actively looking to form their initial expert groups, including JAX-RS 2.1 (filed as JSR 370). Indeed, the JAX-RS specification leads are looking to evaluate the initial set of expert group members fairly quickly - by Wednesday, October 22nd.

Although it's currently slated to be a point release (this can always change), JAX-RS 2.1 is aiming to accomplish quite a bit. Here is a very high level summary of the items currently under consideration:

  • Adding support for SSE.
  • Improved integration with CDI.
  • Exploring support for non-blocking I/O in providers (filters, interceptors, etc.).
  • Evaluating ways in which declarative security can be supported either directly in JAX-RS or by leveraging the Java EE Security JSR (still to be filed).
  • Providing integration with newly filed JSON-B JSR.
  • Building upon the Hypermedia support added in JAX-RS 2.
  • Investigating the reactive programming paradigm as a way to improve the JAX-RS asynchronous client API.
  • Any possible work necessary to support the newly filed MVC 1.0 JSR.

Specification lead Marek Potociar did an excellent job overviewing the possibilities in his JavaOne 2014 talk Let’s Talk JAX-RS.next!. His slides are available here.

Note that you can always participate in a JSR without officially being part of the expert group by simply subscribing to the JSR user alias. In case of JAX-RS, that alias is users at jax-rs-spec dot java dot net. Also remember that you can contribute on an even more lightweight format through Adopt-a-JSR.

Thursday Oct 16, 2014

OTN Virtual Technology Summit is approaching. Save the date!

The OTN Virtual Technology Summit is a set of free online events covering various technical topics such as Java SE, Java EE but also Middleware, Database, etc.  Each topic will be presented by a subject matter expert coming either from Oracle or from the community (Java Champions, Oracle ACEs, ...). And during each session, a live chat will let participants ask questions and clarifications on the presented subject. So this is a really great (and free!) learning opportunity.

This time, the Java EE session will be delivered by Josh Juneau, a renowned Java EE specialist and author of 2 popular Java EE 7 books!

More details will be provided soon (detailed agenda with session abstracts, registration page, etc.) will be published soon. But in the meantime, make sure to save the date in your agenda:
  • VTS America : November 18th, 2014 – 9am to 12:30pm PST
  • VTA Asia : November 19th, 2014 – 10:00am to 1:30pm IST
  • VTS Europe : November 26th, 2014 – 9am to 12:30pm GMT

Wednesday Oct 15, 2014

Java SE 8 (and Java EE 7) Comes to WebLogic!

As many of you know one of the key features of GlassFish 4.1 was support for Java SE 8. You may be glad to hear that WebLogic 12.1.3 now is also officially certified against Java SE 8. This makes WebLogic one of the earliest major commercially supported Java EE platforms to certify for Java SE 8. Keep in mind, WebLogic 12.1.3 also supports some key Java EE 7 APIs such as WebSocket, JSON-P, JAX-RS 2 and JPA 2.1 (read this excellent Aquarium entry by my colleague Bruno Borges for details).

This means that you can start using some of the very well received Java SE 8 features such as lambdas, streams and the new Date-Time API in Java EE 6 and Java EE 7 applications even in the most demanding 24 x 7 enterprise environments. WebLogic 12.1.3 has also taken advantage of new JDK 8 features such as improved garbage collection, security enhancements and JDBC 4.2.

You can read more details in a well written blog entry by Steve Felts of the WebLogic team.

Tuesday Oct 14, 2014

JSR 339 Maintenance Release: JAX-RS 2.0 rev A

JAX-RS 2.0 (JSR 339) has been slightly revised through the JCP Maintenance Release process and has recently passed the JCP MR ballot

This update (JAX-RS 2.0 rev A) is mostly about clarifications (including JavaDoc clarifications) and some fixes in Jersey, the JAX-RS Reference Implementation. The updated documents will be published soon on the JSR 339 page but in the meantime, you can check this page for details about the changes of JAX-RS 2.0 rev A.

It should be noted that GlassFish 4.1, the Java EE 7 Reference Implementation, already supports this version of the JAX-RS specification (i.e. JAX-RS 2.0 rev A).

Monday Oct 13, 2014

Calling All JMS Enthusiasts: Join JMS 2.1!

As you might be aware, the initial wave of Java EE 8 JSRs are now launched, including the platform JSR itself, CDI 2, JSON-B, JMS 2.1, Servlet 4, JAX-RS 2.1, MVC and JSF 2.3. Most of these JSRs are now actively looking to form their initial expert groups, including JMS 2.1 (filed as JSR 368). JMS 2.1 specification lead Nigel Deakin has written up a very handy guide on joining the JMS 2.1 expert group. In fact the guidance applies very well to most JSRs, so it is definitely worth a read if you have an interest in joining a JSR. As you can expect, applications to join the expert group are maintained completely in the open. The current nominations for JMS 2.1 are listed here.

JMS 2.1 will largely continue the focus on API modernization started in JMS 2.0. While we worked primarily on synchronous send and receive, this time the expert group will hone in on improving receiving asynchronous messages - hopefully resulting in a more powerful and simpler alternative to JMS Message Driven Beans (MDBs). Some initial ideas towards this can be found here and here. There are of course many other items under consideration such as improving JMS provider pluggability, redelivery delays, redelivery limits and dead message queues.

Note that you can always participate in a JSR without officially being part of the expert group by simply subscribing to the JSR user alias. In case of JMS, that alias is users at jms-spec dot java dot net. Also remember that you can contribute on an even more lightweight format through Adopt-a-JSR. If you have any questions about participating in JMS 2.1, you should feel free to email Nigel directly at nigel dot deakin at oracle dot com.

Friday Oct 10, 2014

JSON Binding, Slides from JavaOne 2014

At JavaOne 2014, there were several sessions covering Java EE topics. One of the most expected features in Java EE 8 is the JSON Binding API. Martin Grebac from the Expert Group shared his slides with the proposals (yes, lots of code already!) for this API and also details how you can participate and be involved in the development and specification process for JSR 367 - JSON-B.

Get the slides now from JavaOne 2014 (PDF) and follow these links below to participate:

Spotlight on GlassFish 4.1: #12 GlassFish Tools for Luna

Spotlight on GlassFish 4.1' is a series of posts that highlights specific enhancements of the latest GF release, GlassFish 4.1. It could be a new feature, a fix, a behavior change, a tip, etc.

#12 GlassFish Tools for Luna

A new version of the GlassFish Tools (aka the 'GF Eclipse Plugin') has just been released for Luna, the latest and greatest Eclipse version. This version supports both GF 3.1.x and GF 4.1 and is a recommended upgrade as it introduces several UI improvements and fixes various issues.  Note that this capability is also offered in the 'Oracle Enterprise Pack for Eclipse' (aka OEPE).

Installation is simple, just drag this 'Install' button and drop it into your Eclipse Luna workspace.  Follow the process and make sure to select both 'GlassFish Tools' and 'Oracle Java EE' features.  You can also do this from the Eclipse Marketplace.

To configure a GlassFish instance, open the Eclipse preferences window and specify, in the 'Runtime Environments' section, where your GF 4.1 install is located.  Be aware that the UI uses the generic 'GlassFish 4' version, which encompass 4.1 as well!

Questions, remarks, REFs around 'GlassFish Tools for Eclipse' and OEPE can be asked here.

Wednesday Oct 08, 2014

The Java EE 7 Tutorial

"The only thing that interferes with my learning is my education." (Albert Einstein)

The Java EE 7 Tutorial is one of the lesser-known gem. It is an extensive tutorial that covers the Java EE platform and its different APIs. The nearly 1.000 pages of the Tutorial might looks a bit daunting for newcomers. But let's be clear, one doesn't have to go through the complete tutorial! The tutorial has been structured in a way to make it easy to learn specific aspects of the platform. And last but not least, the Tutorial also covers more advanced parts of the platform such as JCA for example. In short, the Java EE Tutorial is a great ressource to learn the Java EE platform at large but also learn more specific aspects of Java EE. The tutorial comes in 3 flavours, a free online version and free PDF version but also a 2 tomes based books edition (paper & Kindle version). 

The Tutorial also bundles many samples that demonstrate specific API but also a few sample applications that shows how to use and combine the different API's to build a complete application. The samples can be download from the SVN repository but also using the GlassFish update center. The following short screencast shows how to install the samples in NetBeans using the GF update center. It's easy, the samples are just a few clicks away!

It should be mentioned that that the Tutorial and its samples have been recently updated for the release of GlassFish 4.1 (see here for more details).

And if you find any issue on the Tutorial or on one if its samples, please make sure to fill a Jira ticket. That input is valuable to continue to maintain and improve the Java EE Tutorial!

Monday Sep 29, 2014

jBatch Suite: Visual Development for the Java API for Batch Processing/Java EE 7

As many of you know, the Java API for Batch Processing (JSR 352) is one of the key APIs added in Java EE 7. The API is largely based on POJOs, annotations and some XML. As a result you can be pretty productive even without an IDE. As a Java developer, however, like me you probably enjoy the usability of modern IDEs like NetBeans and may be wondering what IDE support there is for the Java API for Batch Processing. Although Java IDEs have been very good about supporting Java EE 7 generally, none of them have had much specific support for JBatch - until now that is. Sensing a gap Gaurav Gupta has stepped up with jBatch Suite. jBatch Suite is a NetBeans plugin that allows for both UML style modelling and code generation for Java Batch. Conveniently, it is available through the NetBeans Plugin Portal Update Center (Tools > Plugins). The following video is a great overview of the basic functionality in the plugin:

Gaurav has actually put together a very nice set of video demos covering the majority of functionality in the plugin on YouTube. The NetBeans plugin website offers further details as well as download. Contributions are welcome through the java.net project for the plugin. Enjoy!

Friday Sep 26, 2014

Kito Mann's JSF Sessions at JavaOne 2014

For the Java EE track at JavaOne 2014 we are highlighting some key sessions and speakers to better inform you of what you can expect, right up until the start of the conference.

To this end we recently interviewed Kito Mann. Kito has long been a respected JSF consultant, popular speaker, author and JCP expert. He is the editor-in-chief of JSFCentral.com, co-host of the Enterprise Java Newscast, host of the JSF Podcast interview series, and the author of JavaServer Faces in Action from Manning publications (I met him a long time ago in the process of writing EJB 3 in Action).

Kito has one the highest number of talks from a single speaker in the Java EE track this year. We wanted to talk to him about his JSF sessions at JavaOne 2014, as well as JSF generally:

The following are the sessions we talked about:

  • JSF 2.2 Deep Dive: This tutorial is a two-hour deep dive into all the new features in JSF 2.2 and is probably one of the best bits of training you can have on the technology.
  • PrimeTime JSF with PrimeFaces 5: This session is a look into what is new in PrimeFaces 5, easily the most popular part of the JSF plugin ecosystem.
  • JavaServer Faces Antipatterns and Best Practices: This is an invaluable session if you are a JSF user. Kito shares his wealth of experience as a JSF consultant and navigates the best practices, patterns and anti-patterns for the technology.
  • Mobile JavaServer Faces: This is a deeply well researched session on the available resources for developing mobile applications using JSF. If you are a JSF user being asked to develop mobile functionality, this session is definitely for you.
  • JSF 2.2 in Action: In this one hour session, Kito will overview the features introduced in JSF 2.2 using demos and real life context.

Besides Kito's sessions, we have a very strong program for the Java EE track and JavaOne overall - just explore the content catalog. If you can't make it, you can be assured that we will make key content available after the conference just as we have always done.

Thursday Sep 25, 2014

Spotlight on GlassFish 4.1: #11 Enable Remote Admin

Spotlight on GlassFish 4.1' is a series of posts that highlights specific enhancements of the latest GF release, GlassFish 4.1. It could be a new feature, a fix, a behavior change, a tip, etc.

#11 Enable Remote Admin

When you unzip GlassFish 4.1, the Administration user has no password set. This was introduced quite some time ago to simplify the developer experience. For obvious security reasons, the remote admin capabilities are also disabled. So the default Admin user is 'admin' and its password is empty.

To enable remote Admin, you should first define a password for the admin user and then enable remote admin. The trick is that the change-admin-password command is asking the admin password, in that case you should leave it empty.

./asadmin change-admin-password 
Enter admin user name [default: admin]> [leave it empty to use the default value]
Enter the admin password> [make sure to leave this field empty]
Enter the new admin password> myNewPassword
Enter the new admin password again> myNewPassword
Command change-admin-password execute

You can enable the securre-admin.

./asadmin enable-secure-admin
Enter admin password for user "admin"> [fill in the new password you have defined]
You must restart all running servers for the change in secure admin to take effect. Command enable-secure-admin executed successfully.

And just restart the domain and you are all set!

./asadmin restart-domain domain1

The 'empty admin password' is mentionned in the initial page of the first chapter of the Administration Guide.

Wednesday Sep 24, 2014

Java EE 8 JSRs Unanimously Approved!

The 7 JSRs submitted in August for Java EE 8 have been unanimously approved, with 24 'Yes' votes, by the JCP Executive Committee!
The different Specification Leads are now starting to formally assemble their Expert Group (see instructions for joining the JCP). JUG members can also help with any of these JSRs through the Adopt-a-JSR Program. And in case of doubt, just reach out to the Specification Lead you wan to work with, he/she will be able to guide you (e.g. JMS).

Those recently approved JSRs added to CDI 2.0, which was approved a few weeks ago, give us an impressive initial set of 8 JSRs for Java EE 8!