This content has been marked as final.
Show 3 replies
-
1. Re: Class cast exception in Ejb Look up
jinoaugustine Nov 4, 2009 10:20 AM (in response to jinoaugustine)while calling look up from standard alone application, it will work fine
InitialContext ctx = null; Hashtable<String, String> props = new Hashtable<String, String>(); props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); props.put("java.naming.provider.url", "jnp://localhost:1099"); try { ctx = new InitialContext(props); CalculatorRemote calc = (CalculatorRemote) ctx.lookup("CalculatorBean/remote"); System.out.println( "addition == " + calc .add( 10, 20 )); } catch (NamingException e) { e.printStackTrace(); }
but its not working from servlet
getting java.lang.ClassCastException: $Proxy78 cannot be cast to stateless.CalculatorRemote
at web.CalcServlet.init(CalculationServlet.java:36)public void jspInit() { try { InitialContext ic = new InitialContext(); Object object = ic.lookup( "example/CalculatorBean/remote" ); CalculatorRemote calc = (CalculatorRemote)PortableRemoteObject.narrow( object , CalculatorBean.class); System.out.println("Loaded Calculator Bean"); } catch (Exception ex) { e.printStackTrace (); } }
and i print the method and class name here
Class Name === $Proxy78
Method === hashCode
Method === equals
Method === toString
Method === add
Method === subtract
Method === multiply
Method === division
Method === getAsynchronousProxy
Method === isProxyClass
Method === getProxyClass
Method === newProxyInstance
Method === getInvocationHandler
Method === getClass
Method === wait
Method === wait
Method === wait
Method === notify
Method === notifyAll
here i am getting the object of java.lang.reflect.Proxy
why i am getting this object instead of CalculatorRemote ?
any thing i want to set in jboss-4.2.2.GA sever ?
thx for your replay -
2. Re: Class cast exception in Ejb Look up
jaikiran Nov 4, 2009 1:12 PM (in response to jinoaugustine)Is this an EAR? If yes, then are you packaging the ejb interfaces both in the .war and the ejb .jar? If yes, then remove those interfaces from the .war.
http://www.jboss.org/community/wiki/ClassCastExceptions -
3. Re: Class cast exception in Ejb Look up
jinoaugustine Nov 5, 2009 8:02 AM (in response to jinoaugustine)thanks for your kind replay
No, here i have used in both way ear and separate jar and war
still getting same class cast exception