5 Replies Latest reply on Jul 17, 2003 5:42 AM by bigheadace

    java.lang.ClassCastException

    bigheadace

      during deplying EJB;
      Always get: java.lang.ClassCastException. from
      Context ctx = new InitialContext();
      Object obj = ctx.lookup("ejb/husky/EntityPC");
      LogRecorder.errorRecord("OBJ is "+obj.toString()); //can got ejb/husky/EntityPCHome.

      ==> EntityPCHome eh = (EntityPCHome)PortableRemoteObject.narrow(obj,EntityPCHome.class);
      Here asn above exception is thrown.

      Followo is relative XML files:

      ejb-jar.xml
      ....

      <display-name>EntityPC</display-name>
      <ejb-name>EntityPC</ejb-name>
      fi.mediweb.husky.ejb.persistency.EntityPCRemoteHome
      fi.mediweb.husky.ejb.persistency.EntityPCRemote
      <local-home>fi.mediweb.husky.ejb.persistency.EntityPCHome</local-home>
      fi.mediweb.husky.ejb.persistency.EntityPC
      <ejb-class>fi.mediweb.husky.ejb.persistency.EntityPCBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Long</prim-key-class>
      ....

      in web.xml:
      ...

      <ejb-ref>
      <ejb-ref-name>EntityPC</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      fi.mediweb.husky.ejb.persistency.EntityPCHome
      fi.mediweb.husky.ejb.persistency.EntityPC
      <ejb-link>persistency.jar#EntityPC</ejb-link>
      </ejb-ref>

      .....

      in jboss-web.xml:

      <jboss-web>
      <ejb-ref>
      <ejb-ref-name>EntityPC</ejb-ref-name>
      <jndi-name>ejb/husky/EntityPC</jndi-name>
      </ejb-ref>


      </jboss-web>


      Anybody can help me finger out what's hell goning on.

      Thanks fir ur information.

        • 1. Re: java.lang.ClassCastException
          raja05

          Are you deploying the war and jar files separately? There is a chance that the war file is still holding reference to the older Stub for the EJB and when you deploy the new jar, a classcastexception arises.
          Post ur directory structure and how you deploy the files!!

          -Raj

          • 2. Re: java.lang.ClassCastException
            bigheadace

            EJB jar packaged using ant;

            classpath:
            -ejb
            |__husky
            |__ persistency
            |_ classes....


            servlet classes are packed by jar cf ;

            kkk.war:
            -web.xml
            -jboss-web.xml
            -struts-config.xml
            -WEB-INF
            |_ classes
            |_husky
            |_struts
            |_ classes...
            -other html or js files.


            Is there anything not right there?

            Thank you for your help.

            It took me almost one week, damnit.

            • 3. Re: java.lang.ClassCastException
              bigheadace

              there is misleading on display:

              path is:

              -ejb/husky/persistency/ EJB classes....


              war:

              -web.xml
              -jboss-web.xml
              -struts-config.xml
              -WEB-INF/classes/husky/struts/ servlet classes...
              -other html or js files.

              • 4. Re: java.lang.ClassCastException
                raja05

                if u are deploying teh jar and war separately, you might get this class cast exception. Try redeploying them both or package them into an ear and deploy as a singleunit.

                if u deploy them separately, the war might be holding refrerences to the stub of the jar from an earlier deploy.

                • 5. Re: java.lang.ClassCastException
                  bigheadace

                  Thank raja05.

                  I have resolved this problem.

                  this is caused by misusing interface during coding EJB.