| Author |
How to create Client side stubs and Plan descriptors using weblogic
|
Schandha Ravi
Ranch Hand
Joined: Oct 20, 2007
Posts: 167
|
|
Hi All, I'm using Eclipse Europa(3.3) configured to Weblogic 9.1 server. I was attempting to create a simple J2EE Enterprise Application, where in a web application would send a name and a Stateless session bean needs to return a greeting msg. Using eclipse, however I was able to create my Bean class, Remote and Home interfaces and also written ejb-jar.xml. Now my question is how to generate client side stubs. While creating the bean, I was asked whether I needed any client jar file containing stubs and other needed files and I said yes, but I thought that container would generate that jar file for me so that I can include that in the classpath while coding the servlet. But this is not happening. My first question is 1) How to generate client side stubs using weblogic 9.1 and as per the documentation java weblogic.appc would generate them for me.But It didn't happen actually. 2) My second question is how is weblogic-ejb-jar.xml is generated. Is it generated during deployment or should be generated before deployment. If so how do I get this file. Because I need to set my JNDI mappings also here. To be frank, I have been struggling for a month now to set up my J2EE environment but have miserably failed . Please some one on the network help me in fixing this.
|
Thanks & Regards, SK
SCJP 5.0, DB2 - 800, DB2 - 803, SCDJWS (On the way)
|
 |
Marcos Maia
Ranch Hand
Joined: Jan 06, 2001
Posts: 977
|
|
Hi, I strongly recommend you to use Workshop wich is packaged with Weblogic 9. About your questions: 1) Yes appc can generate stub classes 2) weblogic-ejb-jar.xml usually has to be generated before you deploy(workshop will do this for you). regards
|
 |
Chris Manson
Greenhorn
Joined: Mar 14, 2008
Posts: 7
|
|
Hi, Actually I would be glad if someone could share his experience in: 1) generating ejb client stubs packaged in client.jar file using maven2 and ant 2) generating template weblogic-ejb-jar.xml from existing ejb-jar.xml (not via annotations in classes) Workshop is not an option, we already have our own IDE. Cheers, Lucas
|
 |
Roger Chung-Wee
Ranch Hand
Joined: Sep 29, 2002
Posts: 1683
|
|
|
My preference is to use the wlappc Ant task supplied by BEA, although I know people who prefer to write a shell script which calls weblogic.appc. Regardless of how you do it, you must run weblogic.appc to generate the stubs.
|
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
|
 |
Schandha Ravi
Ranch Hand
Joined: Oct 20, 2007
Posts: 167
|
|
Thanks Roger, Is there any such tool available for Jboss to generate Client Side stubs
|
 |
Chris Manson
Greenhorn
Joined: Mar 14, 2008
Posts: 7
|
|
Roger, I use the following declaration in an ant script: But it does not generate the ejb-client jar, only the full ejb jar. I need to create the ejb-client jar to use it on a tomcat server to communicate with the weblogic. Maybe I'm doing something wrong ? Do you have an example of a working script that generates stubs for remote clients and package them in an ejb-client jar ? Thanks! [ March 17, 2008: Message edited by: Lucas Opara ]
|
 |
Roger Chung-Wee
Ranch Hand
Joined: Sep 29, 2002
Posts: 1683
|
|
Does your JAR file contain classes whose names include "WLStub" and "Impl"? If so, then this JAR file must be on your client classpath. Your client classpath also needs either wlclient.jar or weblogic.jar. Try wlclient.jar first.
|
 |
Chris Manson
Greenhorn
Joined: Mar 14, 2008
Posts: 7
|
|
Roger, Those are the classes that are generated by appc for one EJB called "AtmServices": AtmServices.class AtmServicesBean.class AtmServicesHome.class AtmServicesLocal.class AtmServicesLocalHome.class AtmServices_wmrzn4_ELOImpl.class AtmServices_wmrzn4_EOImpl.class AtmServices_wmrzn4_EOImplRTD.xml AtmServices_wmrzn4_EOImpl_1001_WLStub.class AtmServices_wmrzn4_EOImpl_IIOP_WLStub.class AtmServices_wmrzn4_EOImpl_WLSkel.class AtmServices_wmrzn4_HomeImpl.class AtmServices_wmrzn4_HomeImplRTD.xml AtmServices_wmrzn4_HomeImpl_1001_WLStub.class AtmServices_wmrzn4_HomeImpl_IIOP_WLStub.class AtmServices_wmrzn4_HomeImpl_WLSkel.class AtmServices_wmrzn4_Impl.class AtmServices_wmrzn4_Intf.class AtmServices_wmrzn4_LocalHomeImpl.class _AtmServicesHome_Stub.class _AtmServices_Stub.class _AtmServices_wmrzn4_EOImpl_Stub.class _AtmServices_wmrzn4_HomeImpl_Stub.class Those classes are all packaged in one jar that needs to be deployed on the weblogic server. But for the ejb-client jar, I certainly do not need all those classes. Do I have to package an ejb-client myself, including the classes needed for the remote client? If so, do you know which classes need to be included for the client? Do I need to use something like this in my build.xml: Thank you, Lucas [ March 17, 2008: Message edited by: Lucas Opara ]
|
 |
Roger Chung-Wee
Ranch Hand
Joined: Sep 29, 2002
Posts: 1683
|
|
|
You are not supposed to know which classes the client needs, so just place the JAR on the client classpath. Once you have got the wlclient.jar on the classpath as well, your client should be able to do a JNDI lookup on the home object, get the stub which implements the remote interface and invoke the bean methods.
|
 |
Chris Manson
Greenhorn
Joined: Mar 14, 2008
Posts: 7
|
|
It is definitively dirty to have classes such as *Bean.class in the remote client classpath. Those classes are the EJB implementations classes and are not required on the remote client side. A best practice is to extract the stubs, remote home and remote interfaces in a client jar that is lighter and distributed to all remote clients. Maven 2 has a plugin to generate the client jar containing only the home and remote interfaces: Then I need to add the proprietary stubs classes relative to each application server. In my case, I need to know which stubs classes generated by appc need to be placed in the ejb client jar. Of course I could do the quick and dirty trick and add the entire ejb jar in the client classpath and it would work... But I like clean deployment [ March 17, 2008: Message edited by: Lucas Opara ] [ March 17, 2008: Message edited by: Lucas Opara ]
|
 |
Chris Manson
Greenhorn
Joined: Mar 14, 2008
Posts: 7
|
|
I found the solution to my problem, it's really easy but you need to know it. Weblogic supports the tag <ejb-client-jar> in ejb-jar.xml to generate client stubs. If you include it, and call the ant task wlappc, it will generate the stubs. [ March 17, 2008: Message edited by: Lucas Opara ] [ March 17, 2008: Message edited by: Lucas Opara ]
|
 |
Roger Chung-Wee
Ranch Hand
Joined: Sep 29, 2002
Posts: 1683
|
|
Well done, I had completely forgotten about the ejb-client-jar element! For Web applications, put the ejb-client-jar.jar in the /lib directory. For non-Web clients, include the ejb-client-jar.jar in the client�s classpath.
|
 |
 |
|
|
subject: How to create Client side stubs and Plan descriptors using weblogic
|
|
|