In the previous blog, we described how to create the first EJB project using Eclipse+jboss, and encountered an error during this period:
Exception in thread "main" java.lang.ClassCastException:com.sun.proxy. $Proxy 2 cannot is cast to Com.tgb.ejb.HelloWorldBean at Com.tgb.ejb.client.Client.main (client.java:12)
There are two reasons for this:
1. Your hellowroldbean does not show the Hellowrold interface
@Stateless @remote ({helloworld.class}) public class Helloworldbean implements HelloWorld {}
2. Convert the proxy object obtained from the EJB container to the interface
HelloWorld EJB = (HelloWorld) initialcontext.lookup ("Helloworldbean/remote");
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
EJB Learning (iii)--java.lang.classcastexception:com.sun.proxy. $Proxy 2 cannot is cast to.