[jboss-user] [EJB 3.0 Users] - Re: class java.lang.ClassCastException in EJB3.0 lookup

sarpesh do-not-reply at jboss.com
Thu Sep 3 05:12:41 EDT 2009


Hi friend's

i am calling my ejb class using this code 
public class Client
{
	
   public static void main(String[] args) throws Exception
   {
	   CalculatorRemote calculator =null;
	   Properties properties = new Properties();
	   properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
	   properties.put("java.naming.provider.url", "jnp://localhost:1099");
	   properties.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
	   properties.put("jnp.socket.Factory", "org.jnp.interfaces.TimedSocketFactory");
      Context ctx = new InitialContext(properties);
      CalculatorRemote obj = (CalculatorRemote)ctx.lookup("CalculatorBean/remote");
      System.out.println("1 + 1 = " + calculator.add(1, 1));
      System.out.println("1 - 1 = " + calculator.subtract(1, 1));
   }
}


but always get this exception 
Exception in thread "main" java.lang.ClassCastException: javax.naming.Reference cannot be cast to org.jboss.tutorial.stateless.bean.CalculatorRemote
	at org.jboss.tutorial.stateless.client.Client.main(Client.java:26)

i am using  jboss-5.1.0.GA and jdk1.6
please help me

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

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



More information about the jboss-user mailing list