| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
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.
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.
$ mvn clean installTo run the server in the ejb-ear subproject:
$ mvn --projects ejb-ear liberty:run-serverThe --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 buildTo start the server with the EJB sample application run:
$ ./gradlew libertyStartAlternatively, execute the run command:
$ ./gradlew libertyRun --no-daemonTo stop the server, run:
$ ./gradlew libertyStopIn 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.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
| Back | FazBrowse Home | New Git URL |