aspose file tools*
The moose likes BEA/Weblogic and the fly likes Invoking weblogic ejb through iiop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Invoking weblogic ejb through iiop" Watch "Invoking weblogic ejb through iiop" New topic
Author

Invoking weblogic ejb through iiop

Shubhrajit Chatterjee
Ranch Hand

Joined: Aug 23, 2001
Posts: 356
Hi,
I am trying to invoke my EJB ( stateless session ) through iiop protocol. My client code is based on the sample bean provided by weblogic. I have the client code given below

When I run the client I get the following exception ...


I am invoking the EJB in the same way as it has been suggested by weblogic. I reffered to this url
http://e-docs.bea.com/wls/docs61/rmi_iiop/API_rmi_iiop.html#1044525

Can someone tell me what am I doing wrong? My EJB is OK as I can invoke it nicely from a t3 client.


Shubhrajit
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1850
Try it with the weblogic initial Context
In obtaining an initial context, you have two choices when defining your JNDI context factory:

weblogic.jndi.WLInitialContextFactory
com.sun.jndi.cosnaming.CNCtxFactory
You can use either of these when setting the value for the "Context.INITIAL_CONTEXT_FACTORY" property that you supply as a parameter to new InitialContext(). If you use the Sun version, you'll have a Sun JNDI client, which in turn uses the Sun RMI-IIOP ORB implementation of J2SE 1.3; this may be important to you if you wish to minimize the use of WebLogic classes on the client. To take full advantage of WebLogic's RMI-IIOP implementation however, it is recommended that you use the weblogic.jndi.WLInitialContextFactory method.
Shubhrajit Chatterjee
Ranch Hand

Joined: Aug 23, 2001
Posts: 356
Yep .. I am trying to avoid weblogic classes in the client.
Using weblogic's JNDI the EJB is invoked perfectly . Though I did not try iiop ( I tried t3) ... but supplying the huge weblogic.jar to the client is a big ask.
Shubhrajit Chatterjee
Ranch Hand

Joined: Aug 23, 2001
Posts: 356
I will keep this thread updated with what I have learnt...

1. My client code is working fine with weblogic specific t3 prptocol, using
weblogic.jndi.WLInitialContextFactory
This I don't want.

My motivation is to invoke my ejb in a way which is independent of any vendor specific classes. Anyway, it makes little sense for the client to have the huge weblogic.jar file for a JNDI lookup.

I am trying alternative routes to invoke my EJB from the client. I thought that invoking it over iiop would free myself from weblogic specific classes.
Thank you Rahul for your reply... but I am not being able to get this damn thing working ...
I took a perfectly valid client code which invokes the EJB over t3. Then I made the following changes ...
1. changed the protocol from t3 to iiop ie my URL was changed from t3://localhost:7001 to iiop://localhost:7001 I am still using weblogic.jndi.WLInitialContextFactory here. I got a class cast exception when I tried to narrow down the home.
2. I changed the initialcontext factory also, to the com.sun.jndi.cosnaming.CNCtxFactory
But could not get rid of the class cast exception.

I tried to look at the object when I am doing a lookup . I had the following print
com.sun.corba.se.internal.iiop.CDRInputStream$1:IOR:00000000000000
30524d493a736875622e656a622e746573742e4661723243656e74486f6d653a3030303030303030
303030303030303000000000010000000000000433000102000000000f31302e3233362e3134392e
31363900001b5900000000012c0042454108010200000000096d79646f6d61696e000000000aec95
a900000030524d493a736875622e656a622e746573742e4661723243656e74486f6d653a30303030
3030303030303030303030300000000004323737000000000142454107000000c81b593c7c46f0fa
5c000000bc000000007fffff020000003a524d493a7765626c6f6769632e726a766d2e4a564d4944
3a303030303030303030303030303030313a44433439433233454445313231453241000119c6913c
7c46f0fa5c0000001c00310030002e003200330036002e003100340039002e0031003600390aec95
a90000000700001b5900001b5900001b5a00001b5a00001b5900001b5affffffff00000010006d00
790064006f006d00610069006e00000010006d007900730065007200760065007200000003000000
010000002c0000000000010020000000030001002000010001050100010001010000000003000101
000001010905010001000000190000004b0000000000000043687474703a2f2f31302e3233362e31
34392e3136393a373030312f6265615f776c735f696e7465726e616c2f636c61737365732f737464
5f6661723263656e74402f00004245410300000253000000000000000c726f756e642d726f62696e
00010000000000001b736875622e656a622e746573742e4661723243656e74486f6d650000000000
0100000030524d493a736875622e656a622e746573742e4661723243656e74486f6d653a30303030
303030303030303030303030000000000100000000000001d7000102000000000f31302e3233362e
3134392e31363900001b5900000000012c0042454108010200000000096d79646f6d61696e000000
000aec95a900000030524d493a736875622e656a622e746573742e4661723243656e74486f6d653a
303030303030303030303030303030300000000004323737000000000142454107000000c81b593c
7c46f0fa5c000000bc000000007fffff020000003a524d493a7765626c6f6769632e726a766d2e4a
564d49443a303030303030303030303030303030313a444334394332334544453132314532410001
19c6913c7c46f0fa5c0000001c00310030002e003200330036002e003100340039002e0031003600
390aec95a90000000700001b5900001b5900001b5a00001b5a00001b5900001b5affffffff000000
10006d00790064006f006d00610069006e00000010006d0079007300650072007600650072000000
02000000010000002c00000000000100200000000300010020000100010501000100010100000000
03000101000001010905010001000000190000004b0000000000000043687474703a2f2f31302e32
33362e3134392e3136393a373030312f6265615f776c735f696e7465726e616c2f636c6173736573
2f7374645f6661723263656e74402f00
I tried to look up the API documentation of this class somewhere on the net, but I have not found it yet.

{b] The big question is : Am I missing something ? Do I have to deploy the EJB in some special way in the server, so that it can be invoked over iiop ?
[/b]
I am looking out for solutions .. I will keep this thread updated. Meanwhile if anyone can help, that would be great.
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1850
maybe sometime in my free time I will try and test this out..
Shubhrajit Chatterjee
Ranch Hand

Joined: Aug 23, 2001
Posts: 356
Solved it at last ... there was nothing wrong with the client ... I was foolish to think that no configuration at the server end ....

I re-compiled my ejb with the follwing command ...
java weblogic.ejbc -compiler javac -keepgenerated -idl -idlDirectory idlSources -iiop ejb_far2cent.jar ejb_iiop_far2cent.jar

And then redeployed it .. now everything is working fine ....
It's worth looking at the client.jar that ejbc has generated. Now it contains the stub classes also .. along with home and remote

[ July 26, 2002: Message edited by: Shubhrajit Chatterjee ]
prashant pharate
Greenhorn

Joined: Jun 04, 2012
Posts: 1
Shubhrajit Chatterjee wrote:Solved it at last ... there was nothing wrong with the client ... I was foolish to think that no configuration at the server end ....

I re-compiled my ejb with the follwing command ...
java weblogic.ejbc -compiler javac -keepgenerated -idl -idlDirectory idlSources -iiop ejb_far2cent.jar ejb_iiop_far2cent.jar

And then redeployed it .. now everything is working fine ....
It's worth looking at the client.jar that ejbc has generated. Now it contains the stub classes also .. along with home and remote

[ July 26, 2002: Message edited by: Shubhrajit Chatterjee ]


Hi Shubhrajit,

I am facing same problem. I didn't get your above solution.

My ejb is deployed on weblogic and my client requirement is JDK 1.4 so I can't use wlfullclinet or wlcinet.jar

May I know how can I lookup ejb. What changes I need in ejb and client side

My classes

EJB server

/**
* 11.06.2012.
* Session Bean implementation class CMSyncBean
* @author pharapra
*
*/
@Stateless
//(name = "CRMSyncBean", mappedName = "CRMSyncRemote")
@Remote(CRMSyncRemote.class)
@RemoteHome(CRMSyncHome.class)
public class CRMSyncBean {

public CRMSyncUserVO createWebIssuer(final CRMSyncOrganisationVO orgVO) throws BusinessException, SystemException {
}
}

//Home

public interface CRMSyncHome extends EJBHome
{
CRMSyncRemote create() throws javax.ejb.CreateException, RemoteException;
}

----------------------------------------------------------------------------------------------------------

Client

//Remote
public interface CRMSyncRemote extends EJBObject {
CRMSyncUserVO createWebIssuer(CRMSyncOrganisationVO orgVO) throws RemoteException, BusinessException, SystemException;
}

Lookup code

public static void main(String[] args) throws NamingException, RemoteException, CreateException {
Context ctx = null;
Hashtable<String, String> ht = new Hashtable<String, String>();
CRMSyncRemote remote = null;
//ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
//ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
ht.put(Context.PROVIDER_URL, "iiop://localhost:7001");
ctx = new InitialContext(ht);
final Object objref = ctx.lookup("CRMSyncCRMSync-EJB-0_0_1-SNAPSHOT_jarCRMSyncBean_EO");
System.out.println(objref);

final CRMSyncHome home = (CRMSyncHome)PortableRemoteObject.narrow(objref, CRMSyncHome.class);
System.out.println("Got CRMSyncHome: " + home + " for " + home);

home.create();
//println("Got the MEJB");

}

Exception is

IOR:000000000000003f524d493a636f6d2e746965746f2e766e2e63726d73796e632e72656d6f74652e43524d53796e6352656d6f74653a30303030303030303030303030303030000000000001000000000000023c000102000000000a3132372e302e302e31001b59000000d800424541080103000000000f6578616d706c65735365727665720000000000000000003f524d493a636f6d2e746965746f2e766e2e63726d73796e632e72656d6f74652e43524d53796e6352656d6f74653a3030303030303030303030303030303000000000000433313700000000024245412a0000001000000000000000006e11836aa3e197274245410b00000048000000000000004001003d636f6d2e746965746f2e766e2e63726d73796e632e72656d6f74652e43524d53796e6352656d6f74653a6a617661782e656a622e454a424f626a65637400000005000000010000002c000000000001002000000003000100200001000105010001000101000000000300010100000101090501000100000019000000410000000000000039687474703a2f2f3132372e302e302e313a373030312f6265615f776c735f696e7465726e616c2f636c61737365732f43524d53796e63402f000000000000001f000000040000000300000020000000040000000100000021000000a80000000000000002000600000000002200000000004000000000000806066781020101010000001f0401000806066781020101010000000f7765626c6f67696344454641554c540000000000000000000000000000000000000000000000002200000000004000000000000806066781020101010000001f0401000806066781020101010000000f7765626c6f67696344454641554c540000000000000000000000000000000000
Exception in thread "main" java.lang.ClassCastException
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at TestClient.main(TestClient.java:32)
Caused by: java.lang.ClassCastException: Object is not of remote type com.tieto.vn.crmsync.ejb.CRMSyncHome
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:221)
... 2 more
-------------------------------------------------------------------
 
 
subject: Invoking weblogic ejb through iiop