Dear Grauzone, to access an EJB from remote you have the points below 1. Make
sure your EJB is set as @Remote EJB, so the ejb can be accessed from
different JVM. You can use @Local when client and EJB is in the same JVM for
example @Remote public interface CustomerBeanRemote { //your code here } 2.
Implements the interface into the EJB class, in this case i'am use Singleton
EJB you can also use the same thing for stateless and statefull.
@Singleton(name="CustomerBeanRemote", mappedName="CustomerBeanRemote),
description="CustomerBeanRemote") public class CustomerBean implements
CustomerBeanRemote { //your code here } 3. To accessing your EJB then create
some synchronize method and add this properties to be used for each time you
create initialcontext object Properties props = new Properties();
props.setProperty("java.naming.factory.initial",
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs",
"com.sun.enterprise.naming"); props.setProperty("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl"); // optional.
Defaults to localhost. Only needed if web server is running // on a different
host than the appserver props.setProperty("org.omg.CORBA.ORBInitialHost",
"localhost"); // optional. Defaults to 3700. Only needed if target orb port
is not 3700. props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext ic = new InitialContext(props); CustomerBeanRemote cbr =
(CustomerBeanRemote)ic.lookup("CustomerBean"); cbr.someMethod(); 4. Glassfish
has been provide some client container called ACC --> Application client
provider When you create an EJB client application. then the configuration in
point 3 is no need to create manually. Glassfish will create it for you. Hope
this answer will help you to solve the problem. Just give me some feedback if
you have some problem. Thanks Ferry
--
[Message sent by forum member 'f3riyanto']
View Post: http://forums.java.net/node/900930