File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes EJB3.0 giving java.lang.ClassCastException: $Proxy81 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "EJB3.0 giving java.lang.ClassCastException: $Proxy81" Watch "EJB3.0 giving java.lang.ClassCastException: $Proxy81" New topic
Author

EJB3.0 giving java.lang.ClassCastException: $Proxy81

ved gunjan
Ranch Hand

Joined: May 17, 2003
Posts: 86
Hi All,
I�m new to EJB3.0 and JBoss so struggling with all the strartup problems.
I have a session bean, which I�m testing but I�m not able to get the remote reference through JNDI lookup.

Heres�s my components


@Remote
public interface UserService extends Serializable {
public User findUser(String userName);
public boolean addUser(String userName, String firstName, String lastName);
}

Session Bean
@Stateless
@Remote(UserService.class)
public class UserServiceImpl implements UserService {
���
��..
}


This is the class which gets called from the JSP.
Both EJB and web are running in the same instance of of JBoss

public class AuthenticationDelegate {

public static AuthenticationDelegate authenticationDelegate = null;
private static @EJB UserService userSvc;

����������
����������

Context context = new InitialContext();
String className = context.lookup("UserServiceImpl/remote").getClass().getName();
userSvc = (UserService)context.lookup("UserServiceImpl/remote"); //ejb-name
System.out.println("-->> lookup object successfully");

����
�������..


}

Im getting this exception
java.lang.ClassCastException: $Proxy81
at com.demo.delegate.AuthenticationDelegate.<init>(AuthenticationDelegate.java:55)
at com.demo.delegate.AuthenticationDelegate.getAuthenticationDelegate(AuthenticationDelegate.java:86)
at com.demo.UserBean.executeCommand(UserBean.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
at javax.faces.component.UICommand.broadcast(UICommand.java:312)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
.
I don�t have any jboss.xml or any other xml files as I suppose that we don�t those with EJB3.0.
Any help would be greatly appreciated

Thanks
Ved
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB3.0 giving java.lang.ClassCastException: $Proxy81