Category Archives: javaee

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!

WildFly 8 and IntelliJ IDEA Screencast (Tech Tip #19)

Viktor Gamov (@gAmUssA) published a screencast that shows how to do Java EE 7 development with WildFly and IntelliJ IDEA. The video shows how to:

  • Download and install (basically unzip ;-) WildFly
  • Configure JBoss plugin in IDEA (this enables support for WildFly)
  • Configure WildFly in IDEA
  • Run a Java EE 7 sample on WildFly

Nicely done, enjoy!

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

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 ?

NetBeans 8 and WildFly 8 (Tech Tip #6)

Announcing the availability of WildFly support in NetBeans 8 nightly builds!

Wildfly_logo

netbeans-dev-techtip6

Disclaimer: WildFly plugin provides very basic functionality as of now and is evolving rapidly to support broader feature set. It is purely for testing purpose at this time.

Many thanks to Emmanuel Hugonnet for contributing the plugin and constant support from NetBeans team, especially Geertjan Wielenga in making this possible.

How to get started ?

  1. Download NetBeans 8 nightly. Worked on existing NetBeans 7.4 as well, see instructions below.
  2. Go to “Tools”, “Plugins”, “Available Plugins”, search on “wildfly” to see the updated screen:wildfly-plugin--netbeans-techtip6click on “Install”. Follow the prompts to complete the installation.
  3. In NetBeans, go to “Services”, right click on “Servers”, select “Add Server…” to see:wildfly-server-configure-techtip6Click on “Next>”.
  4. Install or build WildFly following Tech Tip #1. Click on “Browse…” next to “Server Location…” and select the location of WildFly. For example, I used “/Users/arungupta/workspaces/wildfly/build/target/wildfly-8.0.0.Beta2-SNAPSHOT” on my machine.wildfly-server-instance-techtip6

    Click on “Next>”.
  5. Take the defaults as shown:wildfly-instance-props-techtip6and click on “Finish”. Now you can see WildFly configured in NetBeans:

    wildfly-server-techtip6

  6. Right-click on the newly added server and select “Start”:wildfly-start-techtip6to see an output something like:

    “09:51:29,191 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.Beta2-SNAPSHOT “WildFly” started in 2039ms – Started 184 of 232 services (78 services are lazy, passive or on-demand)”

    in the output console.

That’s all it takes to configure WildFly 8 in NetBeans 8!

Trying to run a simple sample showed the following window:

netbeans-server-one-time-techtip6

I particularly like this feature as it does not “corrupt” my Maven files or generate any IDE-specific files.

Do you want to try running Java EE 7 samples/tests and hands-on lab on WildFly from NetBeans ? File plugin bugs at NetBeans Bugzilla and use “WildFly” component.

Note, although this plugin can be installed in NetBeans 8 out-of-the-box, but you can configure an additional Update Center in earlier versions of NetBeans and use “http://deadlock.netbeans.org/job/nbms-and-javadoc/lastStableBuild/artifact/nbbuild/nbms/updates.xml.gz” URL. This is how I hacked my NetBeans 7.4 installation and added support for WildFly there.

Get your wheels churning and try your WildFly applications running from NetBeans 8.

Devoxx 2013 Parleys Channel : Java EE Talks and Red Hat Projects Session Replays

Devoxx 2-13 Parleys Channel is now released, a week before Christmas. All the talks, quickies, interviews are available for you to enjoy!

devoxx2013-parleys

Antonio and I gave a university session on Java EE 7 and the replay is now available in two parts:

Replay of my Java EE 7’s WebSocket API talk is also available:

Here is my brief interview on about 2 months old position at Red Hat:

In general, there were lots of talks on Java EE …

And some talks on Red Hat projects …

And some of my favorites …

I like doing running streaks but with these many fresh talks from Devoxx, I guess a parleys streak is looking very likely. A presentation a day and get reborn every day :-)

Come and Play! with Java EE 7 – JavaOne 2013 Session

Antonio Goncalves and I gave a code-driven talk at JavaOne 2013 showcasing how to build a Java EE  7 web application with:

  • HTML5 front ends with responsive design
  • Sexy graphical components
  • Manageable REST interfaces
  • Easy asynchronous processing
  • Reliable messaging
  • Transactional databases

All this within 58 minutes.

The session replay is now available:

The source referred in the talk is available at github.com/agoncal/agoncal-sample-javaee.

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!

Notes from Java EE meetup at Devoxx

Devoxx provides a great opportunity for the key Java EE players to meet and discuss topics of interest. With the recently released Java EE 7 platform this year’s Birds of Feather session goal was to collect feedback on Java EE 7, ideas and wishes for Java EE 8, and any thing else that would encourage wider participation from the community.

David Delabassee (Oracle), David Blevins (Tomitribe), Peter Pilgrim (independent), Johan Vos (Lodgon), several JUG leaders, and other interested community members were present in this meetup. And of course I was there too!

Here are my notes from the discussion:

  • Feedback on Java EE 7: JCP 2.9 allowed different Java EE 7 JSRs to run transparently. Each project had a xxx-spec.java.net project (e.g. javaee-spec.java.net) and encouraged participation from the wider Java community. Interim spec drafts and API jar files were made available on the project Downloads area (e.g. javaee-spec downloads). Adopt-a-JSR allowed 20+ JUGs around the world to help shape up Java EE 7 platform.
  • API and Specification source: The source files of the API classes and source of the specification needs to be checked into the workspace. This will enable interested members to play with the API classes and provide alternative proposals. A text-based format (e.g. AsciiDoc) for the specification source is strongly preferred. This will allow community members to provide concrete proposals for specific sections from the specification. This will also help the specification lead to easily merge the submitted proposals in the existing specification. A git-based repository is strongly preferred as it enables and encourages collaboration. For example, source code for CDI API classes is available here and the text-based specification here. If  git-based repository cannot be created then a mirror between the existing repository and git must be established.
  • TCK should be open-sourced: A JSR consists of three components: Specification, Reference Implementation, and TCK. The specification is released under a fairly standard license. However as discussed above the source for API classes and specification needs to be made more publicly available. The Reference Implementations are released under an OSI-approved license. IBM led JSR 352 and the TCK is available under Apache License 2.0. Similarly Red Hat led JSR 346 and 349 and the TCK is available under Apache License 2.0. However TCKs for Oracle-led JSRs are available under this license (similar ones for other specifications). Open sourcing the TCK has been discussed multiple times in the past and Oracle already offers TCK to non-profits like Apache and Eclipse Foundation at no charge. However this still seems a last bit of “closed” piece in the otherwise fairly open and transparent process. TCK tests can also serve as extremely valuable resource for the developers to learn the technology. Adam Bien’s SmokeTests and Java EE 7 samples are turning out valuable resources for the developers and container implementors in lack of an open source TCK.A later discussion with David Blevins (founder of Tomitribe) revealed that it is very important to have TCK from the very beginning in order to implement the container and pass compliance eventually. Otherwise significant parts of the container need to be rewritten, as was done for Apache Geronimo, to get compliance. Open sourcing the TCK would certainly allow Tomitribe to work towards Java EE 7 compliance as well.
  • Testing: 90% of the attendees were using Arquillian for testing their apps against single/multiple containers. There was no need felt to file a JSR and standardize it as that could possibly stunt the innovation in this area.
  • Making contributions easier: Steps to contribute a patch to the Reference Implementation should be clearly listed. This is not restricted to but can typically include how to checkout and build workspace, high-level package overview, run smoke tests, steps to add new tests.
  • Potential topics for Java EE 8: Simpler security, standalone CDI, Action-based framework, Event-driven system, standard way of achieving high availability on application server, ability to generate native mobile apps with a Java EE backend.

All in all, Hildeberto Mendonça summarized in three words “Because we care” on why the attendees showed up for the 7pm BoF. If you do care, get involved!

WildFly 8 is getting dressed and Candidate Release 1 is now anyday!

 

Java EE 7 Sessions from JavaOne 2013

Oracle has released first batch of sessions from JavaOne 2013 on parleys.com.

I gave a few Java EE 7 sessions and couple of them are now available:

Several other Java EE sessions are released in this batch:

  • Architecting Enterprise JavaFX 8 Applications (by Adam Bien)
  • Demsytifying Java EE (by Adam Bien)
  • Java Persistence API 2.1 (by Linda DeMichiel)
  • JSR 356: Inside the Java WebSocket API (by Danny Coward)
  • JMS, WebSocket, and the Internet of Things (by David Witherspoon and Prashant Khanai)
  • REST Security by JAX-WS (by Frank Kim)

And some of my favorite ones:

  • Building Modular Cloud Applications in Java (by Bert Ertman and Paul Bakker)
  • Home Automation for Geeks (by Kai Kruzer)
  • Is it a Car ? Is it a Computer ? No, Its a Raspberry Pi JavaFX Informatics System (by Simon Ritter, Tom Angelucci, Aleksander Belokrylov)

Thank you Oracle for releasing these sessions rather quickly! Looking forward to the next batch now.

Java EE 7 Samples (Tech Tip #2)

Where do you find a comprehensive list of Java EE 7 samples ?

github.com/arun-gupta/javaee7-samples
WebSocket (31 samples for JSR 356)
chat
websocket-client-programmatic
endpoint
javase-client
endpoint-singleton
httpsession
encoder
parameters
injection
endpoint-config
binary
encoder-programmatic
websocket-client
endpoint-programmatic-injection
endpoint-programmatic
properties
endpoint-programmatic-async
endpoint-async
websocket-vs-rest
websocket-client-programmatic-config
websocket-client-programmatic-encoders
subprotocol
messagesize
endpoint-programmatic-config
websocket-client-config
whiteboard
endpoint-partial
endpoint-security
endpoint-programmatic-partial
encoder-client
endpoint-javatype
JAX-RS (25 samples for JSR 339)
server-sent-event
server-negotiation
readerwriter-json
moxy
invocation
readerwriter
filter-interceptor
client-negotiation
jsonp
link
singleton-annotation
resource-validation
mapping-exceptions
request-binding
interceptor
invocation-async
jaxrs-endpoint
async-client
dynamicfilter
singleton-application
async-server
filter
beanvalidation
jaxrs-client
readerwriter-injection
JSON Processing (4 samples for JSR 353)
object-reader
streaming-parser
object-builder
streaming-generate
Batch Processing (14 samples for JSR 352)
batchlet-simple
multiple-steps
listeners
chunk-optional-processor
flow
chunk-exception
split
chunk-mapper
chunk-simple-nobeans
chunk-partition
chunk-checkpoint
chunk-simple
chunk-csv-database
decision
Java Message Service (4 samples for JSR 343)
jmscontext-cdi
send-receive-simple
send-receive
temp-destination
Contexts & Dependency Injection (16 samples for JSR 346)
bean-discovery-all
alternatives
extension-impl
bean-discovery-none
scopes
nobeans-xml
bean-discovery-annotated
vetoed
beanmanager
extension
decorators
built-in
interceptors
beansxml-noversion
pkg-level
exclude-filter
Concurrency Utilities for Java EE (4 samples for JSR 236)
managedscheduledexecutor
managedexecutor
dynamicproxy
manageablethread
Java Persistence API (15 samples for JSR 338)
jndi-context
schema-gen
locking-pessimistic
entitygraph
native-sql
listeners
schema-gen-scripts-external
criteria
storedprocedure
multiple-pu
locking-optimistic
pu-typesafe
native-sql-resultset-mapping
schema-gen-scripts-generate
schema-gen-scripts
Servlet (13 samples for JSR 340)
metadata-complete
protocol-handler
async-servlet
servlet-security
cookies
nonblocking
form-based-security
resource-packaging
file-upload
servlet-filters
web-fragment
error-mapping
event-listeners
Java Server Faces (18 samples for JSR 344)
resource-handling
components
simple-facelet
contracts
radio-buttons
http-get
contracts-library
composite-component
bean-validation
flows-programmatic
flows-simple
flows-declarative
file-upload
ajax
passthrough
flows-mixed
server-extension
viewscoped
Java Connector Architecture (2 samples for JSR 322)
connector-simple/connector
connector-simple
Enterprise Java Beans (6 samples for JSR 345)
embeddable
lifecycle
timer
stateless
stateful
singleton
Java Transaction API (4 samples for JSR 907)
user-transaction
transactional
transaction-scope
tx-exception
Bean Validation (2 samples for JSR 349)
custom-constraint
methods
JavaMail (1 sample for JSR 919)
definition
Expression Language (1 sample for JSR 341)
standalone
Extra
quartz
NoSQL
neo4j
voldemort
riak
oracle
cassandra
couchbase
redis
hbase
mongo
twitter-search

In addition, you can also read the Java EE 7 Tutorial or a complete reference guide in Java EE 7 Essentials.

Most of the samples work on GlassFish 4 and some need some further research. I’ve started trying them on WildFly Beta 1 as well. If the samples don’t work or you’d like to see an additional sample, please file an issue.