+

Search Tips   |   Advanced Search

Access the samples

  1. Download WAS samples from GitHub WASdev. Other samples are available at ibm.com: WAS v8.5 Samples

  2. Load samples using wsadmin. For example...

      cd app_server_root/bin
      ./wsadmin.sh -profileName cw_profile -lang jython -c "AdminApp.install('/opt/sample.javaee7.websocket.war', '[ -MapWebModToVH [[ .* .* default_host ]] -appname sample.javaee7.websocket]')"

    Deploy samples using console...

    1. Unzip Sample.zip

    2. Go to...

        http://hostname:9060/ibm/console/

      ...and select...

        Applications | New Application | New Enterprise Application link | Using the Local file system | Browse | /path/to/downloaded/file/InstallableAps/file.ear

    3. Click Next to follow the wizard using the default options until the Finish button is displayed.

    4. Click...

  3. Use your browser to access the home page; for example:

      http://hostname:9080/sample_name/

To load files in Rational Application Developer, create a new project with same name as sample, then import the sample.zip file into the project.


GitHub available samples

Access the following selected samples in GitHub.

sample.javaee7.websocket These web socket samples show how to set up WebSocket Endpoints using annotations or programmatically. These samples exercise opening, reading from, writing to, and closing a WebSocket connection. Also shown is the use of encoders, decoders, the PathParam annotation, and Pong message processing.
sample.javaee7.el30 EL 3.0 (Expression Language) samples. Examples are provided for using lambda expressions, concatenation, and new operators. In addition, it provides a simple sample of a stand-alone servlet that shows EL in use without JSP.
sample.javaee7.servlet.nonblocking These non-blocking I/O samples on GitHub demonstrate how to use new APIs added to ServletInputStream and ServletOutputStream. The example includes usage of ReadListener and WriteListener interface APIs.

sample.javaee7.sleepybatchlet Use the JSR-352 batch reference implementation in the product. The application is composed of a batchlet and one batch job that sleeps for a user-defined number of seconds. Every second, the batchlet prints to the console to show that it is working. Wrapped around the batch application is a web page that is designed to provide an easier, more intuitive mechanism to manage batch executions.
sample.javaee7.concurrency Use managed executors, managed scheduled executors and context service to perform tasks in parallel in a simple application.
sample.javaee7.jta Use @Transactional annotations to declaratively control transaction boundaries. Use the @TransactionScoped annotation to scope a bean lifecycle to a transaction.
sample.javaee7.jsonp JSONP follows the JSR 353 specification. The application is composed of five servlets that parse and display JSON data based on different implementations for getting the JSON code. A web UI page provides an easier, more intuitive way to try out JSON-P functions. The different tests in the JSONP sample are based on special JSON objects that facilitate JSON-based capabilities, including the construction of complex structures of data that readily convert to the JSON format.
sample.javaee7.jms This JMS sample uses the simplified API of JMS 2.0. The sample contains two servlets for performing Point to Point and Publish/Subscribe messaging. The JMS Servlet provides an implementation example to send or receive messages to a queue and also to publish and subscribe messages from a topic.

We must create some resources before deploying the application. Create resources using configuration scripts published with the sample.

  1. Run the createSIBusResources.py script from the app_server_root/bin directory to create the required resources. Provide cell, node, and server values and the path to the sample.javaee7.jms.war file in the command:

      ./wsadmin.sh -f createSIBusResources.py cell node server path_to_file/sample.javaee7.jms.war

  2. If security is enabled in the server, run the addAuthAlias.py script from the app_server_root/bin directory. Provide your user name and password in the command:

      ./wsadmin.sh -f addAuthAlias.py user_name password


sleepybatchlet sample notes

Before running the sleepybatchlet sample above, create the required resources:

  1. Verify that a Derby JDBC Provider instance exists. In the administrative console, click...

    1. If that provider does not exist, create one with a Connection pool datasource implementation type, and point to the Derby .jar file; for example:

        ${WAS_INSTALL_ROOT}/derby/lib

  2. Verify that a Default datasource instance is configured.

    1. (Administrative console) If that datasource does not exist, create one with the name Default datasource and the JNDI name DefaultDatasource that points to the Derby JDBC Provider and "${WAS_INSTALL_ROOT}/derby/DefaultDB" database.

    2. (Command line) Remotely connect your virtual machine with the WebSphere environment using SSH. Navigate to...

        ${WAS_INSTALL_ROOT}/derby/bin/embedded/

      Run ./ij.sh.

      When we see the prompt ij>, enter:

      connect 'jdbc:derby:DefaultDB;create=true';
      

      The default Derby database is created...

        ${WAS_INSTALL_ROOT}/derby/DefaultDB

    3. Add JVM arguments to the server running the batch sample. Click...

        Servers > Server Types > WebSphere application servers > server > Java and Process Management > Process definition > Java Virtual Machine > Custom properties

      Add the following custom properties:

      com.ibm.ws.batch.DB_SCHEMA Value: BATCH
      com.ibm.ws.batch.JNDI_NAME Value: DefaultDatasource

    4. After configuring the environment, install the application using the provided default values.

    5. After the application starts, open...

        /IBM/WebSphere/Profiles/DefaultAppSrv01/logs/server1/SystemOut.log

      ...and look for the following URL:

        http://hostname:9080/sample.javaee7.sleepybatchlet/


Downloading samples code

We can download the source code for samples from the GitHub repository.


Limitations of the samples

The samples are for demonstration purposes only.

The code provided is not intended to run in a secured production environment. The samples support Java 2 Security, therefore the samples implement policy-based access control that checks for permissions on protected system resources, such as file I/O.

The samples also support administrative security.


More samples and examples

Samples on developerWorks More product samples are available on WASdev.
Samples in tutorials Many product tutorials rely on sample code.
Examples in the product documentation The product documentation contains many code snippets and examples. To locate these examples easily, see the developer examples in the Reference section of the IBM Knowledge Center navigation for the product edition that we are using.
(iSeries) IBM Telephone Directory (iSeries) The IBM Telephone Directory business application is shipped separately from the product. the IBM i product documentation.


  • Install enterprise application files
  • Query the application state
  • Add, manage, and remove nodes
  • Example: Install a web services sample with the console
  • manageprofiles command
  • addNode command
  • WAS v8.5 Samples