Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-4708

Unnable to publish service when XmlAdapter has generic parameter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.7.1
    • 2.5.8, 2.6.5, 2.7.2
    • Core, Tooling
    • None
    • Maven 3.0.4, cxf-java2ws-plugin 2.7.1

    • Unknown

    Description

      Following exception is thrown when generate WSDL from Java Code. I was able to debug the code and found that problem is that implementation of the XmlAdapter contains generic typed class.

      Eg. Following XmlAdapter declaration does not work.

      public class MappedListXmlAdapter<K, V> extends XmlAdapter<JaxbHashMapList<K, V>, MappedList<K, V>> {
      

      but the declaration without generic works:

      public class MappedListXmlAdapter extends XmlAdapter<JaxbHashMapList, MappedList> {
      

      Same apply for more complex XmlAdapter. Following throws exception.

      public class EnumWrapperAdapter<T extends Enum<T>> extends XmlAdapter<T, EnumWrapper<T>> {
      

      After this update it is ok

      public class EnumWrapperAdapter extends XmlAdapter<Enum, EnumWrapper> {
      

      This is regression as it works with plugin version 2.5.2

      java.lang.RuntimeException: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
      at org.apache.cxf.frontend.AbstractServiceFactory.createService(AbstractServiceFactory.java:80)
      at org.apache.cxf.tools.java2wsdl.processor.JavaToWSDLProcessor.process(JavaToWSDLProcessor.java:101)
      at org.apache.cxf.tools.java2ws.JavaToWSContainer.processWSDL(JavaToWSContainer.java:110)
      at org.apache.cxf.tools.java2ws.JavaToWSContainer.execute(JavaToWSContainer.java:75)
      at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
      at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:58)
      at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:40)
      at org.apache.cxf.tools.java2ws.JavaToWS.run(JavaToWS.java:77)
      at org.apache.cxf.maven_plugin.Java2WSMojo.processJavaClass(Java2WSMojo.java:357)
      at org.apache.cxf.maven_plugin.Java2WSMojo.execute(Java2WSMojo.java:225)
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
      at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
      at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
      at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
      at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
      at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
      at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
      Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
      at org.apache.cxf.jaxb.Utils.getTypeFromXmlAdapter(Utils.java:294)
      at org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:295)
      at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:222)
      at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:212)
      at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:225)
      at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:212)
      at org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:337)
      at org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:309)
      at org.apache.cxf.jaxb.JAXBContextInitializer.begin(JAXBContextInitializer.java:173)
      at org.apache.cxf.service.ServiceModelVisitor.visitOperation(ServiceModelVisitor.java:109)
      at org.apache.cxf.service.ServiceModelVisitor.walk(ServiceModelVisitor.java:74)
      at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:318)
      at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
      at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:474)
      at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:690)
      at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:536)
      at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:248)
      at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:205)
      at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
      at org.apache.cxf.frontend.AbstractServiceFactory.createService(AbstractServiceFactory.java:78)

      Attachments

        1. bug4708.zip
          9 kB
          Jakub Štiller

        Activity

          People

            dkulp Daniel Kulp
            stiller Jakub Štiller
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: