gpt4 book ai didi

java - wsdl2java 两个类具有相同的 XML 类型名称 "{http://***.***.***.***/***/***/***}objectFactory"

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:22:23 25 4
gpt4 key购买 nike

此问题发生在较新版本的 servicemix(在 5.4 - cxf 3.0.2 和 5.3 - cxf 2.7.11 上测试)在旧版本 4.5.2 和 cxf 2.6.8 一切正常,创建了 web 服务。

在我们的项目中,我们有很多不同的包中的 maven 插件 wsdl2java 生成的不同的 web 服务。在 servicemix 5.4 中,几乎所有的 web 服务都由于这些错误而关闭,奇怪的是,在以前的 servicemix 5.3 中,其中一个 bundle 无需对项目进行任何修改即可启动。

在 maven 中我尝试使用额外的 extraarg:

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

但没有任何结果

堆栈跟踪:

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: org.apache.camel.blueprint.BlueprintContainerRegistry@597012f0 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

编辑

我试图将 cxf 降级到 2.6.8,但我得到了同样的错误,所以我想问题出在其他地方,可能在 org.apache.aries.blueprint.core 中。

编辑 2

我也尝试用所有生成的类创建一个大包,但问题是一样的

最佳答案

如果您通过 cxf-codegen-plugin 生成 ws-client 代码,您可以使用具体配置。我在我的一个项目中取得了类似的成就:

 ...
<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>
...

因此,每个 ws-client 特定的“个人”包 {http://***.***.***.***/***/***/*** }objectFactory 应该生成,这可能有助于避免代码生成阶段的冲突。因此,在运行时,不会有与 namespace 相关的问题阻碍您。

请记住,com.acme.ws.jaxb.ns1com.acme.ws.jaxb.ns2 只是建议,您可以使用任何看似对您在那里的项目有效。

另见 Apache CXF - WSDL to Java

-p [ wsdl-namespace= ] PackageName

Specifies zero, or more, package names to use for the generated code. Optionally > specifies the WSDL namespace to package name mapping.

欢迎评论。

关于java - wsdl2java 两个类具有相同的 XML 类型名称 "{http://***.***.***.***/***/***/***}objectFactory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31475499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com