WASdev/sample.ejb

Name: sample.ejb

Owner: WASdev

Description: A sample that demonstrates injection of an EJB into a servlet and provides an application consisting of a servlet and stateless session bean.

Created: 2017-02-21 15:12:39.0

Updated: 2017-03-02 13:44:02.0

Pushed: 2017-10-24 16:19:12.0

Homepage:

Size: 90

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Enterprise Java Beans (EJB) Sample Build Status

This sample demonstrates injection of an EJB into a servlet. The application consists of a servlet and stateless session bean. The servlet uses annotations to inject the stateless session bean, and then performs a call on the hello method of the bean.

This sample can be installed onto runtime versions 8.5.5.0 and later.

Maven

The Liberty Maven plug-in and WebSphere Developer Tools support creating loose applications. This example creates a loose EAR application when building using Maven. After running the full build, you will see the application installed as sample.ejb/ejb-ear/target/liberty/wlp/usr/servers/ejbServer/apps/ejb-ear.ear.xml.

Using Eclipse with Maven
  1. Clone this project and import into Eclipse as an 'Existing Maven Project'.
  2. Right-click the project and select Run As > Maven Clean.
  3. Right-click the project and select Run As > Maven Install.
  4. Right-click the project and select Run As -> Run on Server.
  5. You should see the following in the console: Application EJBSample started in XX.XX seconds.
Using the command-line with Maven

This project can be built with Apache Maven. The project uses the Liberty Maven Plug-in to automatically download and install the Liberty Java EE 7 Full Platform 7 runtime from Maven Central. The Liberty Maven Plug-in is also used to create, configure, and run the application on the Liberty server.

Use the following steps to run the application with Maven:

  1. Execute the full Maven build. The Liberty Maven Plug-in will download and install the Liberty server in the ejb-ear project. It will also run all tests.

    n clean install
    
  2. To run the server in the ejb-ear subproject:

    n --projects ejb-ear liberty:run-server
    

    The --projects and -pl are equivalent options.

In your browser, enter the URL for the application: http://localhost:9080/ejb-war/ejbservlet/ In your browser, you should see the message “Hello EJB World”.

Gradle

This project can also be built with Gradle. The project uses the Liberty Gradle Plug-in to automatically download and install the Liberty Java EE 7 Full Platform runtime from Maven Central. The Liberty Gradle Plug-in is also used to create, configure, and run the application on the Liberty server.

The Liberty Gradle Plug-in supports creating loose application configuration for war tasks, but it does not yet support loose enterprise applications. This example installs the EAR file when building using Gradle. After running the full build, you will see the application installed as sample.ejb/ejb-ear/build/wlp/usr/servers/ejbServer/apps/ejb-ear.ear.

Using the command-line with Gradle

Use the following steps to build and run the application with Gradle from the root project:

  1. Execute the full Gradle build. The Liberty Gradle Plug-in will download and install the Liberty server in the ejb-ear project. It will also run all tests.

    gradlew clean build
    
  2. To start the server with the EJB sample application run:

    gradlew libertyStart
    

    Alternatively, execute the run command:

    gradlew libertyRun --no-daemon
    
  3. To stop the server, run:

    gradlew libertyStop
    

In your browser, enter the URL for the application: http://localhost:9080/ejb-war/ejbservlet/ You should see the message “Hello EJB World”.

Notice

© Copyright IBM Corporation 2017.

License

nsed under the Apache License, Version 2.0 (the "License");
may not use this file except in compliance with the License.
may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

ss required by applicable law or agreed to in writing, software
ributed under the License is distributed on an "AS IS" BASIS,
OUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
the License for the specific language governing permissions and
tations under the License.

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.