WASdev/sample.javaee7.jta

Name: sample.javaee7.jta

Owner: WASdev

Description: Demonstrates the use of @ Transactional annotations to declaratively control transaction boundaries, along with using the @ TransactionScoped annotation to scope a bean lifecycle to a transaction.

Created: 2016-02-11 15:16:35.0

Updated: 2017-06-07 20:18:58.0

Pushed: 2017-12-07 16:36:10.0

Homepage:

Size: 100

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

JTA sample for Java EE7 Build Status

This application demonstrates the use of @Transactional annotations to declaratively control transaction boundaries, along with using the @TransactionScoped annotation to scope a bean lifecycle to a transaction.

WAS Liberty
Maven

The sample can be built using Apache Maven. In the directory where you cloned the repository issue the following command to build the source.

$ mvn install

Then, in the jta-webapp directory issue the following command to run it on a Liberty server.

$ mvn liberty:run-server
WebSphere Development Tools (WDT)

The WebSphere Development Tools (WDT) for Eclipse can be used to control the server (start/stop/dump/etc.), it also supports incremental publishing with minimal restarts, working with a debugger to step through your applications, etc. WDT also provides:

Installing WDT on Eclipse is as simple as a drag-and-drop, but the process is explained on wasdev.net.

Import project and running in Eclipse/WDT:
  1. Select menu File -> Import -> Maven -> Existing Maven Projects.
  2. Select Browse… to the top level directory titled sample.javaee7.jta and select Finish.
  3. Click Yes to the WebSphere Liberty dialog to automatically create server in the Servers view for this project.
  4. Right-click the project and select Run As > Run on Server.
  5. Select the server and click Finish.
  6. Confirm web browser opens with the sample url: http://hostname:port/sample.javaee7.jta/
Gradle

The sample can be built using Gradle and the Liberty Gradle Plug-in. In the directory where you cloned the repository issue the following command to build and run the project.

$ gradle build

To start the application use the command:

$ gradle libertyStart

To stop the application use the command:

$ gradle libertyStop
WAS Classic
Configure required resources
  1. Verify that a Derby JDBC Provider instance exists. In the administrative console, click Resources > JDBC > JDBC providers.

  2. 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

  3. Verify that a Default datasource instance is configured. Click Resources > JDBC > Data sources.

  4. 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.

  5. To create the actual database, remotely connect to your machine hosting WebSphere Classic using SSH.

    • Navigate to ${WAS_INSTALL_ROOT}/derby/bin/embedded/

    • Run “./ij.sh”. When you see the prompt “ij>“, enter the following command: $ connect 'jdbc:derby:DefaultDB;create=true';

    • The default Derby database is created in the following directory: ${WAS_INSTALL_ROOT}/derby/DefaultDB

Install using the Administrative Console
  1. In your preferred browser, go to the Integrated Solutions Console; for example: http://hostname:9060/ibm/console/
  2. Log in with your user name and password.
  3. Select 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.
  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.

    Notice

© Copyright IBM Corporation 2016, 2017.

License

This information contains sample code provided in source code form. You may copy, modify, and distribute these sample programs in any form without payment to IBM for the purposes of developing, using, marketing or distributing application programs conforming to the application programming interface for the operating platform for which the sample code is written.

Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN “AS IS” BASIS AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR ECONOMIC CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE SAMPLE SOURCE CODE. IBM SHALL NOT BE LIABLE FOR LOSS OF, OR DAMAGE TO, DATA, OR FOR LOST PROFITS, BUSINESS REVENUE, GOODWILL, OR ANTICIPATED SAVINGS. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS TO THE SAMPLE SOURCE CODE.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.