cancel
Showing results for 
Search instead for 
Did you mean: 

Depenency Injection and Session Facade in WebDynpro DCs

Former Member
0 Kudos

Hi all,

for the sake of decoupeling the business logic and persistence from the view i introduced a session facade.

I wonder how to acess the session facade bean from my webdynpro?

am i right that dependency injection inside a wd dc is not working?

does jndi work in a wd dc?

regards,

christian

Accepted Solutions (1)

Accepted Solutions (1)

Vlado
Advisor
Advisor
0 Kudos

Hi Christian,

First - welcome to SDN!

To your questions:

1) JNDI access to EJBs works from any client application, which means also from WD apps. <a href="http://help.sap.com/saphelp_nwce10/helpdata/en/45/e692b2cfaa5591e10000000a1553f7/frameset.htm">Here</a> you can find more information on that.

2) Dependency injection does not work within WD.

3) I would suggest you to consider the <a href="http://help.sap.com/saphelp_nwce10/helpdata/en/45/f7f744aea471fae10000000a1553f6/frameset.htm">EJB Model Importer</a> which is the easiest and recommended way for using session beans inside WD components. This is a new feature coming with <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/ce">SAP NW CE</a> aiming to increase developers productivity by reducing the need for manually written code for accessing and calling the EJB business methods.

Please do not hesitate to come back should you have any further questions.

Best regards,

Vladimir

Message was edited by:

Vladimir Pavlov

Former Member
0 Kudos

Hi Vladimir,

first of all, thanks for your fast reply, 5 seconds after my post i disovered the link you mentioned by myself =).

Now i have a question concering the jndi lookup syntax: The help suggest "ejb:/interfaceName=<fully-qualified class name of the desired bean interface>" i'm not sure what the JNDI expects as fully qualified beant interface name?

regards,

christian

Vlado
Advisor
Advisor
0 Kudos

There are some examples below the "Allowed Keys Table":


ejb:/interfaceName=test.RemoteInterface

i.e. exactly what is meant in the Java world by "fully-qualified class name"

Cheers,

-- Vladimir

Former Member
0 Kudos

Hi,

the fully qualified java classname was the first thing i tried, but i keep on getting errors that the ejb refrence could not be resolved. the DC containing the bean is a dependency of the webdynpro DC, and the bean is also exported via the public part of the DC.

Is there anything else i could have missed?

And another question: When importing a enterprise javabean into a model (we are already working with the ce), let's say a session bean acting as my facade, is there any way how i can get the bean out of the context so that i can nativly work with it? (i hope i'm not to blurry)

regards,

christian

Message was edited by:

Christian Pelster

Message was edited by:

Christian Pelster

Vlado
Advisor
Advisor
0 Kudos

Hi Christian,

> but i keep on getting errors that the ejb refrence could not be resolved

One possible reason could be that the EJB app is not started. You can easily verify that, for example with the LIST_APP telnet command.

> is there any way how i can get the bean out of the context so that i can nativly work with it?

No, but I'm also wondering why you would need so? "nativly work with it" suggests that you want to call business methods on the bean directly, right? So, why not just expose those methods from the EJB to the WD with the help of the model importer?

Anyway, if you still have a good reason to do all this stuff manually, the old good JNDI lookup is the way to go.

-- Vladimir

Former Member
0 Kudos

Hi,

thanks you answer helped a lot I now understand that the model import is "the way to go".

Now we're facing a problem with our model, we followed the procedure in the help and in wdDoInit we did:

---

com.mycompany.myapp.models.customerfacade.CustomerFacade model = new com.mycompany.myapp.models.customerfacade.CustomerFacade();

wdComponentAPI.getModelInstanceMap().putDefaultInstance("com.mycompany.myapp.models.customerfacade.CustomerFacade", model);

try {

wdContext.currentRequest_CustomerFacadeLocal_getAllCustomersElement().modelObject().execute();

}

catch(Exception e)

{

e.printStackTrace();

}

---

We get an NullPointer exception, it seems that "modelObject" is not set, any hints?

Regards,

Christian

0 Kudos

Hi Christian,

Have you changed the collection cardinality of the Request_CustomerFacadeLocal_getAllCustomersElement in the view context to be 1..1 (means mandatory and Web Dynpro creates it automatically)?

Cheers,

Vesselin

Former Member
0 Kudos

Hi,

the collection cardinality is 1..1, the exact error message reads:

---

java.lang.IllegalArgumentException: model object must not be null

---

regards,

christian

Former Member
0 Kudos

Hi any news on this topic,

i noticed that it doesn't throw an execption when the application is run from dev studio "deploy new archive and run" within the webdynpro dc.

when started direct via browser i still get:

---

##0#0#Error##Plain###java.lang.IllegalArgumentException: model object must not be null#

---

thrown by line 6:

---

1 try {

2 com.mycompany.myapp.models.customerfacade.CustomerFacade model = new com.mycompany.myapp.models.customerfacade.CustomerFacade();

3

4 wdComponentAPI.getModelInstanceMap().putDefaultInstance("com.mycompany.myapp.models.customerfacade.CustomerFacade", model);

5

6 wdContext.currentRequest_CustomerFacadeLocal_getAllCustomersElement().modelObject().execute();

7

8 }

9 catch(Exception e)

10 {

11 e.printStackTrace();

12 }

---

regards,

christian

0 Kudos

Hi Christian,

You mean that when starting it from the Developer Studio, then it works fine? Or just nothing is shown?

Btw, it is always a better approach to create and register the model in the component controller instead of in the particular view.

Cheers,

Vesselin

Former Member
0 Kudos

Hi,

for testing purposes i created a WebDynpro DC which consumes an Enterprise Bean form an EJB Module DC via an Enterprise Application DC. The model is linked to the component context via model binding, and the code in the wdDoInit of the component is the same as in my previous post (sadly with the same exception).

I feel im doing something wrong, it can't be so complicated to use an Enterprise bean from a WebDynpro.

Regards,

Christian

0 Kudos

Hi Christian,

Unfortunately I can only guess what might have gone wrong on your system...

Just a question - is the application with EJBs deployed on the engine? You know, Web Dynpro and Java EE are two different applications on the server side.

Please also make sure that the ear with the EJBs is correctly built - you can open and investigate it.

Hope this helps.

Cheers,

Vesselin

Former Member
0 Kudos

Solved.

I didn't inlcude the client.jar part of the dependency.

Thanks to all!

Answers (0)