1 2 3 Previous Next 33 Replies Latest reply on Mar 2, 2010 10:34 PM by alexandreesl

    WS-RM Exception: cannot be cast to org.jboss.ws.core.StubExt

    moweis

      Hi,

      I'm running the example found at:
      http://jbws.dyndns.org/mediawiki/index.php?title=Native_WS-ReliableMessaging_Tutorial

      I'm able to deploy the WS, but when I try to run the sample client:
      http://jbws.dyndns.org/mediawiki/index.php?title=Native_WS-ReliableMessaging_Tutorial#Updating_Client_Code_to_Reference_Custom_JAX-WS_Config_File_and_Close_the_Sequence

      I get the following exception:

      Exception in thread "main" java.lang.ClassCastException: $Proxy25 cannot be cast to org.jboss.ws.core.StubExt


      at the line:

      ((StubExt)proxy).setConfigName("Standard Anonymous WSRM Client", "META-INF/wsrm-jaxws-client-config.xml");
      

      FYI, when I run the client with this line commented out, I get a fault from the service that I'm not using WS-RM:
      Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: java.lang.IllegalStateException: RM handler was not able to find WS-RM message in the payload

      So the service seems to be configured fine, but I am unable to get the client to add WS-RM appropriately.

      Any ideas?

      I'm using:
      -jboss-4.2.3.GA
      -jbossws-native-3.0.2.GA

      Thanks in advance!


        • 1. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
          ropalka

          Can you copy/paste your client code here?

          • 2. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
            moweis

            Sure:

            Here is my client code:

            package org.jboss.test.ws.jaxws.samples.wsrm.client;
            
            import java.net.URL;
            import javax.xml.namespace.QName;
            import javax.xml.ws.Service;
            import org.jboss.ws.core.StubExt;
            import org.jboss.ws.extensions.wsrm.api.RMProvider;
            
            import org.jboss.test.ws.jaxws.samples.wsrm.generated.SimpleService;
            
            
            public final class SimpleServiceTestCase
            {
            
             private static final String serviceURL = "http://localhost:8080/jaxws-samples-wsrm/SimpleService";
            
             public static void main(String[] args) throws Exception
             {
             String url = null;
             if ( args != null && args.length > 0 && args[0] != null )
             url = args[0];
             else
             url = serviceURL;
             System.out.println("Calling wsdl");
             QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "SimpleService");
             QName portName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "SimpleServicePort");
             URL wsdlURL = new URL(url + "?wsdl");
             Service service = Service.create(wsdlURL, serviceName);
             SimpleService proxy = (SimpleService)service.getPort(SimpleService.class);
             ((StubExt)proxy).setConfigName("Standard Anonymous WSRM Client", "META-INF/wsrm-jaxws-client-config.xml");
            
             proxy.ping(); // one way call
             proxy.echo("Hello World!"); // request responce call
             ((RMProvider)proxy).closeSequence();
             }
            
            }
            


            It is directly from the client example on the page:
            http://jbws.dyndns.org/mediawiki/index.php?title=Native_WS-ReliableMessaging_Tutorial#Updating_Client_Code_to_Reference_Custom_JAX-WS_Config_File_and_Close_the_Sequence

            • 3. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
              ropalka

               

              "moweis" wrote:

              I get the following exception:
              Exception in thread "main" java.lang.ClassCastException: $Proxy25 cannot be cast to org.jboss.ws.core.StubExt

              in advance!

              And what is the full stack trace?

              • 4. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
                moweis

                Here is the full stack trace:

                Exception in thread "main" java.lang.ClassCastException: $Proxy25 cannot be cast to org.jboss.ws.core.StubExt
                at org.jboss.test.ws.jaxws.samples.wsrm.client.SimpleServiceTestCase.main(SimpleServiceTestCase.java:30)


                Line 30 is:
                ((StubExt)proxy).setConfigName("Standard Anonymous WSRM Client", "META-INF/wsrm-jaxws-client-config.xml");
                


                • 5. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
                  ropalka

                  Are you using jbossws only libs?
                  What is your client classpath?

                  • 6. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
                    moweis

                    I'm wondering if the wsconsume didn't run properly?

                    I ran it twice:
                    First with a non-WS-Policy wsdl
                    Second with WS-Policy wsdl


                    Both generated the same files.

                    Is that correct?

                    • 7. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
                      moweis

                      Yes, here is my command-line execution:


                      /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/java -classpath .:../wsconsume/generated/classes/:${JBOSS_WS_HOME}/deploy/lib/jbossws-native-core.jar org.jboss.test.ws.jaxws.samples.wsrm.client.SimpleServiceTestCase


                      • 8. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
                        ropalka

                        You have to endorse JAXWS.
                        Try to add:

                        -Djava.endorsed.dirs=${JBOSS_HOME}/lib/endorsed

                        to your client launch command.

                        • 9. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
                          moweis

                          I still get the same error :(

                          /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/java -classpath .:..:../wsconsume/generated/classes/:${JBOSS_WS_HOME}/deploy/lib/jbossws-native-core.jar org.jboss.test.ws.jaxws.samples.wsrm.client.SimpleServiceTestCase -Djava.endorsed.dirs=${JBOSS_HOME}/lib/endorsed

                          Exception in thread "main" java.lang.ClassCastException: $Proxy25 cannot be cast to org.jboss.ws.core.StubExt
                          at org.jboss.test.ws.jaxws.samples.wsrm.client.SimpleServiceTestCase.main(SimpleServiceTestCase.java:30)
                          marw


                          • 10. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
                            ropalka

                            OK, did you see:

                            http://jbws.dyndns.org/mediawiki/index.php?title=Installation

                            topic:

                            Using JBossWS Native with JDK 6

                            • 11. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
                              moweis

                              Yes I did...I copied the libs as stated.

                              Question, if I run wsconsume on the wsdl with no WS-RM related info, and run it again with WS-RM configuration, should I see any difference in the generated source?

                              Because looking at the generated service interface, it doesn't extend StubExt:

                              package org.jboss.test.ws.jaxws.samples.wsrm.generated;
                              
                              import javax.jws.Oneway;
                              import javax.jws.WebMethod;
                              import javax.jws.WebParam;
                              import javax.jws.WebResult;
                              import javax.jws.WebService;
                              import javax.xml.ws.RequestWrapper;
                              import javax.xml.ws.ResponseWrapper;
                              
                              
                              /**
                               * This class was generated by the JAX-WS RI.
                               * JAX-WS RI 2.1.3-b02-
                               * Generated source version: 2.0
                               *
                               */
                              @WebService(name = "SimpleService", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm")
                              public interface SimpleService {
                              
                              
                               /**
                               *
                               * @param arg0
                               * @return
                               * returns java.lang.String
                               */
                               @WebMethod
                               @WebResult(targetNamespace = "")
                               @RequestWrapper(localName = "echo", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm", className = "org.jboss.test.ws.jaxws.samples.wsrm.generated.Echo")
                               @ResponseWrapper(localName = "echoResponse", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm", className = "org.jboss.test.ws.jaxws.samples.wsrm.generated.EchoResponse")
                               public String echo(
                               @WebParam(name = "arg0", targetNamespace = "")
                               String arg0);
                              
                               /**
                               *
                               */
                               @WebMethod
                               @Oneway
                               @RequestWrapper(localName = "ping", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm", className = "org.jboss.test.ws.jaxws.samples.wsrm.generated.Ping")
                               public void ping();
                              
                              }
                              


                              Thanks for your help Richard

                              • 12. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
                                ropalka

                                 

                                "moweis" wrote:

                                Question, if I run wsconsume on the wsdl with no WS-RM related info, and run it again with WS-RM configuration, should I see any difference in the generated source?

                                Because looking at the generated service interface, it doesn't extend StubExt:

                                No, the interface implementation is generated via Java proxies at runtime (behind the scenes)

                                "moweis" wrote:
                                Thanks for your help Richard

                                Does the client work already?

                                • 13. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
                                  moweis

                                  No i still have the same error...

                                  • 14. Re: WS-RM Exception: cannot be cast to org.jboss.ws.core.Stu
                                    ropalka

                                    To recapitulate your problem is wrong client classpath.
                                    You didn't endorse jbossws client libraries properly.
                                    The last stupid question: is your JBOSS_HOME environment variable defined?

                                    1 2 3 Previous Next