Tag: java

JavaOne 2016: Oracle’s ‘refocusing’ of the EE8 proposal

Oracle’s planned Java EE ‘announcement‘ at JavaOne 2016 turned out to be (based on the announcement from the Sunday keynote and the Java EE 8 roadmap session by Linda Demichiel, EE spec lead for EE JSRs) a ‘refocusing’, a realignment to bring Java EE more in line with current trends, particularly to support deploying EE applications to the cloud and the development of microservices.

So what exactly is going to change? For the new EE8 spec proposal, with finalization now planned for 2017,  some previously proposed features for inclusion are now going to be dropped, namely:

  • MVC 1.0
  • JMS 2.1
  • EE Management apis 2.0

Given than MVC 1.0 was a new EE web framework as an alternative to JSF (not adding new technology but built on top of what we already have with a Reference Implementation already built out), this is perhaps the most surprising removal. Given the new focus of cloud and microservices however, this makes sense, as it doesn’t really add anything towards supporting the new goals.

Everything else in the original EE8 JSR 366 is going to remain in the new EE8 proposal.

New features to be added include a new feature for supporting Health Checks, and a new Configuration proposal to standardize external configuration of deployments – both of which will be useful to support deployments to the cloud.

Is this ‘refocusing’ enough? Is it going to be finalized soon enough? For an EE8 target of 2017, and EE9 of 2018, is it too little, too late?

Given that you can use current EE features today with frameworks like Spring Boot and Dropwizard to build and deploy microservices, is a standardized cloud/microservice focused EE platform still relevant?

Alternative runtimes like WildFly Swarm and IBM’s Liberty Profile are giving runtime flexibility and allow you to pick just the features your app needs at runtime (and are available today). Rather than an all-in-one EE runtime container, is a ‘pick n mix’ type approach more relevant to support the current popularity of microservices?

Notes from Raspberry Pi with Java 9 session – CON6210 – JavaOne 2016

A few interesting notes from the Java 9 Embedded on Raspberry Pi, session CON6210, presented by Stephen Chin.

Currently streaming live on YouTube: https://www.youtube.com/watch?v=v95y5CzvcZ4&feature=youtu.be

Full live stream schedule is here: https://community.oracle.com/docs/DOC-1005786

  • SE9 Embedded will be available in a ARM build for the Raspberry Pi
  • This ARM specific build will only be available for Pi 2 and 3 (not the original Pi 1 A/B and + models, as it’s been compiled for ARM Thumb-2 instructions, and these are only supported on Pi 2 ARM CPU and above
  • AWT, Swing and JavaFX will all be supported on SE9 Embedded on the Pi
  • Interesting side note about modular Jigsaw in SE9 – apparently the module file packaging and compression is moving away from zip based Jars, to another format that’s more efficient for class lookup/retrieval

Oracle have something to announce re. Java EE 8 at JavaOne this year?

Oracle have been quiet on the Java EE front since around November 2015 according to public minutes from recent JCP Executive Committee meetings,  which has led to the forming of the Java EE Guardians group forming to rally community awareness and promote the future of Java EE.

This story on The Register just popped up in my feed this evening, with an interesting quote from ‘Oracle spokesman’ Mike Moeller, stating:

“Oracle is committed to Java and has a very well defined proposal for the next version of the Java EE specification – Java EE 8 – that will support developers as they seek to build new applications that are designed using micro-services on large-scale distributed computing and container-based environments on the Cloud … Oracle is working closely with key partners in the Java community to finalize the proposal and will share the full details with the broader Java community at JavaOne in September.”

So there you go. Given that there is already an EE8 JSR in flight (JSR 366) encompassing many other JSRs that were planned to be included in EE8, this statement sounds suspiciously like Oracle has “something else” planned for EE8 that is not the EE8 JSR (“a very well defined proposal for the next version of the Java EE specification”).

In a thread on the Java EE Guardians Google Group, seems like no-one over there has any other insight into this news at this point.

Interestingly, microservices, large-scale distributed computing and containers… this is all very much on target for where EE needs to be heading.

If this is all Oracle is willing (or able) to share at this point, then it will definitely be interesting to hear what they have to share at this year’s JavaOne conference.

MongoDB Java api: using a sequence collection with findAndModify()

MongoDB doesn’t have an equivalent of sequences typically used in relational databases, since documents are automatically given a unique ObjectId value for the “_id” property when inserted.

To return data from documents via a REST api, it may be more useful to use a sequential unique key. The MongoDB docs have an example of how you could use a Collection to hold a document per sequence that you need, and increment a value property each time you retrieve it with findAndModify().

There’s a number of questions on StackOverflow related to this approach, most seem related to the approach doc linked above (e.g. here, here, and articles elsewhere, like here).

To implement this approach using the Java api, using findAndModify() seems to be key, as you need to ensure you are querying and incrementing the sequence value in a document in a single, atomic step. After that point once you have the updated/next value from your document holding your sequence, the fact that you use that value in a subsequent atomic insert to another document seems to be safe (please leave me a comment if this assumption is not correct!), as every call to findAndModify() to increment the sequence value is atomic (making an assumption here based on my limited MongoDB knowledge, but I think this is correct!).

Here’s how I implemented the approach using the Java api:

public int getNextSequence() throws Exception {
    DB db = MongoConnection.getMongoDB();

    DBCollection sequences = db.getCollection("sequences");

    // fields to return
    DBObject fields = BasicDBObjectBuilder.start()
        .append("_id", 1)
        .append("value", 1).get();
    DBObject result = sequences.findAndModify(
      new BasicDBObject("_id", "addressId"), //query 
      fields, // what fields to return
      null, // no sorting
      false, //we don't remove selected document
      new BasicDBObject("$inc", new BasicDBObject("value", 1)), //increment value
      true, //true = return modified document
      true); //true = upsert, insert if no matching document

      return (int)result.get("value");


The future of Java EE as discussed at recent JCP Executive Committee meetings

If you’ve been following Java EE related news over the past few months, you’ll know that Oracle cut back on a number of its Java Evangelist employees, others such as Reza Rahman appear to have left of their own accord, and there’s a general concern than Oracle appears to have slowed down input on any Java EE JSR. Rahman has formed a group called the Java EE Guardians to drive community activity to support future development of Java EE and EE JSRs.

If you want more of an inside view to what’s going on, there’s some interesting reading in the form of the JCP Executive Committee meeting minutes which are public record. The minutes for June 2016 and May 2016 both had agenda items to discuss the future of Java EE. The minutes from the May meeting are very interesting, including comments such as :

“…concern that Oracle, despite its role as steward of Java, has not made any public statements or explanations for the apparent lack of activity on Java EE”

and recording of a statement to Oracle from the JCP Executive Committee formally voicing their concern:

“EC members expressed their serious concerns about the lack of progress on Java EE. They believe that Java EE is critical to the Java ecosystem and to their organizations and customers. They fully accept Oracle’s right to direct its investment where it wishes, but expressed the hope that they and other members of the Java community be permitted to step in and help with the ongoing development of the platform, particularly in areas where Oracle wishes to reduce its investment. They therefore requested a dialog with Oracle about how to make such a transition.”

Other concern recorded in the minutes was that Oracle holds IP rights for the majority of the JSRs that are in progress, and so passing responsibility on to other parties requires Oracle’s involvement to pass on ownership of this IP… something which they may agree to, or may not.

Minutes from April 2016 note:

“Martijn Verburg reported on behalf of the London Java Community that it now seems clear that little if any progress is being made on Oracle-led Java EE JSRs. (Some Oracle Spec Leads have admitted publicly that they are unable to spend any time on their JSRs, having been directed to work elsewhere.) He estimated that work on Java EE seems to have stopped around November 2015.”

So, it’s clear there is industry concern that Oracle has backed off from involvement with development of JSRs for Java EE8. The question is, what happens now?

Lightweight docker images for Java apps

There’s a number of posts (e.g. here) talking about the official Java docker images being on the large side – in Docker terms, the standard images at > 600MB before you even build your image containing you app are … pretty big.

Suggestions are to use a smaller image as a starting point, like Alpine Linux. It looks like at some point the official Java images have been updates to include a number of Alpine based images too.

Pulling down an OpenJDK 8 image, java:openjdk-8-jdk and then java:openjdk-8-alpine, there’s a massive size difference between the size of the two:

If you’re planning on running something lightweight like a Spring Boot app, looks like the provided Alpine images are a good starting point.

Refreshing a JAX-RS backend with some Node.js and Express?

Over the past few year or so, I’ve been building a web app that visualizes amateur radio spots using a digital mode called JT65. The site is currently up and live here: http://www.spotviz.info/#/home

I started building this as an exercise to learn some AngularJS 1.x (I posted a number of posts along the way too). The backend datastore is MongoDB, and there’s a JAX-RS War deployed to WildFly that provides a REST backend to the AngularJS frontend. The majority of the logic for the webapp is all in the AngularJS app.

Since playing with some Node.JS and Express a couple of weeks ago, I’ve been considering if I should have a go at replacing the JAX-RS code with a Node.js backend too. Since the existing code is mainly building and executing MongoDB queries, this wouldn’t be that hard to do a straight replace. Based on what I’ve seen so far of libraries like Mongoose, the replacement code is likely to be significantly more concise than the existing Java based backend. I’ll queue this up for a project in the coming weeks 🙂

Watch for dependency name typos when creating new Spring Boot projects

If you use the Spring Boot CLI, it’s pretty easy to get a new project created from the templates with all required dependencies in place with something like:

spring init --build=maven --dependencies=web project-name.zip

This generates you a zip that you can unzip and import into your IDE and off you go. The trouble with the CLI currently though is that there’s no validation on the dependency names, so if you call

spring init --build=maven --dependencies=wb project-name.zip

You’ll get the same zip generated, but there will be a subtle typo in your dependencies which unless you’ve seen these messages from maven before, you’ll spend a bunch of time trying to work out what’s wrong.

I created a ticket for this issue here, and hopefully this gets picked up as an enhancement.

The maven error in case you’re interested looks like this:

[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   The project com.example:testbaddep:0.0.1-SNAPSHOT (/Users/kev/develop/spring-boot/testbaddep/pom.xml) has 1 error
[ERROR]     'dependencies.dependency.version' for org.springframework.boot:spring-boot-starter-wb:jar is missing. @ line 27, column 15
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

Android Studio – useful notes (1)

Having worked for years with Eclipse (and some time with Netbeans), I have to admit that using Android Studio (based on InteliJ) I’m fining harder that what it should be. Where’s all my key shortcut combinations!

Whenever I use Netbeans, I use the Eclipse keymappings option in the settings, so I don’t have to remember any new key shortcuts. I’m not sure if Android Studio/IntelliJ has this option as well, but in the meantime, here’s some notes for useful things to remember.

Organize Imports (Eclipse: shift-Ctrl-O) / Optimize Imports: Ctrl-Opt-O

Jump to definition (Eclipse: F3) : Opt-Cmd-B

Fix error with popup suggestion: Opt-Return


Other useful Android development related posts: