0 Replies Latest reply on Apr 27, 2006 12:40 AM by vedgunjan singh

    JNDI lookup  for EJB3.0 and JBOSS 4.0.3SP1

    vedgunjan singh Newbie

      Hi All,
      I'm new to EJB3.0 and JBoss4.0.3 SP1, so kind of struggling with all the initial startup 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(using JSF...) and is the client in this case.

      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 cName=context.lookup("UserServiceImpl/remote").getClass).getName();

      userSvc = (UserService)context.lookup("UserServiceImpl/remote")//default jndi naming (bean-name/remote )
      System.out.println("-->> lookup object successfully");

      .............
      .............


      }
      --------------------------------------------------------------------------------------

      Im getting this exception when im doing the lookup.

      java.lang.ClassCastException: $Proxy81
      at com.demo.delegate.AuthenticationDelegate.(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 configuration xml files as I suppose we don't need those with EJB3.0.
      Any help would be greatly appreciated

      Thanks
      Ved