on 06-16-2005 3:36 PM
Hi,
we want to use EJB's as models in Web Dynpro. Because there is no possibility at the moment to include them as models directly, we decided to use Java Beans instead. That means, a Java Bean encapsulates a method of an EJB.
We decided not to expose the ejb as a webservice and import that as a model because performance is a big issue.
My question is: is this way (calling an ejb via a Java Bean) an "officially" supported workaround?
And if so: how has the Java Bean to be implemented? Namely we aren't able at the moment to add any jars to the Java Bean (e.g. jars to call the ejb). When we do this, the Java Bean is not recognized any more in web dynpro.
Any help to this topic is appreciated.
Greetings.
Achim
Check this
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/webdynpro/us... ejbs in web dynpro applications.pdf
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi everybody,
thanks to all for the very helpful posts.
We finally managed to call the ejb from our JavaBean in WebDynpro. The main obstacle at the end was the fact, that the properties of the JavaBean were complex types and we included the corresponding classes in the JavaBean archive as another JAR-file. We finally discovered that this was the reason which prevented us to import the JavaBean in WebDynpro.
After we extracted the JAR-file of the complex classes in the JavaBean the import in WebDynpro and the call to the EJB worked as expected.
Greetings.
Achim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
if u created ur EJB u can access it in webdynpro using the following code.
try{
InitialContext ic = new InitialContext();
Object obj = ic.lookup("localejbs/<Project name>/<Bean name>");
<UrlEjbLocalHome object> home = (UrlEjbLocalHome)PortableRemoteObject.narrow(obj,UrlEjbLocalHome.class);
UrlEjbLocal ejb = home.create();
<then create a context attribute of java native type of URLEJBBEAN type and set is as follows , here bean1 is that context attribute>
wdContext.currentContextElement().setBean1(ejb);
// wdComponentAPI.getMessageManager().reportSuccess("before connection");
<I have connect as my method in my bean that i'm accessing in this below line>
j = ejb.connect();
<now u can continue ur code >
<
a = ejb.getNodeListForAdd();
num = ejb.getNoOfNodes();
}
else
{
// wdComponentAPI.getMessageManager().reportSuccess("not connected");
}
}
catch(Ex)
{}
hope this helps u.
Regards,
Sirisha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Achim,
Your solution of encapsulating EJB methods in a JavaBean and importing the JavaBean into Web Dynpro is a great solution which I have personaly used in the past.
I would not call it a work around. It is a J2EE design pattern, where the JavaBean acts as a facade to the EJB.
You will need of course to implement the EJB lookup code in the JavaBean or one of it's helper classes.
You need to pack the JavaBean code and it's related classes into a JAR, and import the JAR via the Java Bean import model in Web Dynpro.
G-Luck,
Itai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Itai,
how exactly did you pack the JavaBean code and it's related classes (e.g. ejb-access) into the JavaBean jar? When we added a JAR-file which contained the related classes to the JavaBean jar, we could import the JavaBean as a model but got a 'ClassNotFoundException' for the related classes.
When we packed the related classes directly into the JavaBean jar (without encapsulating them into another jar), we weren't able to import the JavaBean jar as a bean model any more.
It seems that exact pattern name is Business Delegate
http://java.sun.com/blueprints/corej2eepatterns/Patterns/BusinessDelegate.html
VS
Hi Achim,
I'm adding a link to a zip files that includes a Web Dynpro project, an EJB project file and a Java Model Bean project. I created these projects to demonstrate how the import functionality works. I'm sure this is not the only way to do it, but this worked from me.
You can DL the files from here:
Itai
Hi,
For my knowledge you can't achieve this using the java bean importer.
Java Bean importer will take simple bean as input.
regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.