This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Remote client Vs Local Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Remote client Vs Local Client" Watch "Remote client Vs Local Client" New topic
Author

Remote client Vs Local Client

Gaurav Chugh
Ranch Hand

Joined: Aug 28, 2001
Posts: 50
Hi

What is actual differnce between a local client and Remote Client and what is the reason we have two differnt types of Local home and Remote Home Interface . Is Local client means that the Local EJB is installed in the same jvm or same machine where the client reside . I want to clear my doubts in real world .

Thanks in Advance.


Regards<br />gaurav..
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Local Client means the client that is going to access the EJB deployed on same machine as client and same JVM. To create Local EJBs, EJB spec has provided EJBLocalHome and EJBLocalObject interfaces. Local client was required due to the performance issues, so that if client and EJB reside on same machine then instead of going over the network, the container can find it locally. Say you have two EJBs which uses each other frequently, so you do the analysis and found out that if you make them local to each other then it will help improve the performance, so you can make them local.

Whereas in case of Remote client, the client doesn't know whether the EJB is deployed on same machine or on some other machine, Container will go over the network and access the EJB using RMI/IIOP which will degrade performance in some cases.
Gaurav Chugh
Ranch Hand

Joined: Aug 28, 2001
Posts: 50
Thanks Ali for your reply. i understand now better.
Rajesh So
Ranch Hand

Joined: Oct 08, 2002
Posts: 135
Hi,

I have been using the application client container in Glassfish to communicate with the beans.

I tried to write a JNDI client to communicate with the beans, so that the client can be placed in any desktop in the network. When I try to fill the properties of the InitialContext, I had errors.

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial


The following mandatory properties are filled.


It would be good to find the jndi.properties of the Glassfish server and write the same in these properties. But there was no jndi.properties in Glassfish.

Or, could the application server documentation mention the properties (except the hostname of the server).

Your help would be very useful.

Thanks,
Rajesh
Rajesh So
Ranch Hand

Joined: Oct 08, 2002
Posts: 135
Hi again,

I managed to come out of NoInitialContextException, by specifying the Provider URL and the jndi name as part of the lookup.


I followed the server documentation
Sun Java System Application Server Documentation

However, I get different exception and the call has not reached the server.

javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDLmg.org/CosNaming/NamingContext/NotFound:1.0]


Please help!

Rajesh
Rajesh So
Ranch Hand

Joined: Oct 08, 2002
Posts: 135
Hi,

I have managed to move up, but yet to reach the bean. The problem was that the Context factory was wrong. I am using Glassfish 9.1 Update 2 and used the ldap factory com.sun.jndi.ldap.LdapCtxFactory and the Context.PROVIDER_URL,"ldap://localhost:389/o=myObjects" as mentioned Sun System Application Server 9.1 Admin guide

I get an exception
javax.naming.CommunicationException: localhost:389 [Root exception is java.net.ConnectException: Connection refused: co
nnect]

Do I have to run any LDAP server. If yes, how to. The JNDI name is visible in the log of the server and in the Admin Console. But having problems to reach the jndi naming service from the remote client.

Could you help me in this regard.

Regards,
Rajesh


Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
Ali Gohar's answer is not 100 % correct.

According to the spec, A Client to an EJB in same JVM is not must be a local client. Spec only says A local Client means a client in Same JVM + Same Application.

For a example glass fish treat a client in different application in same jvm as a remote client, while jboss treat as a local client.

Regards,
Cham
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Rajesh, why don't you start your own thread instead of hijacking this one ?


[My Blog]
All roads lead to JavaRanch
Rajesh So
Ranch Hand

Joined: Oct 08, 2002
Posts: 135
Hi,

I got it working and wish to publish it, so that anyone who has this problem can get it sorted easily.

This thread was useful
http://forums.java.net/jive/thread.jspa?messageID=225734𷇆

The problem was that the application server's client jar was file was not present in my remote client. Application servers have a client jar file, that is intended for use of client applications of the Appserver.

For Glassfish 9.1 update 2, it is appserv-rt.jar. If our client make use of the packages such as the context factory implementation, we have to embed the jar that has this implementation. As soon as i entered the jar, the context factory implementation (com.sun.enterprise.naming.SerialInitContextFactory) was found and the 'irritating' error of NameNotFoundException or NoInitialContextException were sorted.

Besides, it is possible to specify just the no-args construction of InitalContext and the jar is capable of using its preferred ContextFactory.

Good luck!

Christophe, i shall use separate threads for my questions. My intention was to reuse the thread that was related. I have posted this answer to avoid leaving my query open. Sorry!

Regards,
Rajesh
 
Don't get me started about those stupid light bulbs.
 
subject: Remote client Vs Local Client
 
Similar Threads
Mock question from Headfirst EJB
Implementing Remote and local interface at the same time ?
EJB Newbie
LocalHomes
HF EJB Session bean question