https://github.com/mrts/local-ejb-injection
Sample project demonstrating packaging EJB JARs and WARs into EAR
https://github.com/mrts/local-ejb-injection
ear ejb ejb-jar servlet war
Last synced: 7 months ago
JSON representation
Sample project demonstrating packaging EJB JARs and WARs into EAR
- Host: GitHub
- URL: https://github.com/mrts/local-ejb-injection
- Owner: mrts
- Created: 2016-08-26T18:13:40.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-08-26T18:17:48.000Z (about 9 years ago)
- Last Synced: 2025-01-28T05:14:17.723Z (8 months ago)
- Topics: ear, ejb, ejb-jar, servlet, war
- Language: Java
- Size: 3.91 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# local-ejb-injection
This is a sample project demonstrating injecting EJBs from EJB JARs into web
applications packaged as WARs inside a master EAR.Here's how the result looks:
application-ear.ear
├── service-ejb-impl.jar
├── web-application.war
├── lib
│ └── service-ejb-api.jar
└── META-INF
├── MANIFEST.MF
└── application.xmlHere’s a usage scenario:
You have a web application packaged as a WAR that needs to use EJB services
that cannot be packaged into the WAR as they are used by other WARs in the EAR.
You annotate the service interface with `@Local`, extract it into a separate
API JAR and reference the API JAR from both the WAR and EAR projects. Then you
implement the service in an EJB JAR that is packaged into the EAR and inject
the interface with `@EJB` annotation as an instance field into a servlet in the
WAR.It’s a Maven project with the following modules:
* *web-application* – servlet that calls the EJB service, open
to access it
* *service-ejb-api* – service interface with `@Local` annotation
* *service-ejb-impl* – `@Stateless` EJB that implements the service interface
* *application-ear* – packages the EJB JAR into an EAR.Build it with `mvn package` and deploy
`application-ear/target/application-ear.ear` to the application server to run
it.