Bean
package Bean;
import interfaces.EjbBusinessInterface;
import javax.ejb.Stateless;
import javax.ejb.Remote;
@Stateless(mappedName="TestSessionBean")
public class CalculatorBean implements EjbBusinessInterface{
public void add(int x,int y){
System.out.println(x+y) ;
}
}
Business Interafce
package interfaces;
import javax.ejb.Remote;
@Remote
public interface EjbBusinessInterface {
public void add(int x,int y);
}
Client
package Client;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import Bean.CalculatorBean;
public class TestSessionClient {
private static CalculatorBean helloWorld;
public static void main(
String[] args)
{
try
{
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL,"t3://192.168.9.168:7001");
Context ctx = new InitialContext(env);
System.out.println("Initial Context created");
helloWorld = (CalculatorBean) ctx.lookup("TestSessionBean");
System.out.println("lookup successful");
System.out.println("Calling EJB method . . .");
helloWorld.add(2,4);
System.out.println("Output will be in Managed server console");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
as i am writing ejb3.0 we do not need the deployment descriptors(ejb-jar.xml,weblogic-ejb-jar.xmal etc.).
in the above files how should i give the jndi name and what is the format of default jndi name for weblogic 10.3?