Skip to Content
Author's profile photo VINCENZO TURCO

How to leverage JNDI in Web Dynpro for Java

h2. *Web Dynpro Enterprise Java Bean models are great but…*  On each and every Java Web Dynpro tutorial we have been taught that the correct way to use Enterprise Java Bean 3.0 in Web dynpro applications is EJB model. while this is a simple and effective concept for integrating WDJ and EJBs, the most experienced developers might have noticed a few drawbacks: ** no polymorphism allowed ** need to reimport the model or modify the generated classes upon ejb interface change  What we will see in this blog is how to leverage the native lookup features of SAP Java Application Server, namely Java Naming and Directory Interface  ( While proposing new ideas we will not reinvent the wheel, i.e. existing useful features of WDJ will be nonetheless leveraged. We will be studying how this can be done in SAP NW CE 711, realizing a proof of concept Web Dynpro application which will invoke a stateless session EJB deployed locally to retrieve a list of employees. The same APIs can of course be used with later version of SAP Java AS. Previous versions support JNDI as well but with minor differences. The figure below illustrates the final result: Final result of the blog exampleh2. *Decoupling web tier and business logic* engine.jee5.facade  (required for JEE libraries)Web Dynpro application DC dependenciesOur WDJ application component controller will just feature an Employee context node with cardinality 0..n, based on model binding with Employee model (see figure below)Component Controller   The view controller will have its own Employee context node mapped to the Component Controller’s, see figure below.View Controller Context Our view will show a simple table bound to Employee context node, see figure below.Table Layout in Application View We will call our application “JndiApp” I won’t go into greater detail as there are plenty of tutorials and guides on this subjects. Bear in mind that our context is empty and our application does nothing yet, we are going to integrate it with our business logic EJB shortly. h2. Meet SAP WAS JNDI console In order for our WDJ application to perform some business logic, we need to enable the WDJ component to retrieve the stateless session EJB we previously created. To do so we need the JNDI lookup string from SAP WAS JNDI console. This name+ +represents the unique id of the EJB you want to lookup from your WDJ component.  Go to NWA in your application server: http://host:port/NWA  (http://host:port/NWA) And then: type “JNDI” in the search box in the upper right part of the screen, you will get only one result, that’s it! After starting the JNDI console, select Object in the drop down field and enter *EmployeeManager* in the input field. Then click +search+. JNDI console lookup resultYou should get only one entry. Click on the appropriate entry and in the lower part of the screen you will see a detailed view.JNDI console lookup detail

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Matthias Steiner
      Matthias Steiner
      Hi Vincenzo,

      having discussed this concept some time back I'm happy to see you spreadingthe word in a very detailled blog. Well done!

      This concept surely is very handy and worth taking a closer look on. I've been promoting the key features of our Java 5 EE server for a while. It's a powerful tool 😉

      Keep bloggin',

      Author's profile photo VINCENZO TURCO
      Blog Post Author
      Hi Matthias,
      thanks for your feedback, more stuff is underway
      Stay tuned!


      Author's profile photo Former Member
      Former Member
      EJB model sucks, bean model rocks. cheers matthias 😉