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
Size: 90
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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.
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
.
Application EJBSample started in XX.XX seconds.
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:
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
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”.
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
.
Use the following steps to build and run the application with Gradle from the root project:
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
To start the server with the EJB sample application run:
gradlew libertyStart
Alternatively, execute the run command:
gradlew libertyRun --no-daemon
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”.
© Copyright IBM Corporation 2017.
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.