Create Java Web Application using WEB Module and EJB in NWDS

Thanapuet Kaewmanee
3 min readMay 7, 2020

--

Create EJB Module

  1. Under your Software Component create new development component “EJB Module”
Select “EJB Module”
Specify the name for development component

2. In the project create a new package and session bean for the example return result.

Project Explorer Perspective
Create a new package and session bean

3. Declare getCustomerFullName() method and implement.

Declare getCustomerFullName() method in CustomerInfoLocal Interface
Implement CustomerInfoLocal into CustomerInfoBean and Override method getCustomerFullName()

Deploy EJB Module to SAP Netweaver

  1. Create EAR component
Create EAR component for deploy EJB Module
Specify the development component name and go to the last step
Add reference EJB Module to EAR Project
Right-click on EAR component and deploy

2. Test EJB on SAP Netweaver AS JAVA

EJB Explorer
find your Bean name and try to execute

The result should return the string “Thanapuet Kaewmanee” as per your coding.

Call EJB Module by font-ent (WEB Module)

  1. Create Web Module
Under your software component create new Web Module
Specify the name and then click “Finish”
Under web_demo/Java Resource/source Create new package and servlet
web.xml auto-generate <servlet> and <servlet-mapping>

2. Add dependency ejb_demo to web_demo

At component properties/dependencies of web_module
reference to ejb_demo

3. Create customerInfo instant it’s a reference to CustomerInfoLocal interface and try to call getCustomerFullName() method.

Create EJB instant and try to call to an EJB method

Deploy WEB Module and Run

  1. Add the web_demo component to the ear_demo component.

2. Deploy EAR and try to run a web module from the browser.

The result from the web module

You may return the result by JSON or another format.

--

--

Thanapuet Kaewmanee
Thanapuet Kaewmanee

No responses yet