File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Lookup EJB on Different Application servers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Lookup EJB on Different Application servers" Watch "Lookup EJB on Different Application servers" New topic
Author

Lookup EJB on Different Application servers

Abdelrahman Musa
Greenhorn

Joined: Feb 09, 2010
Posts: 5
Hi All,

How can I lookup remote EJB 3.1 deployed on Websphere Application server(V8.0) from client Application deployed on Weblogic server (10.3)?

I tried the following scripts
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
props.put(javax.naming.Context.PROVIDER_URL, "corbaname::192.168.75.104:2809");

InitialContext cxt = new InitialContext(props);

Object obj = cxt.lookup("java:global/AcasyaPrmClientEAR/PrmBusiness/dep");

DepartmentRemote departmentBoundary = (DepartmentRemote)obj;


And other code
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
props.put(javax.naming.Context.PROVIDER_URL, "iiop://localhost:2809");

InitialContext cxt = new InitialContext(props);

Object obj = cxt.lookup("java:global/AcasyaPrmClientEAR/PrmBusiness/dep");

DepartmentRemote departmentBoundary = (DepartmentRemote)obj;


and I tried all patterns of JNDI, but Unfortunately not work, I got a lot of exceptions especially NamingException & org.omg.CosNaming.NamingContextPackage.NotFound: IDLmg.org/CosNaming/NamingContext/NotFound:1.0

its Important, I want help from you

Thanks
Jayr Motta
Ranch Hand

Joined: Jul 30, 2010
Posts: 110

Abdelrahman,

Hmm, If you're getting naming exception it's because you're pointing to the wrong place. You may be pointing to the wrong JNDI server or also to a non-existing EJB.

Are you sure of this JNDI server? Have you declared your EJB under this name / address? In EJB 3.1 it's possible through the attribute lookup of the DI injections from the EJB 3.1 (@EJB, @Resource, @PersistenceContext, etc)


Feel free to ask me anything!
www.BlackBeltFactory.com/ui#!/ref=jmotta, SCJP 6, OCWCD JEE5, OCE EJB JEE6
Abdelrahman Musa
Greenhorn

Joined: Feb 09, 2010
Posts: 5
Mr. Jayr

I have two application instances deployed on different application server on my local machine, I tried to testing the EJBs instances that deployed on WAS server by deploying an web application on the same server its worked fine without any problem, but when I lookup these EJBs from other application server(Weblogic, or glassfish) Unfortunately no response.

is it my snap of code true ?
Regarding to INITIAL_CONTEXT_FACTORY should I use the callee application server factory or calling application server (WAS or weblogic Factory)?
Should I use the IIOP in this syntax?
I used global EJB JNDI name is it right ? or i have to use vendor specific JNDI name for Websphere ?


Thanks a lot
Jayr Motta
Ranch Hand

Joined: Jul 30, 2010
Posts: 110

Abdelrahman,

That's what I meant bro, you've said that you're using EJB 3.1, right? In the spec of EJB 3.1, you can declare JNDI global names through the annotation attribute lookup.



Once you did this and you have the proper address and permission to access it, then the EJB will be accessible on the global JNDI environment.

is it my snap of code true ?

Yes!

Regarding to INITIAL_CONTEXT_FACTORY should I use the callee application server factory or calling application server (WAS or weblogic Factory)?

I couldn't understand your question. I also don't know too much about "WAS".

Should I use the IIOP in this syntax?

No, you should use the JNDI name. java:global[/<app-name>]/<module-name>/<bean-name>[!<fully-qualified-interface-name>]

I used global EJB JNDI name is it right ?

No, you didn't. I don't know the vendor-specific features of "WAS", but by default your bean will not exist in the global JNDI register.

i have to use vendor specific JNDI name for Websphere ?

If it translate into a global JNDI entry, yes.

Hope it helps. If it doesn't, keep asking and I'll help you!
Abdelrahman Musa
Greenhorn

Joined: Feb 09, 2010
Posts: 5
Jayr,

To declare JNDI global names through the annotation attribute lookup. I think we have to distinguish between Local and Remote EJBs; in Local EJB you can use annotation attribute lookup with EBJ's name,
but in case Remote you have to define ejb-ref in web.xml , is it right ???



and ejb-ref in vendor-web.xml file



please could you provide me sample of code to lookup EJBs between two different Application servers, either using EJB3.1 spec. or using InitialContext.

I appreciate your help

Thanks
Jayr Motta
Ranch Hand

Joined: Jul 30, 2010
Posts: 110

Right now I can't post an example of it because I'm at work, check this out http://publib.boulder.ibm.com/infocenter/wasinfo/beta/topic/com.ibm.websphere.base.doc/info/aes/ae/cejb_ref.html and if it doesn't make yourself clear I'll code an example for you!

Let me know!
Abdelrahman Musa
Greenhorn

Joined: Feb 09, 2010
Posts: 5
Jayr,

I tried all possibilities but useless, please provide me sample code about this issue

Thanks a lot
Abdelrahman Musa
Greenhorn

Joined: Feb 09, 2010
Posts: 5

the technique that used in the following forum describe the Lookup EJBs on remote server from Java client resolved the problem,
but I feel its not sense when the client is other application server
http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14109046

but , when I want to connect to EJB on remote sever(WAS) from client deployed on Weblogic, should I use the same technique ?

Thanks
Jayr Motta
Ranch Hand

Joined: Jul 30, 2010
Posts: 110

There is no difference between a non-EJB client and an EJB client from the access perspective, it could have from the injection perspective(once certain classess are not managed by the container).

If the technique worked there it's because they've wired everything correctly. The ejb name with the reference that becomes a JNDI global name and then referencing this one in any other code, either in an EJB through injection annotations or in any class through JNDI lookup.
Lekamge Perera
Greenhorn

Joined: Aug 01, 2011
Posts: 5

Hi,

I know this is an old post. but I'm having the same problem. So far nobody has posted a proper answer in this thread.

I think Jayr is missing the fact that the two servers Musa is using are from two different vendors.

"Regarding to INITIAL_CONTEXT_FACTORY should I use the callee application server factory or calling application server (WAS or weblogic Factory)?
Should I use the IIOP in this syntax?
"

could someone please shed some light on this issue?

Thanks
 
Don't get me started about those stupid light bulbs.
 
subject: Lookup EJB on Different Application servers