Tag Archives: javaee7

Adding Java EE 7 Batch Addon to JBoss Forge – Part 1 (Tech Tip #22)

JBoss Forge is the fastest way to build your Java EE applications, and not even tied to a particular IDE or an Application Server. Tech Tip #17 explained how to build a simple Java EE application rapidly, and deploy it on WildFly. JBoss Developer Studio provide a very neat integration with Forge as well. The instructions from the video are also explained in a text-based script here.

Forge is built with an extensible architecture where third-party addons can be easily installed to enable new functionality that does not exist in the Forge itself. A large variety of addons (nee plugins) are already available such as Arquillian, RichFaces, JRebel, OpenShift, Spring, TomEE, AngularJS, Netty, and a lot more.

Now, you’ve used Forge, found some functionality missing, fortunately somebody already created a addon and so could use that. But now you need some functionality and there is no addon available for that. So you’ll need to create an addon. How do you start ?

Lincoln Baxter (@lincolnthree) and I are starting a multi-part video series where we are going to interactively build a addon for adding Java EE 7 Batch functionality to Forge. The first video is available and shows:

  • Get started with creating a plugin basic structure
  • Add relevant dependencies
  • Build and install the addon
  • Add parameters to the addon

We plan to record the next session next Friday-ish. Let us know if you’d like to join us on G+ hangout and will share the coordinates.

The evolving source code is available at github.com/javaee-samples/forge-addons.

Enjoy!

 

Getting Started with WildFly in OpenShift and JBoss Developer Studio (Tech Tip #21)

[Republishing from http://wildfly.org/news/2014/04/25/Getting-Started-WildFly-OpenShift/]

OpenShift provides an open source hybrid cloud application platform by Red Hat. It enables polyglot applications to be deployed on a public, private, and a hybrid cloud very easily. It provides an extensible cartridge-based architecture that allows a wide range of functionality such as frameworks, databases, monitoring services, or connectors to external backends to be easily added. WildFly cartridge allows you to start a WildFly instance in OpenShift Online.

JBoss Developer Studio provide comprehensive tooling around Java EE, HTML5, Mobile, and many other technologies needed for modern web application development. The latest 7.1.1 release provide support for Eclipse Kepler SR2, the latest Eclipse release.

This blog contains a video tutorial that explains how to get started with WildFly in OpenShift and JBoss Developer Studio. Specifically, it shows:

  • Create an OpenShift application using WildFly cartridge
  • Access the WildFly administration console using port forwarding
  • Import the created application in JBoss Developer Studio
  • Make changes to the application and view them in the deployed application
  • Add a simple Java EE 7 component to the application

Enjoy!

WildFly 8, Java EE 7, and Eclipse/JBoss Developer Studio Screencast (Tech Tip #20)

JBoss Developer Studio provide comprehensive tooling around Java EE, HTML5, Mobile, and many other technologies needed for modern web application development.

This short screencast shows you how to configure WildFly 8 in JBoss Developer Studio 7.1.1 and build/deploy a simple Java EE 7 application to it. Please note, that this would work if you installed Eclipse + JBoss Tools separately as well.

Enjoy!

NetBeans 8 and WildFly 8 Screencasts (Tech Tip #18)

Wildfly_logo netbeans8-logo

Enjoy the short screencast on how to get started with WildFly 8 in NetBeans 8:

Emmanuel Hugonet (@ehsavoie) created the NetBeans plugin and maintains it. He also created a quick video that shows how to:

  • Configure and start WildFly 8 server
  • Run a Java EE 7 WebSocket sample on WildFly
  • Choose Maven profile to run tests
  • Type of resources shown by the plugin

Enjoy!

File the bugs here (use “WildFly” component).

Don’t forget a ton of Java EE 7 samples are available at github.com/javaee-samples/javaee7-samples.

WildFly 8, JDK 8, NetBeans 8, Java EE 7: Excellent combo for enterprise Java

JDK 8 and NetBeans 8 was released Mar 18, 2014
WildFly 8 was released Feb 11, 2014
Java EE 7 was released Jun 12, 2013

Past 12 months have been really instrumental for Java community with all these very important releases.

java8-logonetbeans8-logo  Wildfly_logo  javaee-logo

Together, JDK 8 + NetBeans 8 + Java EE 7 +WildFly 8 make an excellent combination for building enterprise Java application.

JDK 8, Java EE 7, and WildFly 8 are also supported in Eclipse and IntelliJ as well. So you are not limited to just NetBeans ;-)

I tried Java EE 7 hands-on lab with this combination and every thing worked seamlessly. Now I just need a pull request (issue #12) where the source code is using java.util.stream and Lambdas. Who is going to do it ? ;-)

There are tons of new features in JDK 8, the main ones are:

  • Lambda Expressions allows you to express instances of single-method classes more compactly. In other words, it allows you to treat functionality as method, or code as data. Read more details in Venkat‘s excellent book on Functional Programming with Java or standard Java tutorial.
  • Default methods enable you to add new functionality to an interface. This ensures binary compatibility with code written for older versions of those interfaces. This is different from abstract methods as they do not have a method implementation. Read more details here.
  • Repeating annotations allows an annotation to be repeated over a declaration or type use. This is useful if the same annotation needs to be applied multiple times to a class or a method. Read more details here.
  • Method parameter names are now available using Reflection API (Parameter.getName()).
  • Functional-style programming using the newly added Stream API in  java.util.stream package.
  • New tools: jjs to invoke Nashorn engine and jdeps for class dependency analyzer
  • New Nashorn JavaScript engine
  • New Date-Time API (JSR 310)
  • Replacement of permgen with Metaspace (JEP 122) – -XX:PermSize and -XX:MaxPermSize are replaced by -XX:MetaSpaceSize and -XX:MaxMetaspaceSize in java
  • Compact profiles

And there are a lot more!

WildFly 8 is Java EE 7 compliant, and in addition also provide tons of features:

  • High performance web server (Undertow)
  • Role Based Access Control (RBAC)
  • Port reduction
  • “Core” distribution

Read the complete list here.

Remember that Java EE 7 mandates JDK 7 only, and so even though you can leverage all the runtime improvements made in the Java SE 8 platform but in order to have your application run on a Java EE 7 compliant application server, you may be restricted to JDK 7 only. For example, GlassFish 4 is not even tested on JDK 8. WildFly 8 has been running its test suite on JDK 8 regularly. We may even leverage some of the JDK 8 features in the near future.

No matter what, JDK 8 + WildFly 8 + NetBeans 8 + Java EE 7 together make a very compelling toolset for your enterprise Java. If your applications don’t work, then file a bug on WildFly JIRA.

Java EE 7 and WildFly in France, Germany, and Switzerland

Andrew Rubinger (@ALRubinger) and I are starting this Spring with a tour of France, Germany, and Switzerland.

Paris JUG: 3/19
Marseille JUG: 3/20
Riviera JUG: 3/21
AeroGear hackathon: 3/22
JavaLand: 3/25 & 3/26
Zurich JUG: 3/27

There will be lots of discussions on Java EE 7, WildFly, Arquillian, AeroGear, Cordova, JBoss Tools, Open Source, Red Hat or anything else that comes to your fancy. Personally, I’m always interested in sharing fitness workout routines and talking about how we can inspire kids/teenagers through Devoxx4Kids.

I’m always up for running in any of these cities. JavaLand already has a community run scheduled for Mar 26th. Lets see which city has the runners to take me out city seeing ;-)

Where will we see you ?

REST vs WebSocket Comparison and Benchmarks

One of the common questions asked during my #JavaEE7 presentations around the world is how do WebSockets compare with REST ?

First of all, REST is a style of architecture so what really people mean is RESTful HTTP. As an architecture cannot be compared with a technology. But the term is so loosely used that they are used in place of each other commonly.

Lets start with a one line definition for WebSocket …

Bi-directional and full-duplex communication channel over a single TCP connection.

WebSocket solves a few issues with REST, or HTTP in general:

  • Bi-directional: HTTP is a uni-directional protocol where a request is always initiated by client, server processes and returns a response, and then the client consumes it. WebSocket is a bi-directional protocol where there are no pre-defined message patterns such as request/response. Either client or server can send a message to the other party.
  • Full-duplex: HTTP allows the request message to go from client to server and then server sends a response message to the client. At a given time, either client is talking to server or server is talking to client. WebSocket allows client and server to talk independent of each other.
  • Single TCP Connection: Typically a new TCP connection is initiated for a HTTP request and terminated after the response is received. A new TCP connection need to be established for another HTTP request/response. For WebSocket, the HTTP connection is upgraded using standard HTTP Upgrade mechanism and client and server communicate over that same TCP connection for the lifecycle of WebSocket connection.
  • Lean protocol: HTTP is a chatty protocol. Here is the set of HTTP headers sent in request message by Advanced REST Client Chrome extension.

    And the response headers received from WildFly 8:

    These are 663 characters exchanged for a trivial “Hello World” echo. The source code for this simple application is here.

    For WebSocket, after the initial HTTP handshake, the data is minimally framed with 2 bytes.

Lets take a look at a micro benchmark that shows the overhead caused by REST over a WebSocket echo endpoint. The payload is just a simple text array populated with ‘x’. The source code for the benchmark is available here.

The first graph shows the time (in milliseconds) taken to process N messages for a constant payload size.

websocket-rest-messages

Here is the raw data that feeds this graph:

websocket-rest-constant-payload

This graph and the table shows that the REST overhead increases with the number of messages. This is true because that many TCP connections need to be initiated and terminated and that many HTTP headers need to be sent and received. The last column particularly shows the multiplication factor for the amount of time to fulfill a REST request.

The second graph shows the time taken to process a fixed number of messages by varying the payload size.

websocket-rest-payload

Here is the raw data that feeds this graph:

websocket-rest-constant-messages

This graph shows that the incremental cost of processing the request/response for a REST endpoint is minimal and most of the time is spent in connection initiation/termination and honoring HTTP semantics.

These benchmarks were generated on WildFly 8 and the source code for the benchmark is available here.

Together the graph also shows that WebSocket is a more efficient protocol than RESTful HTTP. But does that mean it will replace RESTful HTTP ?

The answer to that, at least in the short term is, NO!

  • WebSocket is a low-level protocol, think of it as a socket on the web. Every thing, including a simple request/response design pattern, how to create/update/delete resources need, status codes etc to be build on top of it. All of these are well defined for HTTP.
  • WebSocket is a stateful protocol where as HTTP is a stateless protocol. WebSocket connections are know to scale vertically on a single server where as HTTP can scale horizontally. There are some proprietary solutions for WebSocket horizontal scaling, but they are not standards-based.
  • HTTP comes with a lot of other goodies such as caching, routing, multiplexing, gzipping and lot more. All of these need to be defined on top of WebSocket.
  • How will Search Engine Optimization (SEO) work with WebSocket ? Works very well for HTTP URLs.
  • All proxy, DNS, firewalls are not yet fully aware of WebSocket traffic. They allow port 80 but might restrict traffic by snooping on it first.
  • Security with WebSocket is all-or-nothing approach.

This blog does not provide any conclusion because its meant to trigger thoughts!

And if you want a complete introduction to JSR 356 WebSocket API in Java EE 7, then watch a recently concluded webinar at vJUG:

So, what do you think ?

WildFly 8 CR1 on OpenShift (Tech Tip #7)

OpenShift-logo

OpenShift is Red Hat’s PaaS platform and comes in three flavors:

  • Origin is the Community PaaS offering. You can explore the community-driven open source upstream of OpenShift. Join the community.
  • Online is the Public PaaS offering. Host your applications in the public cloud with automated provisioning, management, and scaling of applications. Sign up for free.
  • Enterprise is the Private PaaS offering. Leverage PaaS in your own data centers and private cloud. Request evaluation.

With 1.5m+ total apps created, 2400 apps created each day, 2100 new users each week, OpenShift provides the best PaaS experience for Java with JBoss EAP, Tomcat, Jenkins, Maven, Eclipse, MongoDB, MySQL, and a whole variety of pluggable cartridges. OpenShift provides great velocity by providing support for devops, Node.js, Ruby, Mobile, NoSQL. In addition it also offers stability by offering multi-tenancy, security, auto-scaling, no lock-in, and Red Hat Enterprise Linux.

OpenShift was the first PaaS to offer support for WildFly, naturally! As WildFly CR1 was released recently with 100% Java EE 7 TCK passing, the developer cartridge has been updated as well.

Lets take a look at how to get started with WildFly CR1 using the CLI tools. Alternatively, Web Console or IDE can be used as explained in Getting Started Guide.

  1. Install the client: sudo gem install rhc
  2. Setup your environment: rhc setup
  3. Create your application as shown

    And now you have your first application running on OpenShift and deployed on WildFly. Console should show the following output:

openshift-console-techtip7

The application is now accessible at:

http://mywildfly-milestogo.rhcloud.com and looks like:

wildfly-openshift-mainpage-techtip7

Port forwarding can be enabled by issuing the following command:

Now WildFly’s wonderful admin console is accessible at http://localhost:9090 and is automatically redirected to your instance running on OpenShift.

You can also get some more details about the service at:

http://mywildfly-milestogo.rhcloud.com/snoop.jsp

Do you want to try deploying one of the Java EE 7 samples on this application now ? May be a WebSocket one ;-)

IntelliJ IDEA 13, Java EE 7 and WildFly (Tech Tip #4)

IntelliJ IDEA 13 was recently released – download now!

intellij-idea13

What’s New provide a comprehensive list of new features in this release, and there are plenty! Needless to say the features that I’m most excited about is Java EE 7 and WildFly support.

Here are some of the highlights for Java EE 7 in IDEA 13:

  • Support for JavaServer Faces 2.2 including a rich set of coding assistance features for flows, actions, contracts, pass-through attributes, and more.
  • Improved navigation, code analysis, and diagrams for injected beans, including Context and Dependency Injection 1.1 annotations and beans.xml configuration.
  • New JAX-RS 2.0 and WebSocket annotations are supported with additional code completion and analysis for path parameters; improved REST Client tool window (now with authorization capabilities and requests history.)
  • Advanced coding assistance for Batch Processing jobs definition, including specific code completion, navigation, code analysis, and many more.
  • Easier project configuration: no need to download or configure Java EE libraries if they are bundled with application server you’re using. This was my personal pet peeve for the longest time and is very clean now.

Andrey Cheptsov (from JetBrains), Antonio Goncalves (a very famous Java person ;) and myself did a webinar a few days ago highlighting some of these capabilities. A replay of the webinar is now available:

Here is a quick tutorial and a playlist of videos that show the Java EE 7 features in detail:

WildFly 8 Beta2 snapshot can be easily configured as well:

techtip4-wildfly8-beta2-snapshot-idea13

Here are some additional videos for you to get started:

  • How to import Java EE 7 samples from GitHub,
  • How to test RESTful web applications using REST Client tool window,
  • How to debug WebSockets,
  • And finally how to configure Java EE 7 using Gradle.

A fully imported Java EE 7 samples repo is shown below:

tectip4-javaee7-samples

IntelliJ has definitely matured a LOT since I tried it first a few years ago. Congratulations to the entire team for a release well done, especially Andrey who really listened to all the feedback and Philip Torchinsky (ex-colleague and a friend) who triggered my interest back in IntelliJ.

Note that Java EE support is only available in Ultimate Edition, not the free Community Edition. Compare the feature sets between the two here. Both the bundles are available for download here.

Also note, IDEA 13 still requires JDK 6 for retina display although there is a hack available for JDK 7.

Red Hat at JavaLand : Java EE 7, Enterprise Testing using Arquillian, JBoss Way

Java conference in a theme park ? How will I explain that to family and friends ? But I’ve spoken at many such venues which are difficult to explain. This one is definitely first of its kind :-)

javaland-logo

JavaLand (Mar 25/26, 2014) is the event created by the Java community for the Java community. This is definitely going stir the interest of German Java developers. I was fortunate to be selected amongst 100 submissions from 18 countries. After speaking in 37 countries, this will be my first speaking engagement in Germany.

The conference venue is Phantasialand, a theme park in Brühl, Germany, and is exclusively reserved for the attendees for two days of the conference.

Here are the announced sessions to be presented by Red Hat speakers:

  • 50 new features of Java EE 7 in 50 minutes: Arun Gupta
  • Testing the Enterprise Layers: The ABCs of Integration Testing: Andrew L Rubinger
  • Building Modern Applications using JBoss and OpenShift: Pete Muir

There is lots of good content at the conference. But attendees will have to strike a balance between them and Black Mamba, Colorado Adventure, Talocan, JUMP!, River Quest, Mystery Castle, and Fantissima – this is going to be a tough call ;-)

I’ll be staying at Hotel Matamba in Africa. Where will you be – Fantasy, Berlin, Mexico, China town or Mystery ?

Hotels within the theme park are selling out fast, make sure to register rather promptly. You can also consider coming with your family and there are deals available.

Java EE Samples Github Organization: Java EE 7 Samples and Hands-on Lab already moved

After 737 commits, 15 contributors, 134 tests, its time for github.com/arun-gupta/javaee7-samples to move to github.com/javaee-samples/javaee7-samples. Similarly Java EE 7 hands-on lab is also moved from github.com/arun-gupta/javaee7-hol to github.com/javaee-samples/javaee7-hol.

Octocat

Java EE samples organization is a new GitHub organization, instead of a personal repo, and will provide a common ground for everybody in the community to contribute.

Moving these two repos to an organization opens up room for growth. If you have any Java EE 6/7 samples, tests, applications, hands-on lab or any other guides then feel free to transfer/create a new repository and contribute. This new organization would provide a common ground for all app server vendors like Red Hat, Oracle, IBM and Tomitribe to contribute. Independent consultants and every body else is welcome to contribute content too.

This will be a new central location for all samples around Java EE – truly showing the power of Community Powered Innovation!

Ready to contribute ?

  • Arquillian Hackergarten provide instructions on how to contribute unit tests to Java EE 7 Samples. WildFly and GlassFish CI jobs polls the workspace every 15 minutes.
  • Convert Java EE 7 hands-on lab to AsciiDoc by assigning an issue to yourself.

This will be one organization to rule them all :-)

Thanks to Aslak Knutsen, the Arquillian man, for the nudge!

Java EE 7 Hackergarten @ Devoxx 2013

What is Hackergarten ?

Hackergarten is a craftmen’s workshop, classroom, a laboratory, a social circle, a writing group, a playground, and an artist’s studio. Our goal is to create something that others can use; whether it be working software, improved documentation, or better educational materials. Our intent is to end each meeting with a patch or similar contribution submitted to an open and public project. Membership is open to anyone willing to contribution their time.

hackergarten-logo

In short, changing the open source world, one commit at a time!

And that’s what we did at Devoxx 2013 yesterday. Several of us got together in the back of a room, did a poll on what technologies everybody is interested in, gathered around the tables, and started hacking right away!

I was coordinating a team that helped create Arquillian tests for Java EE 7 samples. It was pretty amazing that most of the folks stayed from 9:30am – 5pm, without any break. We had lots of interesting discussions, tons of information exchange on how Java EE 7 work, how Arquillian enables to write container-independent tests and run them in a managed or remote environment easily, how to file bugs on JCP specs, and much more.

Here are some pictures from the event:

   
   

Here is the state of samples repo the morning of hackergarten:

devoxx2013-github-before-hackergarten

And here is the state the morning after hackergarten:

devoxx2013-github-after-hackergarten

As you can see the repo got:

  • 5 new contributors
  • 63 new commits
  • 10 more forks

And to give a slightly better idea of what we did in the hackergarten, here is a pulse of samples repo in the last 24 hrs:

devoxx2013-hackergarten-pulse

This to me, summarizes the power of hackergarten.

Many thanks to @aslakknutsen, @radcortez, @pdudits, @alexishassler, @g_scheibel, @xcoulon, @lightguardjp and many others who helped in making this successful. Even @jfarcand participated remotely in this hackergarten and contributed a new sample.

Of course, this was not possible without Andres Almiray‘s initiative!

A Jenkins job is running on cloudbees and will hopefully generate a consolidated test report on WildFly soon.

The whole experience completely blew away my expectations and I’m truly learning the power of Red Hat’s spirit of “Community Powered Collaboration”.

The formal conference starts in a few hours, and I better get my run in before that. Come talk to me and lets talk you can help with this effort.

See you there!

 

Java EE 7 University at Devoxx 2013

Antonio and I gave a What’s New in Java EE 7 Platform University Session at Devoxx 2013 earlier today. The room was pretty big and almost 90% full. We basically took our “50 tips for Java EE 7 in 50 minutes” from JavaOne 2013 and explained each feature with a lot more code samples. We both really enjoyed sharing our passion with the attendees and think highly interactive attendees also had fun. At least that’s what ~98 tweets asked during the session indicate.

The slides from the session are available:

Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013

And all the code samples used in the talk are available at github.com/arun-gupta/javaee7-samples.

And here are some sample tweets from during/after the session:

 

 

 

 

 

And last but not the least:

If you want to learn more about Java EE 7, we’d love to see you at the Hackergarten tomorrow. Help us write tests for these samples and learn some WildFly, GlassFish, and Aquillian skills. Aslak Knutsen, the Arquillian man, will be there himself. And then we have our Java EE 7 hands-on lab on Wednesday, 14:00 – 17:00.

Enjoy some pictures from the event so far …

 
 
   

And the evolving album so far …

I hope to meet lots of you. See ya at Hackergarten tomorrow, 9:30 by back wall of the exhibitor hall!

Java EE 7 at Transylvania JUG

Transylvania JUG is now Java EE 7 ready!


(picture by Constantin Pârțac, more pics in his album)

I connected with Gabriel Pop (JUG leader) at QCon London earlier this year and we have been working on dates since then. I’m so glad it finally worked out. The session was scheduled for about 2 hrs but ~130 attendees were having fun and went for an hour beyond that. This was all the more impressive given that it was a weekday.

Their logo is indeed one of the best ones

I walked through lots of Java EE 7 samples and enjoyed the interaction with the attendees. I used a mix of WildFly 8 beta 2 snapshot (get started now) and GlassFish 4 to run different samples. The walkthrough included the following samples:

  • websocket/whiteboard
  • batch/chunk-csv-database
  • batch/chunk-partition
  • batch/listeners
  • jms/send-receive
  • cdi/bean-discovery-all
  • cdi/vetoed
  • concurrency/managedexecutor
  • jaxrs/jaxrs-client
  • jaxrs/async-client
  • jaxrs/async-server
  • json/streaming-parser
  • json/object-parser
  • jta/transaction-scope
  • validation/methods
  • javamail/definition

Slides are, well slides, code is king! :-) IMHO, this is the best way to understand Java EE 7.

Is your JUG interested in getting a similar session for Java EE 7 ? Drop me a note or leave a comment on this blog.

In this country of Nadia Comăneci, it was pretty impressive to see that 30-40% of the attendees were women. And somebody in the audience even made a comment “Women in Romania are smarter than men” ;-) This was very inspiring for me as typically the female attendees are far lower in number.

About 90% of the attendees use some open source technology in their daily life. But only ~6 contribute back. I’m not surprised by that because that is a very typical ratio. David Blevins has written an excellent post on why All Open Source communities need your support. I highly encourage you to read it. Open Source is very much the DNA of Red Hat. jboss.org has plenty of projects that provide you an opportunity to get involved. I highly encourage you to pick a project and start contributing – bugs, patch, docs, feature, anything goes a long way!

Romania is a very running friendly country. Constantin introduced me to a local night 10k  and so I signed up for that. I met some members of local Road Runners club and we instantly connected. Java community is the best and allows me to meet from developers all around the world. We instantly start talking same language, same issues, get into our religious battles. Running community very much mimics that ;-)

I enjoyed the course so much that I went back for another 10 miler this morning.

Check out some pictures from the trip:

   
 
   

And the complete album:

I also spent some time clean up github.com/arun-gupta/javaee7-samples in order to prepare for Devoxx Hackergarten. I’d love to see you there!