0 Replies Latest reply on Mar 18, 2016 11:46 AM by soltzu

    Static wsdl not working after ugrading to CXF 3.0.4

    soltzu Newbie

      So I have a pretty simple setup where I have a wsdl in my web application, I use this wsdl to generate classes which I then instantiate and use to call methods present on a remote server that uses the exact same wsdl I have in my web application.

      This was working until not long ago when I upgraded from CXF 2.6.8 to CXF 3.0.4 (more precisely the version that comes with JBoss Fuse 6.2.1 running on top of JBoss 6.4.0 EAP). Here is the dependencies section of my pom file (note that I have a root pom for version management and all dependencies are provided by default):

      <dependencies>
             
              <dependency>
                  <groupId>org.apache.cxf</groupId>
                  <artifactId>cxf-core</artifactId>
              </dependency>
             
              <dependency>
                  <groupId>org.apache.cxf</groupId>
                  <artifactId>cxf-rt-wsdl</artifactId>       
              </dependency>
             
              <dependency>
                  <groupId>org.apache.cxf</groupId>
                  <artifactId>cxf-rt-frontend-jaxws</artifactId>        
              </dependency>
             
              <dependency>
                  <groupId>org.jboss.spec</groupId>
                  <artifactId>jboss-javaee-all-6.0</artifactId>
              </dependency>
             
              <dependency>
                  <groupId>org.apache.camel</groupId>
                  <artifactId>camel-cdi</artifactId>        
              </dependency>
             
              <dependency>
                  <groupId>org.codehaus.jettison</groupId>
                  <artifactId>jettison</artifactId>
              </dependency>
                    
              <dependency>
                  <groupId>junit</groupId>
                  <artifactId>junit</artifactId>
              </dependency>
             
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-validator</artifactId>
              </dependency>
      
      

      Here is the source generation by the wsdl2java maven plugin, also from the pom:

      <plugin>
          <groupId>org.apache.cxf</groupId>
          <artifactId>cxf-codegen-plugin</artifactId>
          <configuration>
              <fork>once</fork>
          </configuration>
          <executions> 
              <execution>
                  <id>Step one</id>
                  <phase>generate-sources</phase>
                  <goals>
                      <goal>wsdl2java</goal>
                  </goals>
                  <configuration>
                      <sourceRoot>${project.build.directory}/generated-sources/wsdl/pg-sapc</sourceRoot>
                      <wsdlOptions>
                          <wsdlOption>
                              <wsdl>${project.basedir}/src/main/resources/wsdl/Generic/MyWsdl.wsdl</wsdl>
                              <wsdlLocation>classpath:wsdl/Generic/MyWsdl.wsdl</wsdlLocation>
                              <packagenames>
                                  <packagename>my.package</packagename>
                              </packagenames>
                              <extraargs>
                                  <extraarg>-exsh</extraarg>
                                  <extraarg>true</extraarg>
                              </extraargs>
                          </wsdlOption>
                      </wsdlOptions>
                  </configuration>
              </execution>
          ...
      
      

      And this is the code using the generated files, notice I change the endpoint to the remote server endpoint before calling a method:

      private static final GeneratedSource GENERATEDSOURCE = new GeneratedSource();
          ...
          Service destination = GENERATEDSOURCE.getServiceport(); //EXCEPTION TRIGGERED ON THIS LINE!!! 
          BindingProvider prov = (BindingProvider) destination;
         
          prov.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
          prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
          prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);  
          try { 
              destination.methodCall(inputData);
          } catch (WebServiceException ex) {
          ...
      
      

      I marked the line that throws an exception in the above code. The stack trace is:

      Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Service class my.package.protocol.session.SessionControl does not implement the logout method.
          at org.apache.cxf.jaxws.JAXWSMethodDispatcher.bind(JAXWSMethodDispatcher.java:69) [cxf-rt-frontend-jaxws-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.bindOperation(JaxWsServiceFactoryBean.java:294) [cxf-rt-frontend-jaxws-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.initializeWSDLOperation(JaxWsServiceFactoryBean.java:267) [cxf-rt-frontend-jaxws-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeWSDLOperations(ReflectionServiceFactoryBean.java:665) [cxf-rt-wsdl-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.initializeWSDLOperations(JaxWsServiceFactoryBean.java:303) [cxf-rt-frontend-jaxws-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:415) [cxf-rt-wsdl-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:525) [cxf-rt-wsdl-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:261) [cxf-rt-wsdl-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215) [cxf-rt-frontend-jaxws-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102) [cxf-rt-frontend-simple-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91) [cxf-rt-frontend-simple-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:157) [cxf-rt-frontend-simple-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142) [cxf-rt-frontend-jaxws-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:493) [cxf-rt-frontend-jaxws-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:359) [cxf-rt-frontend-jaxws-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          ... 211 more
      Caused by: java.lang.NoSuchMethodException: my.package.protocol.session.SessionControl.logout(my.package.protocol.session.Logout, javax.xml.ws.Holder)
          at java.lang.Class.getMethod(Class.java:1670) [rt.jar:1.7.0_71]
          at org.apache.cxf.jaxws.JAXWSMethodDispatcher.getImplementationMethod(JAXWSMethodDispatcher.java:89) [cxf-rt-frontend-jaxws-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          at org.apache.cxf.jaxws.JAXWSMethodDispatcher.bind(JAXWSMethodDispatcher.java:56) [cxf-rt-frontend-jaxws-3.0.4.redhat-621084.jar:3.0.4.redhat-621084]
          ... 225 more
      
      

      Any clues as to what am I doing wrong would be much appreciated, thanks!

      UPDATE: I have seen found a way of getting this error consistently, before there were some strange occasions in which it did not happen. The steps are:

      1- Restart JBoss.

      2- Deploy application. Now it doesn't give me the exception.

      3- Re-deploy the exact same application. Now it gives me the exception.

      4- Restart JBoss without deploying again. Now it doesn't give me the exception.

      5- Re-deploy application again. Not I get the exception.