1 Reply Latest reply on Aug 27, 2007 11:35 AM by Mustafa Cayci

    java.lang.ClassCastException: org.jnp.interfaces.NamingConte

    Mustafa Cayci Newbie


      I am sorry if this has been posted before. I did a search and nothing came back.

      I developed a very simple EJB3.0 Stateless Session Bean. I created a client that calls this session bean as follows:

      public static void main(String [] args) {
       try {
       final Context context = getInitialContext();
       ReadCrimeReport readCrimeReport = (ReadCrimeReport)context.lookup("ReadCrimeReport");
       } catch (Exception ex) {
       private static Context getInitialContext() throws NamingException {
       Hashtable env = new Hashtable();
       env.put( Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );
       env.put(Context.PROVIDER_URL, "localhost");
       env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );
       return new InitialContext( env );

      I deployed the EJB and see the following

      09:13:04,288 WARN [Ejb3DescriptorHandler] Descriptor based bean has no ejb-clas
      s defined: ReadCrimeReportBean
      09:13:04,328 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jbo
      09:13:04,338 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=ejb1.
      jar,name=ReadCrimeReport,service=EJB3 with dependencies:
      09:13:04,568 INFO [EJBContainer] STARTED EJB: server.ReadCrimeReportBean ejbNam
      e: ReadCrimeReport
      09:13:04,678 INFO [EJB3Deployer] Deployed: file:/D:/jboss-4.2.1.GA/server/defau

      Now when I run the client, I am getting

      java.lang.ClassCastException: org.jnp.interfaces.NamingContext
      at client.ReadCrimeReportClient.main(ReadCrimeReportClient.java:15)

      It is complaining on

      ReadCrimeReport readCrimeReport = (ReadCrimeReport)context.lookup("ReadCrimeReport");

      Thanks for your help.