Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

ved gunjan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic