2015-07-17 40 views
9

Ten problem występują w nowszej wersji servicemix (testowanej w wersji 5.4 - cxf 3.0.2 i 5.3 - cxf 2.7.11) w starszej wersji 4.5.2 z cxf 2.6.8 wszystko działa, tworzone są serwisy internetowe.wsdl2java Dwie klasy mają tę samą nazwę typu XML "{http: //***.***.***.***.***/***/***/***} objectFactory"

W naszym projekcie mamy wiele różnych serwisów internetowych generowanych przez wtyczkę maven wtdl2java w różnych pakietach. W servicemix 5.4 prawie wszystkie webservices są wyłączone z powodu tych błędów, dziwne jest to, że w poprzednim servicemix 5.3 jeden z pakietów jest w stanie uruchomić bez żadnych modyfikacji w projekcie.

W Maven Próbowałem użyć dodatkowych extraarg:

<extraarg>-autoNameResolution</extraarg> 
<extraarg>-xjc-npa</extraarg> 

jednak bez rezultatu

StackTrace:

Unable to start blueprint container for bundle bundle-name1 
    org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to initialize bean .camelBlueprint.factory.camelContext 
     at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:714)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[19:org.apache.aries.blueprint.core:1.4.1] 
     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_21] 
     at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_21] 
     at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:230)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:145)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:753)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.camel.blueprint.handler.CamelNamespaceHandler$CamelDependenciesFinder.process(CamelNamespaceHandler.java:863)[105:org.apache.camel.camel-blueprint:2.13.2] 
     at org.apache.aries.blueprint.container.BlueprintContainerImpl.processProcessors(BlueprintContainerImpl.java:528)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:361)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:269)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:276)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:245)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:235)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[14:org.apache.aries.util:1.1.0] 
     at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[14:org.apache.aries.util:1.1.0] 
     at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[14:org.apache.aries.util:1.1.0] 
     at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[14:org.apache.aries.util:1.1.0] 
     at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[14:org.apache.aries.util:1.1.0] 
     at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1127)[org.apache.felix.framework-4.4.1.jar:] 
     at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:696)[org.apache.felix.framework-4.4.1.jar:] 
     at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:484)[org.apache.felix.framework-4.4.1.jar:] 
     at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4429)[org.apache.felix.framework-4.4.1.jar:] 
     at org.apache.felix.framework.Felix.startBundle(Felix.java:2100)[org.apache.felix.framework-4.4.1.jar:] 
     at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1299)[org.apache.felix.framework-4.4.1.jar:] 
     at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304)[org.apache.felix.framework-4.4.1.jar:] 
     at java.lang.Thread.run(Thread.java:722)[:1.7.0_21] 
    Caused by: org.apache.camel.NoSuchBeanException: Cannot lookup: routeBuilder from registry: [email protected] with expected type: interface org.apache.camel.RoutesBuilder due: Error when instantiating bean ****CxfClient of class ***.***.***.***.***.***.***.*** 
     at org.apache.camel.impl.CompositeRegistry.lookupByNameAndType(CompositeRegistry.java:62) 
     at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookupByNameAndType(PropertyPlaceholderDelegateRegistry.java:63) 
     at org.apache.camel.util.CamelContextHelper.lookup(CamelContextHelper.java:129) 
     at org.apache.camel.model.RouteBuilderDefinition.createRoutes(RouteBuilderDefinition.java:70) 
     at org.apache.camel.core.xml.AbstractCamelContextFactoryBean.installRoutes(AbstractCamelContextFactoryBean.java:750) 
     at org.apache.camel.core.xml.AbstractCamelContextFactoryBean.setupRoutes(AbstractCamelContextFactoryBean.java:311) 
     at org.apache.camel.blueprint.CamelContextFactoryBean.afterPropertiesSet(CamelContextFactoryBean.java:304) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_21] 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_21] 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_21] 
     at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_21] 
     at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:297)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:958)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)[19:org.apache.aries.blueprint.core:1.4.1] 
     ... 30 more 
    Caused by: org.osgi.service.blueprint.container.ComponentDefinitionException: Error when instantiating bean ****CxfClient of class ***.***.***.***.***.***.***.*** 
     at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:300)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:806)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[19:org.apache.aries.blueprint.core:1.4.1] 
     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_21] 
     at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_21] 
     at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.di.RefRecipe.internalCreate(RefRecipe.java:62)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:106)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:268)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:806)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[19:org.apache.aries.blueprint.core:1.4.1] 
     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_21] 
     at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_21] 
     at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.di.RefRecipe.internalCreate(RefRecipe.java:62)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:106)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:933)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:907)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:888)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:820)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[19:org.apache.aries.blueprint.core:1.4.1] 
     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_21] 
     at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_21] 
     at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:230)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:145)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:753)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.camel.blueprint.BlueprintContainerRegistry.lookupByNameAndType(BlueprintContainerRegistry.java:54) 
     at org.apache.camel.impl.CompositeRegistry.lookupByNameAndType(CompositeRegistry.java:56) 
     ... 43 more 
    Caused by: org.apache.cxf.service.factory.ServiceConstructionException 
     at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:341) 
     at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86) 
     at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:490) 
     at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:704) 
     at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:550) 
     at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:265) 
     at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215) 
     at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102) 
     at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91) 
     at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:157) 
     at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_21] 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_21] 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_21] 
     at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_21] 
     at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:297)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:958)[19:org.apache.aries.blueprint.core:1.4.1] 
     at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:298)[19:org.apache.aries.blueprint.core:1.4.1] 
     ... 75 more 
    Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions 
    Two classes have the same XML type name "{http://***.***.***.***/***/***/***}objectFactory". Use @XmlType.name and @XmlType.namespace to assign different names to them. 
     this problem is related to the following location: 
      at ***.***.***.***.***.***.***.ObjectFactory 
     this problem is related to the following location: 
      at 1***.1***.1***.1***.1***.1***.1***.ObjectFactory 
    Two classes have the same XML type name "{http://***.***.***.***/***/***/***}objectFactory". Use @XmlType.name and @XmlType.namespace to assign different names to them. 
     this problem is related to the following location: 
      at ***.***.***.***.***.***.***.ObjectFactory 
     this problem is related to the following location: 
      at 1***.1***.1***.1***.1***.ObjectFactory 

     at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102) 
     at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:472) 
     at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302) 
     at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140) 
     at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154) 
     at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121) 
     at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_21] 
     at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_21] 
     at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:222)[:2.4.0] 
     at javax.xml.bind.ContextFinder.find(ContextFinder.java:396)[:2.4.0] 
     at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:656)[:2.4.0] 
     at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:345) 
     at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:343) 
     at java.security.AccessController.doPrivileged(Native Method)[:1.7.0_21] 
     at org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:343) 
     at org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:244) 
     at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:484) 
     at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:339) 
     ... 92 more 

EDIT

Próbowałem downgrade CXF do 2,6 .8 ale mam takie same błędy, więc , Przypuszczam, że problem jest gdzie indziej może w org.apache.aries.blueprint.core.

EDIT 2

Próbowałem też stworzyć jeden duży pakiet z wszystkich wygenerowanych klas, ale problemem jest to samo

+0

Czy 2 xmltypy pochodzą z 2 różnych schematów? – Sridhar

+0

Używasz wtyczki cxf-codegen do generowania klas klientów przez maven? – MWiesner

Odpowiedz

-1

Problem dotyczy nieprawidłowej definicji <Import-Package> w pom. Zmieniliśmy import zgodnie z dokumentacją bezpiecznika i wszystko zaczęło działać poprawnie.

<Import-Package> 
      javax.jws, 
      javax.wsdl, 
      javax.xml.bind, 
      javax.xml.bind.annotation, 
      javax.xml.namespace, 
      javax.xml.ws, 
      org.apache.cxf, 
      org.apache.cxf.bus, 
      org.apache.cxf.bus.spring, 
      org.apache.cxf.bus.resource, 
      org.apache.cxf.interceptor, 
      org.apache.cxf.io, 
      org.apache.cxf.message, 
      org.apache.cxf.phase, 
      org.apache.cxf.service, 
      org.apache.cxf.service.model, 
      org.apache.cxf.transport, 
      org.apache.cxf.ws.addressing, 
      org.apache.cxf.ws.rm, 
      org.apache.cxf.ws.rm.v200702, 
      org.apache.cxf.configuration.spring, 
      org.apache.cxf.resource, 
      org.apache.cxf.jaxws, 
      org.springframework.beans.factory.config     
      * 
     </Import-Package> 
6

W przypadku generowania kodu WS-klienta poprzez cxf-codegen-plugin, można oddzielny nazwy pakietów pakietów ws/client o określonej konfiguracji. I osiągnąć coś podobnego w jednym z moich projektów tak:

... 
<plugin> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-codegen-plugin</artifactId> 
     <version>${cxf.version}</version> 
     <executions> 
      <execution> 
       <id>generate-sources</id> 
       <phase>generate-sources</phase> 
       <configuration> 
        <sourceRoot>${basedir}/src/main/gen</sourceRoot> 
        <wsdlOptions> 
         <wsdlOption> 
          <wsdl>${basedir}/src/main/resources/MyWSEndpoint1.wsdl</wsdl> 
          <extraargs> 
           <extraarg>-client</extraarg> 
           <!-- 
           <extraarg>-validate</extraarg> 
           --> 
           <extraarg>-p</extraarg> 
           <extraarg>com.acme.ws.jaxb.ns1</extraarg> 
           <extraarg>-wsdlLocation</extraarg> 
           <extraarg></extraarg> 
          </extraargs> 
         </wsdlOption> 
         <wsdlOption> 
          <wsdl>${basedir}/src/main/resources/MyWSEndpoint2.wsdl</wsdl> 
          <extraargs> 
           <extraarg>-client</extraarg> 
           <!-- 
           <extraarg>-validate</extraarg> 
           --> 
           <extraarg>-p</extraarg> 
           <extraarg>com.acme.ws.jaxb.ns2</extraarg> 
           <extraarg>-wsdlLocation</extraarg> 
           <extraarg></extraarg> 
          </extraargs> 
         </wsdlOption> 
        </wsdlOptions> 
       </configuration> 
       <goals> 
        <goal>wsdl2java</goal> 
       </goals> 
      </execution> 
     </executions> 
</plugin>   
...  

Zatem „osobnik” pakiety dla każdego konkretnego klienta WS-{http://***.***.***.***/***/***/***}objectFactory powinien być wygenerowany, które mogłyby przyczynić się do uniknięcia konfliktów podczas fazy generowania kodu. W związku z tym problemy związane z programem NameSpace nie powinny powodować blokowania użytkownika.

Należy pamiętać, że com.acme.ws.jaxb.ns1 i com.acme.ws.jaxb.ns2 to tylko sugestie i że można wykorzystać to, co wydaje się ważne dla danego projektu.

Patrz również Apache CXF - WSDL to Java

-p [wsdl-namespace =] packageName

Określa zero lub więcej, nazwy pakietów do użycia wygenerowanego kodu. Opcjonalnie> określa przestrzeń nazw WSDL do mapowania nazw pakietów.

Komentarze mile widziane.

+0

Witam, już w naszym projekcie używamy arg -p [wsdl-namespace =] NazwaPakietu.Głównym pytaniem jest, dlaczego w różnych cxf te generowane klasy działają w inny sposób. – mapek

+0

czy są oddzielone, aby się różnić w każdym module? – MWiesner

+0

To nie jest tak oczywiste dla innych, gdy widzą zamaskowane paczki ...;) – MWiesner