Tuesday Nov 26, 2013

Help to improve JDK8

"The best preparation for good work tomorrow is to do good work today." (Elbert Hubbard)

The clock is ticking... Java 8 is not that far anymore. The Adopt OpenJDK initiative is to OpenJDK, the Java SE Reference Implementation, what the Adopt-a-JSR initiative was to Java EE 7 / GlassFish 4 a few months ago.  The idea is the same, i.e. let people get familiar with the Reference Implementation and its different APIs before they are released. Let them play and stress test those implementations and provide as much feedback as possible before those implementations go final.

In short, Adopt OpenJDK allows the Java community to prepare the field for JDK8. There are many ways to contribute. The first step could be to test existing Java applications on top on OpenJDK 8. The next step would then be the adapt those existing applications to leverage some of the new Java 8 enhancements (e.g. Lambda), etc.

From a Java EE angle, this effort also makes a lot of sense. After all, 'we' all run on top of the JVM! So have you already tried to run your current Java EE environment on top of an early JDK8 build? What were the issues, if any?  Have you tried to tweak your existing Java code to use some of the new Java SE 8 features? If so, please do share your findings with the community, the Adopt OpenJDK program is great venue for that.

Monday Nov 25, 2013

Asynchronous clients integration with Java EE 7

"The client is not always right." (Enzo Ferrari)

Integrating clients with a back-end server may pose some challenges as it involve a mix between asynchronous and synchronous behaviour and data exchange.

The 'communication related APIs' of Java EE 7 APIs have all some asynchronous capabilities, e.g. JAX-RS 2.0, WebSocket 1.0 , JMS 2.0, Servlet 3.1, JAX-WS 2.2. In his 'JavaFX Integration Strategies' article, Adam Bien explain some strategies to easily integrate JavaFX clients with a back-end using some of the asynchronous capabilities of Java EE 7. The article also illustrate how to push information from the server to the client using WebSocket.

The article uses JavaFX as the client side UI framework but the patterns and strategies described are not necessarily JavaFX specific and are easily applicable to almost any types of client. As Adam says "REST and JSON become the new, least common denominator for communication with HTML5 clients, Java applications, and even low-level devices.". Finally, the article also illustrate how Java SE 8 Lambda leads to a cleaner code.

Friday Nov 22, 2013

Optimized WebSocket broadcast

"When you have to make a choice and don't make it, that is in itself a choice."  (William James)  Tyrus logo

The Java API for WebSocket (JSR 356) is one of the API added to Java EE 7. It is a '1.0' release, that means that the API is complete and fully functional. It is often said that premature optimisation is the root of all evil, so an initial implementation can easily be optimised. The same is also true for features, choices had to made as it is impossible to implement all the desired features in an initial release. Clearly, they are different aspects that could easily be improved going forward.

Tyrus serves as the JSR 356 Reference Implementation, it is also a test-bed for potential new WebSocket features and improvements. As always, a proprietary feature of an implementation doesn't necessarily means that this particular feature will be included in a future revision of the specification. It could just remains a proprietary feature or an implementation specific optimisation.

In this post, Pavel Bucek, a Tyrus team member, discuss how a WebSocket Server Endpoint could be improved when it needs to broadcast a message to its connected remote endpoints. In Tyrus 1.3, a new broadcast() method has been introduced, it allows to broadcast a message by re-using the same data frame for all the remote endpoints, by doing so the overall performance should be improved.


Thursday Nov 21, 2013

Jersey 2.x Tracing support

"Rest is the sweet sauce of labor." (Plutarch – a long time ago!)

Jersey is JAX-RS 2.0 Reference Implementation and as such it's fully compliant to JSR 339. The Jersey Team goes beyond the specification by adding features and functionalities to their JAX-RS implementation. Overtime, some of those features might be good candidates for standardization.  The Client API is a good example of that. In JAX-RS 1.x, Jersey and some other implementations has their own proprietary Client API. In JAX-RS 2.0, the Client API has been standardized and is now part of the specification. So it is not uncommon to have, in an implementation, features that are (not yet?) part of the specification. Those extra capabilities are also a way for an implementation to differentiate itself from the other implementations.

Tracing is a feature that was available in Jersey 1.x, this feature has now been ported to Jersey 2.x (2.3 and above). The Jersey Tracing capabilities allows to easily diagnose server-side request processing pipelines.  Libor Kramoliš, a member of the Jersey Team, has written a detailed post on how to use the Jersey's Tracing capability.

Wednesday Nov 20, 2013

JPA 2.1 Type Converters

Somewhat surprisingly, JPA 2.1 appears to be one of the APIs that seems to get lost in the Java EE 7 buzz. Although it is a point release JPA 2.1 includes a fairly large number of very important changes such as schema generation, entity graphs, support for stored procedures, unsynchronized persistence contexts, entity converters, and much, much more. In a code driven post Thorben Janssen discusses one of these changes - entity converters. There's also the 20-minute JPA 2.1 presentation by specification lead Linda Demichiel on the GlassFish videos YouTube channel:

More recently, Linda presented a JavaOne 2013 technical session titled Java Persistence 2.1. Stay tuned to Parleys.com for video of the session to be posted.

Tuesday Nov 19, 2013

New book: RESTful Java with JAX-RS 2.0


Bill Burke's RESTful Java with Jax-RS is a book that comes to mind when talking about JAX-RS. It is has been published by O'Reilly in its Animal Menagerie a few years ago.

Bill is a long time JBoss contributor and is also the RedHat representative in theJAX-RS 2.0 Expert Group.

O'Reilly has just published a revised edition of the book to includes the new JAX-RS 2.0 features. RESTful Java with JAX-RS 2.0 has new chapters to cover the specification important additions such as the JAX-RS 2.0 Client API, the Asynchronous Client and Server APIs, Filters and Interceptors. In addition, the new edition also covers smaller JAX-RS 2.0 updates such as ParamConverters, UriBuilder extension, etc.

JAX-RS 2.0 cover


Monday Nov 18, 2013

JMS2@London GlassFish User Group

Some of you may be aware that the London GlassFish User Group got launched a few months ago. The group is organized and sponsored by C2B2 Consulting. C2B2 continues to offer GlassFish support and C2B2 Technical Director Steve Millidge recently offered his pretty level-headed reaction to the discontinuation of Oracle commercial support for GlassFish - it's worth reading for perspective.

The Manchester, UK based JMS 2 specification lead Nigel Deakin recently led a session in the group on the new JMS 2/Java EE 7 features in GlassFish 4. The video for the talk is posted below. There's also my own slide deck on JMS 2 posted on SlideShare (with source PDF and abstract).

Do consider inviting Nigel to give a JMS 2 talk if you are relatively local to him. Also, consider supporting the group if you are local to it. More recently, Nigel presented a JavaOne 2013 technical session titled Easier Messaging with JMS 2.0 as well as a Birds-of-a-Feather session titled What’s Next for JMS?. Stay tuned to Parleys.com for video of the sessions to be posted (the slide decks are already posted on the linked JavaOne Content Catalog).

Friday Nov 15, 2013

MOXy is the New Default JSON-Binding Provider in GlassFish 4

When I talk about JAX-RS 2, JSON-P and Java EE 7 a surprising number of people seem to assume that GlassFish and Jersey does not support JSON binding and just supports lower level JSON processing. It is in fact correct that Java EE 7 has standardized JSON processing (via JSON-P) but not a JSON binding API yet (although such a standardized API is a very strong consideration for Java EE 8 and would build upon the JSON-P work). However Jersey, the popular JAX-RS reference implementation, has long had strong support for JSON binding via MOXy, Jackson and Jettison (now it also has support for JSON-P of course). In fact, in GlassFish/Jersey the default JSON binding provider is MOXy. If you are not familiar with MOXy, it is a very interesting project part of EclipseLink (the JPA reference implementation) that translates JAXB annotations to JSON. In a code driven post, Blaise Doughan of the Oracle EclipseLink team explains the details of using MOXy with JAX-RS in GlassFish.

For more details on Jersey's support for JSON, you should check out the very well-written documentation.

Thursday Nov 14, 2013

JSF Specification Lead Ed Burns Discusses JSF 2.2 and Java EE7

If you are a JSF user you owe it to yourself to know about JSFCentral. Run by key JSF advocate, consultant and JSF in Action author Kito Mann, it's an excellent resource for everything JSF. In a recent podcast on JSFCentral, Kito chats with celebrated JSF specification lead Ed Burns about JSF 2.2 and Java EE 7. It's an extremely insightful but informal discussion between two powerhouses of the JSF ecosystem. The discussion covers JSF 2.2 features such as HTML 5 support, the flow scope, resource library contracts and CDI alignment as well as Java EE 7, all in the context of broader industry trends. You can read the transcript and listen to the podcast here. There's also the brief JSF 2.2 video from Ed Burns on the GlassFish Videos YouTube channel:

More recently, Ed presented a JavaOne 2013 session titled JSF 2.2 New Features in Context. Stay tuned to Parleys.com for video of the session to be posted (the slide deck is already posted on the linked JavaOne Content Catalog).

Wednesday Nov 13, 2013

Tyrus 1.3 Released

Tyrus, the WebSocket 1.0 reference implementation included in GlassFish and WebLogic, released version 1.3 a few days ago. The release contains some valuable features like asynchronous handling of the client-side connectToServer method call, optimized broadcast support and lots of stability and performance improvements (listed below).

One issue that popped up a little too late for getting into 1.3 is TYRUS-263: Accessing SSL protected resource via HTTP proxy. This regression is already fixed in the Tyrus master branch, please let us know whether you consider this feature critical. It might be possible to release 1.3.1 just with this fix.

Tyrus 1.3 is already integrated into GlassFish trunk, so is included in the nightly releases. You can also just remove all tyrus related jars and replace it with the contents of the websocket-ri-archive artifact.

Below is a list of JIRA entries incorporated into Tyrus 1.3:

  • TYRUS-71: ErroCollector not properly used in AnnotatedEndpoint class.
  • TYRUS-262: @OnOpen fails for programmatically deployed annotated endpoint.
  • TYRUS-261: Text decoder disables Binary decoder if both are configured for the same server endpoint; endpoint cannot receive binary messages anymore.
  • TYRUS-248: Consolidate Extension representation
  • TYRUS-258: Tyrus always creates HTTP session
  • TYRUS-251: DecodeException is not passed to @OnError method
  • TYRUS-252: encoder for primitive types cannot be overridden
  • TYRUS-250: Sec-WebSocket-Protocol header cannot be present when there is no negotiated subprotocol
  • TYRUS-249: WebSocketContainer MaxSessionIdleTimeout is not propagated to Session (server side)
  • TYRUS-257: Async timeout value set on WebSocketContainer is not propagated to RemoteEndpoints (Session#getAsyncRemote())
  • TYRUS-253: DecodeException is not passed to @OnError method from session.getAsyncRemote().sendObject
  • TYRUS-243: WebSocketContainer.connectToServer can block for seconds
  • TYRUS-227: Build failure : AsyncBinaryTest
  • TYRUS-226: Tyrus build error : OnCloseTest
  • TYRUS-247: Make all samples use TestContainer for tests
  • TYRUS-238: Refactor WebSocketEngine (SPI and Impl)
  • TYRUS-157: Submitting tasks to an injected ManagedExecutorService in a ServerEndpoint does not work
  • TYRUS-137: Improve subprotocols/extensions headers parsing
  • TYRUS-133: Some Broadcast(er) API is needed in order to opmtimize chat-like usecases
  • TYRUS-245: ServerEndpointConfig#getConfiigurator returns Configurator not used when getNegotiatedExtensions has been called
  • TYRUS-240: clean up duplicated static fields (strings)
  • TYRUS-230: When Session is invalidated, the close reason is not 1006
  • TYRUS-190: Remove TyrusServetServerContainer (merge with TyrusServerContainer)
  • TYRUS-65: Implement common utilities for testing
  • TYRUS-242: Tyrus does not run on JDK8 compact2 profile
  • TYRUS-237: RemoteEndpoint.Async#sendBinary does not throw IllegalArgumentException when data is null
  • TYRUS-239: Improve WebSocketEngine ByteBuffer handling
  • TYRUS-232: Refactor grizzly/servlet container – Tyrus-SPI
  • TYRUS-235: Fix findbugs errors in tests/servlet
  • TYRUS-234: Remove support for older protocol version
  • TYRUS-229: Session#setMaxIdleTimeout() will kill the session whether or not the session actually timed out
  • TYRUS-225: Invalidation of (Servlet) HttpSession does not invalidate WebSocket Session
  • TYRUS-153: Static map in TyrusRemotEndpoint
  • TYRUS-201: Wrong ServletInputStream#isReady() usage in TyrusHttpUpgradeHandler
  • TYRUS-224: Refactor Connection#write and ConnectionImpl to use CompletionHandler only (no Future)
  • TYRUS-221: wss:// doesn’t appear to function correctly via a http proxy
  • TYRUS-146: Support request from client to secured services (“wss”)
  • TYRUS-223: Message can be writen multiple times when running on Servlet container

Besides trying the release out, you should feel equally free to file new JIRA entries on Tyrus and the rest of the GlassFish codebase for that matter.

Tuesday Nov 12, 2013

Java Developer Days India Trip Report

October 21st through October 25th I spoke at Java Developer Days India. This was three separate but identical one-day events in the cities of Pune (October 21st), Chennai (October 24th) and Bangalore (October 25th). For those with some familiarity with India, other than Hyderabad these cities are India's IT powerhouses.

The events were focused on Java EE. I delivered five sessions on Java EE 7, WebSocket, JAX-RS 2, JMS 2 and EclipeLink/NoSQL. The events went extremely well and was packed in all three cities. More details on the sessions and Java Developer Days India, including the slide decks, posted on my personal blog.

Monday Nov 11, 2013

HTTP Session Invalidation in Servlet/GlassFish

HTTP session invalidation is something most of us take for granted and don't think much about. However for security and performance sensitive applications it is helpful to have at least a basic understanding of how it works in Servlets.

In a brief code centric blog post Servlet specification lead Shing Wai Chan introduces the APIs for session invalidation and explains how you can fine tune the underlying reaper thread for session invalidation when it is needed in GlassFish 4. Don't hesitate to post a question here if the blog is not clear, this is a relatively esoteric topic...

Thursday Nov 07, 2013

6 Facts About GlassFish Announcement

To help clarify the message about the recent roadmap for GlassFish, I decided to put together 6 facts about the announcement, future of GlassFish, and the Java EE platform as a whole: 

"Since Oracle announced the end of commercial support for future Oracle GlassFish Server versions, the Java EE world has started wondering what will happen to GlassFish Server Open Source Edition. Unfortunately, there's a lot of misleading information going around. So let me clarify some things with facts, not FUD."

Read full story here

Monday Nov 04, 2013

Java EE and GlassFish Server Roadmap Update

2013 has been a stellar year for both the Java EE and GlassFish Server communities. On June 12, Oracle and its partners announced the release of Java EE 7, which delivers on three major themes – HTML5, developer productivity, and meeting enterprise demands. The online event attracted over 10,000 views in the first two days!

During the online event, Oracle also announced the availability of GlassFish Server Open Source Edition 4, the world's first Java EE 7 compatible application server. The primary role of GlassFish Server Open Source Edition has been, and continues to be, driving adoption of the latest release of the Java Platform, Enterprise Edition. Oracle also announced the Java EE 7 SDK, which bundles GlassFish Server Open Source Edition 4, as a Java EE 7 learning aid. Last, Oracle publicly announced the Java EE 7 reference implementation based on GlassFish Server Open Source Edition 4. Java EE is a popular platform, as evidenced by the 20+ Java EE 6 compatible implementations available to choose from.

After the launch of Java EE 7 and GlassFish Server Open Source Edition 4, we began planning the Java EE 8 roadmap, which was covered during the JavaOne Strategy Keynote. To summarize, there is a lot of interest in improving on HTML5 support, Cloud, and investigating NoSQL support. We received a lot of great feedback from the community and customers on what they would like to see in Java EE 8.

As we approached JavaOne 2013, we started planning the GlassFish Server roadmap. What we announced at JavaOne was that GlassFish Server Open Source Edition 4.1 is scheduled for 2014. Here is an update to that roadmap.

  • GlassFish Server Open Source Edition 4.1 is scheduled for 2014
  • We are planning updates as needed to GlassFish Server Open Source Edition, which is commercially unsupported
  • As we head towards Java EE 8:
    • The trunk will eventually transition to GlassFish Server Open Source Edition 5 as a Java EE 8 implementation
    • The Java EE 8 Reference Implementation will be derived from GlassFish Server Open Source Edition 5. This replicates what has been done in past Java EE and GlassFish Server releases.
  • Oracle will no longer release future major releases of Oracle GlassFish Server with commercial support – specifically Oracle GlassFish Server 4.x with commercial Java EE 7 support will not be released.
  • Commercial Java EE 7 support will be provided from WebLogic Server.
  • Oracle GlassFish Server will not be releasing a 4.x commercial version

Expanding on that last bullet, new and existing Oracle GlassFish Server 2.1.x and 3.1.x commercial customers will continue to be supported according to the Oracle Lifetime Support Policy.

Oracle recommends that existing commercial Oracle GlassFish Server customers begin planning to move to Oracle WebLogic Server, which is a natural technical and license migration path forward:

  • Applications developed to Java EE standards can be deployed to both GlassFish Server and Oracle WebLogic Server
  • GlassFish Server and Oracle WebLogic Server have implementation-specific deployment descriptor interoperability (here and here).
  • GlassFish Server 3.x and Oracle WebLogic Server share quite a bit of code, so there are quite a bit of configuration and (extended) feature similarities. Shared code includes JPA, JAX-RS, WebSockets (pre JSR 356 in both cases), CDI, Bean Validation, JSF, JAX-WS, JAXB, and WS-AT.
  • Both Oracle GlassFish Server 3.x and Oracle WebLogic Server 12c support Oracle Access Manager, Oracle Coherence, Oracle Directory Server, Oracle Virtual Directory, Oracle Database, Oracle Enterprise Manager and are entitled to support for the underlying Oracle JDK.

To summarize, Oracle is committed to the future of Java EE.  Java EE 7 has been released and planning for Java EE 8 has begun. GlassFish Server Open Source Edition continues to be the strategic foundation for Java EE reference implementation going forward. And for developers, updates will be delivered as needed to continue to deliver a great developer experience for GlassFish Server Open Source Edition. We are planning for GlassFish Server Open Source Edition 5 as the foundation for the Java EE 8 reference implementation, as well as bundling GlassFish Server Open Source Edition 5 in a Java EE 8 SDK, which is the most popular distribution of GlassFish. This will allow GlassFish releases to be more focused on the Java EE platform and community-driven requirements. We continue to encourage community contributions, bug reports, participation on the GlassFish forum, etc. Going forward, Oracle WebLogic Server will be the single strategic commercially supported application server from Oracle.

Disclaimer: The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract.It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.