Duvida como chamar metodo via Local

Caros,

duvida referente a chamada metodo via Local pois não estou conseguindo chamar
e fiz conforme abaixo mas acho que está errado …

Alguém poderia me dar uma ajuda da forma correta …

abs

	public  void imprimeLocal() throws ClassNotFoundException, InstantiationException, IllegalAccessException, CreateException, NamingException, RemoteException {
		CalculadoraBean cal =   new CalculadoraBean();
		System.out.println(cal.soma(2000, 2000));
	}

--main   
public class TesteCalculadora {
	private InitialContext getContext() throws NamingException {
		Hashtable props = new Hashtable();
		props.put(InitialContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
		props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099");
		InitialContext initialContext = new InitialContext(props);
		return initialContext;
	}
	
	
	private CalculadoraLocalHome getHome1() throws NamingException, ClassNotFoundException, InstantiationException, IllegalAccessException {
		CalculadoraLocalHome result;
		Hashtable props = new Hashtable();
		props.put(InitialContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
		props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099");
		InitialContext initialContext = new InitialContext(props);
		result =  (CalculadoraLocalHome)initialContext.lookup("CalculadoraLocal");
		return result; 
    	
	}
	public  void imprimeRemoto() throws ClassNotFoundException, InstantiationException, IllegalAccessException, CreateException, NamingException, RemoteException {
		Calculadora cal =  getHome().create();
		System.out.println(cal.soma( 2008 , -1968));
		}
	public  void imprimeLocal() throws ClassNotFoundException, InstantiationException, IllegalAccessException, CreateException, NamingException, RemoteException {
		CalculadoraBean cal =   new CalculadoraBean();
		System.out.println(cal.soma(2000, 2000));
	}

	public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, RemoteException, CreateException, NamingException {
		TesteCalculadora teste = new TesteCalculadora();
		teste.imprimeLocal();
	}
}

--   
package aplicacao;   
  
import java.rmi.RemoteException;   
  
import javax.ejb.EJBObject;   
  
public interface Calculadora extends EJBObject {   
    public Integer soma(Integer v1, Integer v2) throws RemoteException;   
}   
--   
public class CalculadoraBean implements SessionBean {   
  
    public CalculadoraBean() {   
        // TODO Auto-generated constructor stub   
    }   
  
    @Override   
    public void ejbActivate() throws EJBException, RemoteException {   
        // TODO Auto-generated method stub   
  
    }   
  
    @Override   
    public void ejbPassivate() throws EJBException, RemoteException {   
        // TODO Auto-generated method stub   
  
    }   
  
    @Override   
    public void ejbRemove() throws EJBException, RemoteException {   
        // TODO Auto-generated method stub   
  
    }   
  
    @Override   
    public void setSessionContext(SessionContext arg0) throws EJBException,   
            RemoteException {   
        // TODO Auto-generated method stub   
  
    }   
       
    public void ejbCreate() throws CreateException{}   
       
    public Integer soma(Integer v1, Integer v2 ){   
        return v1+v2;   
    }   
  
}   
--   
import java.rmi.RemoteException;   
  
import javax.ejb.CreateException;   
import javax.ejb.EJBHome;   
  
  
public interface CalculadoraHome extends EJBHome {   
    public Calculadora create() throws CreateException, RemoteException;   
}   
  
--   
  
public interface CalculadoraLocal extends EJBLocalObject {   
    public Integer soma(Integer v1, Integer v2) ;   
}   
--   
  
  
public interface CalculadoraLocalHome extends EJBLocalHome {   
    public CalculadoraLocal create() throws CreateException ;   
}   
--ejb-jar.xml   
<ejb-jar >   
    <description><![CDATA[Sem Descricao.]]></description>   
    <display-name>Gerado pelo XDoclet</display-name>   
       
    <enterprise-beans>   
        <!-- Session Beans -->   
        <session >   
        <description><![CDATA[]]></description>   
        <ejb-name>Calculadora</ejb-name>   
        <home>aplicacao.CalculadoraHome</home>   
        <remote>aplicacao.Calculadora</remote>   
        <local-home>aplicacao.CalculadoraLocalHome</local-home>   
        <local>aplicacao.CalculadoraLocal</local>   
        <ejb-class>aplicacao.CalculadoraBean</ejb-class>   
        <session-type>Stateless</session-type>   
        <transaction-type>Container</transaction-type>   
        </session>   
    </enterprise-beans>   
    <assembly-descriptor >    </assembly-descriptor>   
</ejb-jar>   
--jboss.jar   
<jboss>   
    <unauthenticated-principal>nobody</unauthenticated-principal>   
    <enterprise-beans>   
        <session>   
            <ejb-name>Calculadora</ejb-name>   
            <jndi-name>Calculadora</jndi-name>   
            <local-jndi-name>CalculadoraLocal</local-jndi-name>   
        </session>   
    </enterprise-beans>   
    <resource-managers>   </resource-managers>   
</jboss>  
--main
public class TesteCalculadora {
	private InitialContext getContext() throws NamingException {
		Hashtable props = new Hashtable();
		props.put(InitialContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
		props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099");
		InitialContext initialContext = new InitialContext(props);
		return initialContext;
	}
	
	private CalculadoraLocalHome getHome1() throws NamingException, ClassNotFoundException, InstantiationException, IllegalAccessException {
		CalculadoraLocalHome result;
		result = (CalculadoraLocalHome) getContext().lookup("CalculadoraLocal");
		return result; 
    	
	}
	public void imprime() throws ClassNotFoundException, InstantiationException, IllegalAccessException, CreateException, NamingException, RemoteException {
		Calculadora cal =  (Calculadora) getHome1().create();
		System.out.println(cal.soma( 2008 , -1968));
		}
	public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, RemoteException, CreateException, NamingException {
		TesteCalculadora teste = new TesteCalculadora();
		teste.imprime();
	}
}
--
package aplicacao;

import java.rmi.RemoteException;

import javax.ejb.EJBObject;

public interface Calculadora extends EJBObject {
	public Integer soma(Integer v1, Integer v2) throws RemoteException;
}
--
public class CalculadoraBean implements SessionBean {

	public CalculadoraBean() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void ejbActivate() throws EJBException, RemoteException {
		// TODO Auto-generated method stub

	}

	@Override
	public void ejbPassivate() throws EJBException, RemoteException {
		// TODO Auto-generated method stub

	}

	@Override
	public void ejbRemove() throws EJBException, RemoteException {
		// TODO Auto-generated method stub

	}

	@Override
	public void setSessionContext(SessionContext arg0) throws EJBException,
			RemoteException {
		// TODO Auto-generated method stub

	}
	
	public void ejbCreate() throws CreateException{}
	
	public Integer soma(Integer v1, Integer v2 ){
		return v1+v2;
	}

}
--
import java.rmi.RemoteException;

import javax.ejb.CreateException;
import javax.ejb.EJBHome;


public interface CalculadoraHome extends EJBHome {
	public Calculadora create() throws CreateException, RemoteException;
}

--

public interface CalculadoraLocal extends EJBLocalObject {
	public Integer soma(Integer v1, Integer v2) ;
}
--


public interface CalculadoraLocalHome extends EJBLocalHome {
	public CalculadoraLocal create() throws CreateException ;
}
--ejb-jar.xml
<ejb-jar >
	<description><![CDATA[Sem Descricao.]]></description>
	<display-name>Gerado pelo XDoclet</display-name>
	
	<enterprise-beans>
		<!-- Session Beans -->
		<session >
		<description><![CDATA[]]></description>
		<ejb-name>Calculadora</ejb-name>
		<home>aplicacao.CalculadoraHome</home>
		<remote>aplicacao.Calculadora</remote>
		<local-home>aplicacao.CalculadoraLocalHome</local-home>
		<local>aplicacao.CalculadoraLocal</local>
		<ejb-class>aplicacao.CalculadoraBean</ejb-class>
		<session-type>Stateless</session-type>
		<transaction-type>Container</transaction-type>
		</session>
	</enterprise-beans>
	<assembly-descriptor >	</assembly-descriptor>
</ejb-jar>
--jboss.jar
<jboss>
	<unauthenticated-principal>nobody</unauthenticated-principal>
	<enterprise-beans>
		<session>
			<ejb-name>Calculadora</ejb-name>
			<jndi-name>Calculadora</jndi-name>
			<local-jndi-name>CalculadoraLocal</local-jndi-name>
		</session>
	</enterprise-beans>
	<resource-managers>	</resource-managers>
</jboss>

 

Caros,

venho varios exemplo referente EJB usando session
na hora de chamar o metodo via Local não venho nenhum
se alguem puder me ajudar queria um exemplo ou ajuda
para chamar metodo Local sem ser remoto.

agradeço…


Interfaces Locais
package examples;
/**Interface que os clientes operam quando interagem com
o objetos EJB Locais */
public interface ContadorLocal extends
javax.ejb.EJBLocalObject{
public int contador();
}


--
package examples;
/**Interface que os clientes operam quando interagem com o
objetos HOME Local criado pelas ferramentas do contêiner */
public interface ContadorLocalHome extends
javax.ejb.EJBLocalHome{
ContadorLocal create(int val) throws
javax.ejb.CreateException;
}

--

package examples;
import javax.ejb.SessionContext;
public class ContadortBean implements javax.ejb.SessionBean {
private SessionContext sessionContext;
public int val;
public int count() {
System.out.println("count() chamado");
return ++val;
}
public void ejbCreate(int val) throws CreateException {
this.val = val;
System.out.println("ejbCreate(val) chamado");
}
public void ejbRemove() {
System.out.println("ejbRemove() chamado");
}
public void ejbActivate() {
System.out.println("ejbActivate() chamado");
}
public void ejbPassivate() {
System.out.println("ejbPassivate() chamado");
}
public void setSessionContext(SessionContext ctx) {
this.sessionContext = ctx;
}
}
--ejb-jar.xml
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Contador</ejb-name>
<home>examples.ContadorHome</home>
<remote>examples.Contador</remote>
<local-home>examples.ContadorLocalHome</local-home>
<local>examples.ContadorLocal</local>
<ejb-class>examples.ContadorBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

--main
public class ContadorClient {
public static void main(String[] args) throws Exception {
Hashtable prop = new Hashtable();
prop.put(InitialContext.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
prop.put(InitialContext.PROVIDER_URL,"jnp://localhost:1099");
Context ctx = new InitialContext(prop);
Object obj = ctx.lookup("Contador");
ContadorHome home = (ContadorHome)
javax.rmi.PortableRemoteObject.narrow(
obj, ContadorHome.class);
Contador cont = home.create(0);
System.out.println(cont.contador());
Thread.sleep(1000);
System.out.println(cont.contador());
cont.remove();
}
}
---
<jboss>
	<unauthenticated-principal>nobody</unauthenticated-principal>
	<enterprise-beans>
		<session>
			<ejb-name>Contador</ejb-name>
			<jndi-name>Contador</jndi-name>
		</session>
	</enterprise-beans>
	<resource-managers>	</resource-managers>
</jboss>