11 Replies Latest reply on Oct 24, 2002 6:53 PM by jcowgar

    ClassCastException while outside IDE, works fine in IDE.

    jcowgar

      I use Eclipse, have developed about 15 CMP Beans and Session beans to go along, now I am trying to use my client application that accesses these beans outside of the IDE, however whenever I keep getting ClassCastException and cannot figure out why.

      The code that it's occuring in is code in the XDoclet Utility class, here it is (however, this is just a sample, it happens on all beans in the same place, this is just one):

      cachedRemoteHome = (ejbs.interfaces.ClaimEntityHome) PortableRemoteObject.narrow(objRef, ejbs.interfaces.ClaimEntityHome.class);

      The weird thing is that it is working fantastic inside my IDE. Outside the IDE is the only time I am getting this message error.

      Thank you,

      Jeremy Cowgar
      jc@cowgar.com

        • 1. Re: ClassCastException while outside IDE, works fine in IDE.
          prabhakar

          Can you post the stack trace?

          -prabhakar

          • 2. Re: ClassCastException while outside IDE, works fine in IDE.
            jcowgar

            java.lang.ClassCastException
            at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java
            :293)
            at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
            at com.eldoserv.ejbs.interfaces.PatientSessionUtil.getHome(PatientSessionUtil.java:34)
            at com.eldoserv.knopro.eclipse.views.PatientSearchResultsView.search(PatientSearchResultsVie
            w.java:506)
            at com.eldoserv.knopro.eclipse.views.PatientSearchView$1.widgetSelected(PatientSearchView.ja
            va:116)
            at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:87)
            at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77)
            at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833)
            at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1622)
            at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1368)
            at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1420)
            at org.eclipse.ui.internal.Workbench.run(Workbench.java:1403)
            at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:775)
            at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462)
            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:324)
            at org.eclipse.core.launcher.Main.basicRun(Main.java:247)
            at org.eclipse.core.launcher.Main.run(Main.java:703)
            at org.eclipse.core.launcher.Main.main(Main.java:539)



            Sorry. Thanks for looking at the problem.

            Jeremy Cowgar
            jc@cowgar.com

            • 3. Re: ClassCastException while outside IDE, works fine in IDE.
              jcowgar

              That was kinda silly. I have quite a few beans and when I read my original message, I saw that I was quering the ClaimEntity bean, not the Provider or Patient bean that I gave the stack trace for.

              Here is the stack trace that the code in the first message creates.

              java.lang.ClassCastException
              at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java
              :293)
              at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
              at com.eldoserv.ejbs.interfaces.ClaimSessionUtil.getHome(ClaimSessionUtil.java:34)
              at com.eldoserv.knopro.eclipse.views.ClaimSearchResultsView.search(ClaimSearchResultsView.ja
              va:409)
              at com.eldoserv.knopro.eclipse.views.ClaimSearchView$1.widgetSelected(ClaimSearchView.java:1
              01)
              at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:87)
              at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77)
              at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833)
              at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1622)
              at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1368)
              at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1420)
              at org.eclipse.ui.internal.Workbench.run(Workbench.java:1403)
              at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:775)
              at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462)
              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:324)
              at org.eclipse.core.launcher.Main.basicRun(Main.java:247)
              at org.eclipse.core.launcher.Main.run(Main.java:703)
              at org.eclipse.core.launcher.Main.main(Main.java:539)

              Jeremy Cowgar
              jc@cowgar.com

              • 4. Re: ClassCastException while outside IDE, works fine in IDE.
                jcowgar

                I'm sorry, I need to stop posting as quick. That stack trace is not right either, wrong example again, but here is the code that created the above error message, ClaimSessionUtil.java, Lines: 28-38

                public static com.eldoserv.ejbs.interfaces.ClaimSessionHome getHome() throws NamingException
                {
                // Obtain initial context
                InitialContext initialContext = new InitialContext();
                try {
                java.lang.Object objRef = initialContext.lookup(com.eldoserv.ejbs.interfaces.ClaimSessionHome.JNDI_NAME);
                return (com.eldoserv.ejbs.interfaces.ClaimSessionHome) PortableRemoteObject.narrow(objRef, com.eldoserv.ejbs.interfaces.ClaimSessionHome.class);
                } finally {
                initialContext.close();
                }
                }


                Jeremy Cowgar
                jc@cowgar.com

                • 5. Re: ClassCastException while outside IDE, works fine in IDE.
                  jcowgar

                  Oh, in case you didn't see, the whole ClaimSessionUtil.java file is attached.

                  Jeremy

                  • 6. Re: ClassCastException while outside IDE, works fine in IDE.
                    prabhakar

                    When you use the client outside eclipse, are you adding the jars in $jboss/client/lib to your classpath.

                    -prabhakar

                    • 7. Re: ClassCastException while outside IDE, works fine in IDE.
                      jcowgar

                      Yes. I have no problems with finding classes.

                      Jeremy Cowgar
                      jc@cowgar.com

                      • 9. Re: ClassCastException while outside IDE, works fine in IDE.
                        jcowgar

                        Yeah, I saw that one before. I have never had anything but 3.0.3 on my system, so that one does not apply :(

                        The thing that is strange is that it works great in the IDE and does not outside.

                        Jeremy Cowgar
                        jc@cowgar.com

                        • 10. Re: ClassCastException while outside IDE, works fine in IDE.

                          Does your IDE run a different version of the JDK (rt.jar specifically)?

                          • 11. Re: ClassCastException while outside IDE, works fine in IDE.
                            jcowgar

                            No, it's eclipse and when installs asks which RT you wish to use. I think it has to do something with Eclipse using class loaders.

                            Jeremy