[jboss-user] [EJB 3.0] - Re: InitialContext reference and definition

pepelara do-not-reply at jboss.com
Tue Jan 27 10:54:02 EST 2009


Hi,

It is working ok when I call the remote interface.
I do it as you say. It works fine.

But about the local interface, then console of Eclipse
gives me the following exception,


  | Caught an unexpected exception!
  | javax.ejb.EJBException: Invalid (i.e. remote) invocation of local interface (null container)
  | 	at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:80)
  | 	at $Proxy0.add(Unknown Source)
  | 	at jboss.tutorial.CalculatorClient.doOperations(CalculatorClient.java:29)
  | 	at jboss.tutorial.CalculatorClient.main(CalculatorClient.java:45)
  | 

This is my new client,


  | public class CalculatorClient {
  | 	
  | 	@EJB
  | 	private static Calculator calculator;
  | 	
  | 	public CalculatorClient() {
  | 		try {
  | 			Properties props = new Properties();
  | 			props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
  | 			props.put("java.naming.factory.url.pkgs", "jnp://localhost:1099");
  | 			props.put("java.naming.provider.url", "jnp://localhost:1099");
  |             Context ctx = new InitialContext(props);
  |             calculator = (Calculator) ctx.lookup("CalculatorEAR/CalculatorBean/local");
  |         } catch (Exception ex) {
  |             System.out.println("Couldn’t create calculator bean. "+
  |                     ex.getMessage());
  |         }
  |     }
  | 	
  | 	public void doOperations() {
  |         try {
  |         	System.out.println("1 + 1 = " + calculator.add(1, 1));
  |     		System.out.println("1 - 1 = " + calculator.subtract(1, 1));
  |      
  |             System.exit(0);
  |         } catch (Exception ex) {
  |             System.err.println("Caught an unexpected exception!");
  |             ex.printStackTrace();
  |         }
  |     }
  | 
  | 	/**
  | 	 * @param args
  | 	 */
  | 	public static void main(String[] args) {
  | 		// TODO Auto-generated method stub
  | 		CalculatorClient cClient = new CalculatorClient();
  | 		cClient.doOperations();
  | 	}
  | }
  | 

The exception occurs when I call the doOperations() method.

Thanks,
pepelara

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4205014#4205014

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4205014




More information about the jboss-user mailing list