Reputation: 265
As per my references the @Local session beans are accessible under same JVM which where the bean is deployed(client & server running on same JVM).
I have implemented a simple statless local session bean and deployed in my GlassFish Server(also have tried in JBoss server).
And my standalone client which lookups the session bean, but this local session can not be accessible. I did tried same with @Remote which can be accessible.
As of this both server and client runs in same/single JVM(On My machine).
Is it possible to access the local Session bean from the standalone client app? Is there any specific way of accessing ?
My Codes are:
Statless Local Session bean
@Stateless
public class TicketBookingImpl implements TicketBookingLocal {
public String doBooking(String name) {
return "Ticket Booked for " + name;
}
}
lookup code
public static void main(String[] args) {
try {
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");
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
final Context context = new InitialContext(props);
System.out.println("Doing lookup");
TicketBooking ticketBooking = (TicketBooking) context.lookup("java:global/ejb-work-1/TicketBookingImpl");
Upvotes: 2
Views: 830
Reputation: 4369
Unfortunately you can use local interfaces only in the same deployment unit (usually ear).
You have to use remote interface in two cases:
Check this link for a more detailed recommendation about local/remote interface usage: Local vs. Remote Interfaces in EJB (EJB3)
Upvotes: 1