0 Replies Latest reply on Dec 8, 2005 4:30 PM by Eric Green

    InitialContext.lookup() exception for Stateless session bean

    Eric Green Newbie

      Hi,

      I have JBoss 4.0.3SP1 installed on my local Windows XP Professional machine. I downloaded and deployed the EJB3Trail application and all the examples ran just fine. I then created a simple stateless session bean to try it out for myself:

      // local interface
      public interface Eric {
      
       public String[] listFriends();
      }
      


      // stateless session bean
      @Stateless
      public class EricBean implements Eric {
      
       private String[] friends =
       { "Joe Sessions", "Larry Polnicky", "Laura Mayers",
       "Gary Carbone", "Venkat Koya", "Jay Elrod" };
      
       public String[] listFriends() {
       return friends;
       }
      }
      


      The bean is being deployed correctly as far as I am able to see from the following JBoss server output:

      14:55:55,631 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=test.EricBean, class=test.EricBean, type=STATELESS
      14:55:55,712 INFO [JaccHelper] test.EricBean has no @SecurityDomain - skipping JACC configuration
      14:55:55,722 INFO [JaccHelper] JACC Policy Configuration for deployment has been put in service
      14:55:55,722 INFO [Ejb3Deployment] EJB3 deployment time took: 451


      However, when I execute the ctx.lookup() call in the following local client code:

      // local client code
      InitialContext ctx = new InitialContext();
      Eric eric = (Eric)ctx.lookup( Eric.class.getName() );


      I get the following exception:

      14:58:51,034 INFO [STDOUT] java.lang.ClassCastException: org.jboss.ejb3.stateless.StatelessContainer
      14:58:51,044 INFO [STDOUT] at org.jboss.ejb3.LocalProxy.readObject(LocalProxy.java:50)
      14:58:51,044 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      14:58:51,044 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      14:58:51,044 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      14:58:51,044 INFO [STDOUT] at java.lang.reflect.Method.invoke(Unknown Source)
      14:58:51,044 INFO [STDOUT] at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
      14:58:51,064 INFO [STDOUT] at java.io.ObjectInputStream.readSerialData(Unknown Source)
      14:58:51,064 INFO [STDOUT] at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      14:58:51,064 INFO [STDOUT] at java.io.ObjectInputStream.readObject0(Unknown Source)
      14:58:51,064 INFO [STDOUT] at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
      14:58:51,064 INFO [STDOUT] at java.io.ObjectInputStream.readSerialData(Unknown Source)
      14:58:51,064 INFO [STDOUT] at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      14:58:51,074 INFO [STDOUT] at java.io.ObjectInputStream.readObject0(Unknown Source)
      14:58:51,074 INFO [STDOUT] at java.io.ObjectInputStream.readObject(Unknown Source)
      14:58:51,074 INFO [STDOUT] at java.rmi.MarshalledObject.get(Unknown Source)
      14:58:51,074 INFO [STDOUT] at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:57)
      14:58:51,074 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:637)
      14:58:51,074 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      14:58:51,084 INFO [STDOUT] at javax.naming.InitialContext.lookup(Unknown Source)
      14:58:51,084 INFO [STDOUT] at com.hrst.struts.action.TestAction.execute(TestAction.java:40)
      14:58:51,084 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
      14:58:51,084 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
      14:58:51,084 INFO [STDOUT] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
      14:58:51,084 INFO [STDOUT] at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
      14:58:51,094 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
      14:58:51,094 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      14:58:51,094 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      14:58:51,094 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      14:58:51,094 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
      14:58:51,104 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      14:58:51,104 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      14:58:51,104 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      14:58:51,104 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      14:58:51,104 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      14:58:51,114 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
      14:58:51,114 INFO [STDOUT] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:407)
      14:58:51,114 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      14:58:51,114 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      14:58:51,114 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      14:58:51,114 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      14:58:51,124 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      14:58:51,124 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      14:58:51,124 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      14:58:51,124 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      14:58:51,134 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      14:58:51,134 INFO [STDOUT] at java.lang.Thread.run(Unknown Source)


      Hopefully this will be an easy thing to answer for some of you guys who've used this a bit. Thanks in advance for any help you are able to give!

      Eric