For WebSphere Application Server (WAS) V9, available on IBM Bluemix, there are some downloadable Java EE 7 sample applications that allow you to explore some selected Java EE 7 technologies. You will deploy the samples for yourself, and will find the samples on GitHub. These applications run on both WAS V9 and on Liberty (which already supports the Java EE 7 Full Platform). Let’s take a closer look at these samples.

What are the Java EE 7 samples?

Here’s a quick overview of the selected Java EE 7 samples:

sample.javaee7.websocket

  • shows how to set up WebSocket endpoints using annotations or programmatically
  • exercises opening, reading from, writing to, and closing a WebSocket connection
  • demonstrates the use of encoders, decoders, the PathParam annotation, and Pong message processing

sample.javaee7.el30

  • shows how to use some of the new Expression Language (EL 3.0) functions
  • demonstrates a use of lambda expressions, concatenation, and new operators
  • provides a simple sample of a stand-alone servlet that shows EL in use without JavaServer Pages (JSP)

sample.javaee7.servlet.nonblocking

  • demonstrates how to use non-blocking I/O by using new APIs added to ServletInputStream and ServletOutputStream
  • explores the usage of the ReadListener and WriteListener interface APIs

sample.javaee7.sleepybatchlet

  • exercises the JSR 352 batch implementation
  • provides a sample of a batchlet and one batch job that sleeps for a user-defined number of seconds
  • uses a web interface wrapped around the batch application to provide an easier access to the batch functions

sample.javaee7.jsonp

  • provides five servlets that parse and display data based on different implementations for processing JSON code
  • uses a web interface designed to provide an easier access to JSON-P functions

sample.javaee7.jms

  • uses the simplified API of JMS 2.0
  • contains two servlets for performing Point to Point and Publish/Subscribe messaging
  • provides an example how to send or receive messages to a queue and also to publish and subscribe messages from a topic

You can find the source code for the samples on GitHub, which you can download, deploy and run.

Downloading and deploying the samples to WAS on the cloud

To download and deploy the Java EE 7 samples to WAS on the cloud:

  1. Download the source code for a sample from GitHub and build your application using a Liberty server. The following articles describe how to use Maven to download and build the sample depending on whether you prefer to work from the command line or from within Eclipse:
  2. Most sample applications can be deployed without any further preparation but sample.javaee7.sleepybatchlet and sample.javaee7.jms require resources to be created before you attempt to deploy application on WAS in the cloud. Check the README.md files for each of those samples for detailed instructions.
  3. To deploy to WAS (whether in the cloud or on a local installation), you have two options:
    • Using wsadmin scripting
    • Using the graphical WAS administrative console

Deploying using wsadmin

  1. Navigate to your bin directory of your WAS installation. For example : /opt/IBM/WebSphere/AppServer/bin/
  2. Run the following command:
    ./wsadmin.sh -profileName AppSrv01 -lang jython -c "AdminApp.install('/opt/sample_name.war', '[ -MapWebModToVH [[ .* .* default_host ]] -appname sample_name]')"

Deploying using the WAS administrative console

  1. In your web browser, go to the WAS administrative console; for example: http://hostname:9060/ibm/console/
  2. Log in with your user name and password.
  3. Click Applications > New Application.
  4. Select the New Enterprise Application link.
  5. Using the Local file system option, click Browse, and select the .war file that you built using Maven earlier.
  6. Click Next to follow the wizard using the default options until the Finish button is displayed.
  7. When the Confirm changes section is displayed, click Save.
  8. Click Applications > Application Types > WebSphere enterprise applications.
  9. Select the check box next to the sample application, and click Start.
  10. Use your browser to access application home page; for example: http://hostname:9080/sample_name/

Join The Discussion

Your email address will not be published. Required fields are marked *