Introduction:
We all have worked on creating custom adapter module in various projects at some point. And we have mostly written all our custom modules in EJB(Enterprise Java Bean) 2.1 standard. In this blog, let’s look into few main differences between EJB 2.1 and 3.0 standards and how to develop and deploy your custom modules in EJB 3.0 standard. This document will be more helpful if you have basic knowledge on how to create/develop custom adapter modules in EJB 2.1 standard.
Differences:
Few key differences between EJB 2.1 and EJB 3.0 are
S.No | EJB 2.1 | EJB 3.0 |
1 | XML deployment descriptor(ejb-jar.xml) is mandatory | XML deployment descriptor is optional and annotations can be used instead |
2 | Bean implementation class must implement SessionBean interface | Not required to implement SessionBean interface |
3 | Bean implementation class must override all bean lifecycle methods whether you use them or not | Add your own bean lifecycle methods if required using annotations |
4 | Complex, more work on developers | Simple, less work on developers as container does most of the work. |
There are many other differences between EJB2.1 and 3.0, but we are not using them.
Let's create a simple adapter module in EJB 3.0:
To keep the implementation simple our custom adapter module just prints a statement to the audit log.
Step 1: Create new EJB project in NWDS


Step 2: Configure Build Path




Step 3: Create a new Session Bean


Add below annotations to the Validation class

Implement Module interface and add bean lifecycle methods using @PostConstruct and @PreDestroy annotations. Bean life cycle methods are optional and can be ignored.

Step 4: Provide JNDI name for module



Step 5: Add standard references to EAR



Repeat the steps in step5 and add below references
S.No | Reference-Target | Reference-Type | Target-Type | Provider-Name |
1 | engine.j2ee14.facade | hard | library | sap.com |
2 | com.sap.aii.af.svc.facade | hard | service | sap.com |
3 | com.sap.aii.af.ifc.facade | hard | interface | sap.com |
4 | com.sap.aii.af.lib.facade | hard | library | sap.com |
5 | com.sap.base.technology.facade | hard | library | sap.com |




Step 6: Deploy EAR into PI Web AS Java


Add SAP AS Java instance to NWDS

Open deployment perspective in NWDS

In Deployment Job view



The module should get deployed successfully without any errors

Step 7: Use module in communication channel and test
Use the module in channel

Audit log

Note:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 27 | |
| 24 | |
| 21 | |
| 20 | |
| 14 | |
| 13 | |
| 13 | |
| 12 | |
| 12 | |
| 11 |