3 Replies Latest reply on Jan 16, 2007 4:03 AM by antoine_h

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

    sony3002

      hello all

      i am getting tis error when i connect to remote Jboss 4.0.4RC1
      from my stand alone tomcat
      java.lang.ClassCastException: org.jnp.interfaces.NamingContext

      i am using Jboss 4.0.4RC1 with EJB3
      Java 1.5 update 6
      Netbeans 5.5 preview
      tomcat 5.5.9

      i listed all the bind variable in port 1099 and found that my bean is there
      and in JMX-console my bean is loaded

      Bind Objects :XAConnectionFactory: org.jboss.mq.SpyXAConnectionFactory
      Bind Objects :TopicConnectionFactory: org.jboss.naming.LinkRefPair
      Bind Objects :UIL2ConnectionFactory: javax.naming.LinkRef
      Bind Objects :UserTransactionSessionFactory:$Proxy27
      Bind Objects :UIL2XAConnectionFactory: javax.naming.LinkRef
      Bind Objects :QueueConnectionFactory: org.jboss.naming.LinkRefPair
      Bind Objects :topic: org.jnp.interfaces.NamingContext
      Bind Objects :UserLoginBean: org.jnp.interfaces.NamingContext
      Bind Objects :queue: org.jnp.interfaces.NamingContext
      Bind Objects :ConnectionFactory: org.jboss.mq.SpyConnectionFactory
      Bind Objects :UserTransaction: org.jboss.tm.usertx.client.ClientUserTransaction
      Bind Objects :jmx: org.jnp.interfaces.NamingContext
      Bind Objects :UILXAConnectionFactory: javax.naming.LinkRef
      Bind Objects :UILConnectionFactory: javax.naming.LinkRef


      what is the problem with me ??? my code ???
      here is my remote beans
      package test.ejb.user;
      
      import java.util.Vector;
      import javax.ejb.*;
      
      /**
       * This is the bean class for the UserLoginBean enterprise bean.
       * Created Mar 26, 2006 8:56:08 PM
       * @author Administrator
       */
      @Stateless()
      public class UserLoginBean implements com.amlaki.cbmega.ejb.user.UserLoginRemote
      {
       public boolean doLogin(String userId,String memberId,String password)throws Exception
       {
       System.out.println("User Id Received from Remot Server is :"+userId);
       System.out.println("Member Id Received from Remot Server is :"+memberId);
       System.out.println("Password Received from Remot Server is :"+password);
       System.out.println("Returning true to the called programme.....");
       return true;
       }
      
       public Vector getUserRights(String userId)throws Exception
       {
       System.out.println("Called getUserRights() method of Jboss");
       return new Vector();
       }
      
      }


      package test.ejb.user;
      
      import java.util.Vector;
      import javax.ejb.Remote;
      
      
      /**
       * This is the business interface for UserLogin enterprise bean.
       */
      @Remote()// this line was added by me
      
      public interface UserLoginRemote
      {
       public boolean doLogin(String userId,String memberId,String password)throws Exception;
      
       public Vector getUserRights(String userId)throws Exception;
      }
      

      when this line execute i get .............
       UserLoginRemote obj = (UserLoginRemote)Remote.getRemoteObject("UserLoginBean");
      
      


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

      please help

      Sony George


        • 1. Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC
          antoine_h

          Hello,

          I have the same kind of problem.
          Did you find a solution ?

          Thank you

          • 2. Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC
            sony3002

            yes solved

            when u call a bean in jboss u have to call by adding remote or local to it
            example

            UserLoginRemote obj = (UserLoginRemote)Remote.getRemoteObject("UserLoginBean/remote");


            or

            UserLoginRemote obj = (UserLoginRemote)Remote.getRemoteObject("UserLoginBean/local");


            and also in u r client application
            u have to add the following jar files from the <jboss_home>\client\ dir
            to u r classpath

            <jboss_home>\client\jboss-aop-jdk50-client.jar
            <jboss_home>\client\jboss-aspect-jdk50-client.jar
            <jboss_home>\client\jboss-ejb3-client.jar
            <jboss_home>\client\jbossall-client.jar
            

            this solved my problem

            thanks and regards

            Sony


            • 3. Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC
              antoine_h

              I have solved it by putting every thing in the same ear, which is ok for now.
              Then, it works fine, no error on class cast.
              I 'll look at the library you recommend to add to the client. It seems to be a good way to go further.

              Thank you.
              Best regards,