File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "EJB3.0 giving java.lang.ClassCastException: $Proxy81" Watch "EJB3.0 giving java.lang.ClassCastException: $Proxy81" New topic

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

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

Session Bean
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>(
at com.demo.delegate.AuthenticationDelegate.getAuthenticationDelegate(
at com.demo.UserBean.executeCommand(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.sun.faces.el.MethodBindingImpl.invoke(
at com.sun.faces.application.ActionListenerImpl.processAction(
at javax.faces.component.UICommand.broadcast(
at javax.faces.component.UIViewRoot.broadcastEvents(
at javax.faces.component.UIViewRoot.processApplication(
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(
at com.sun.faces.lifecycle.LifecycleImpl.phase(
at com.sun.faces.lifecycle.LifecycleImpl.execute(
at javax.faces.webapp.FacesServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(
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

I agree. Here's the link:
subject: EJB3.0 giving java.lang.ClassCastException: $Proxy81
It's not a secret anymore!