我在karaf中启动我的捆绑包时遇到问题。 我已经安装了cxf和http功能。 但是当我尝试在Karaf中安装我的软件包时,我有这个例外:
2016-09-18 17:07:49,157 | ERROR | nsole user karaf | BlueprintContainerImpl | 12 - org.apache.aries.blueprint.core - 1.6.2 | Unable to start blueprint container for bundle karafcxf.rest/1.0.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to initialize bean cxf
....
Caused by: org.apache.cxf.bus.extension.ExtensionException: Could not create object of extension class org.apache.cxf.ws.policy.PolicyEngineImpl.
at org.apache.cxf.bus.extension.Extension.load(Extension.java:241)
at org.apache.cxf.bus.osgi.CXFExtensionBundleListener$OSGiExtension.load(CXFExtensionBundleListener.java:145)
at org.......
Caused by: java.lang.ClassCastException: Cannot cast org.apache.cxf.service.factory.FactoryBeanListenerManager to org.apache.cxf.service.factory.FactoryBeanListenerManager
at java.lang.Class.cast(Class.java:3258)[:1.8.0]
at org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeanOfType(ExtensionManagerImpl.java:322)
at org.apache.cxf.bus.blueprint.BlueprintBeanLocator.getBeanOfType(BlueprintBeanLocator.java:99)
at .....
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0]
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)[:1.8.0]
at org.apache.cxf.bus.extension.Extension.load(Extension.java:217)
这是我的蓝图背景:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws" xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"
xmlns:cxf="http://cxf.apache.org/blueprint/core"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd
http://cxf.apache.org/blueprint/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd
http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd">
<cxf:bus id="cxfBus1">
<cxf:features>
<cxf:logging />
</cxf:features>
</cxf:bus>
<!-- <bean id="resourceWriter" -->
<!-- class="com.wordnik.swagger.jaxrs.listing.ResourceListingProvider" /> -->
<!-- <bean id="apiWriter" -->
<!-- class="com.wordnik.swagger.jaxrs.listing.ApiDeclarationProvider" /> -->
<!-- JAXRS providers -->
<!-- <bean id="jsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" /> -->
<!-- <bean id="swaggerResourceJSON" -->
<!-- class="com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON" /> -->
<!-- CXF Swagger2Feature -->
<!-- <bean id="swagger2Feature" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature"> -->
<!-- <property name="resourcePackage" value="com.sau.swagger.intg" /> -->
<!-- <property name="version" value="2.0" /> -->
<!-- <property name="basePath" -->
<!-- value="http://localhost:8080/SwaggerUI-Integration/rest" /> -->
<!-- <property name="title" value="Swagger UI Integration Sample" /> -->
<!-- <property name="description" -->
<!-- value="Swagger UI Integration Sample for demonstrating its working." /> -->
<!-- <property name="contact" value="saurabh29july@gmail.com" /> -->
<!-- <property name="scan" value="true" /> -->
<!-- </bean> -->
<jaxrs:server address="/karafsimple" id="someRestService">
<jaxrs:serviceBeans>
<ref component-id="restServiceImpl" />
</jaxrs:serviceBeans>
<!-- <jaxrs:providers> -->
<!-- <ref component-id="jsonProvider" /> -->
<!-- </jaxrs:providers> -->
<!-- <jaxrs:features> -->
<!-- <ref component-id="swagger2Feature" /> -->
<!-- </jaxrs:features> -->
</jaxrs:server>
<!-- Implementation of the rest service -->
<bean id="restServiceImpl" class="me.rerun.karafcxf.rest.HelloRestServiceImpl">
<property name="helloService" ref="helloServiceBean" /> <!--Points to the reference below -->
</bean>
<!-- This has to point to the service registered through serviceimpl.xml
in the service.impl project -->
<reference id="helloServiceBean" interface="me.rerun.karafcxf.service.impl.HelloService">
</reference>
</blueprint>
这是我的maven dependecy树:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building karafcxf.rest 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ karafcxf.rest ---
[INFO] karafcxf:karafcxf.rest:bundle:1.0-SNAPSHOT
[INFO] +- karafcxf:karafcxf.service.impl:jar:1.0-SNAPSHOT:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] +- com.google.guava:guava:jar:14.0.1:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] +- org.codehaus.jackson:jackson-core-asl:jar:1.8.9:compile
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.8.9:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.2:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.6:compile
[INFO] +- org.apache.solr:solr-solrj:jar:4.4.0:compile
[INFO] | +- org.apache.zookeeper:zookeeper:jar:3.4.5:compile
[INFO] | +- commons-io:commons-io:jar:2.1:compile
[INFO] | +- org.noggit:noggit:jar:0.5:compile
[INFO] | +- org.apache.httpcomponents:httpmime:jar:4.2.3:compile
[INFO] | \- org.codehaus.woodstox:wstx-asl:jar:3.2.7:runtime
[INFO] +- org.osgi:org.osgi.core:jar:4.3.1:provided
[INFO] +- org.apache.cxf:cxf-rt-frontend-jaxrs:jar:2.7.11:compile
[INFO] | +- org.apache.cxf:cxf-api:jar:2.7.11:compile
[INFO] | | +- org.codehaus.woodstox:woodstox-core-asl:jar:4.2.1:compile
[INFO] | | | \- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
[INFO] | | +- org.apache.ws.xmlschema:xmlschema-core:jar:2.1.0:compile
[INFO] | | +- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.1:compile
[INFO] | | \- wsdl4j:wsdl4j:jar:1.6.3:compile
[INFO] | +- org.apache.cxf:cxf-rt-core:jar:2.7.11:compile
[INFO] | | \- com.sun.xml.bind:jaxb-impl:jar:2.1.13:compile
[INFO] | +- javax.ws.rs:javax.ws.rs-api:jar:2.0-m10:compile
[INFO] | \- org.apache.cxf:cxf-rt-bindings-xml:jar:2.7.11:compile
[INFO] +- org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.7.11:compile
[INFO] | +- xml-resolver:xml-resolver:jar:1.2:compile
[INFO] | +- asm:asm:jar:3.3.1:compile
[INFO] | +- org.apache.cxf:cxf-rt-bindings-soap:jar:2.7.11:compile
[INFO] | | \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.7.11:compile
[INFO] | +- org.apache.cxf:cxf-rt-frontend-simple:jar:2.7.11:compile
[INFO] | \- org.apache.cxf:cxf-rt-ws-addr:jar:2.7.11:compile
[INFO] | \- org.apache.cxf:cxf-rt-ws-policy:jar:2.7.11:compile
[INFO] | \- org.apache.neethi:neethi:jar:3.0.3:compile
[INFO] +- org.apache.cxf:cxf-rt-transports-http:jar:2.7.11:compile
[INFO] +- org.apache.cxf:cxf-rt-transports-http-jetty:jar:2.7.11:compile
[INFO] | +- org.eclipse.jetty:jetty-server:jar:8.1.14.v20131031:compile
[INFO] | | +- org.eclipse.jetty:jetty-continuation:jar:8.1.14.v20131031:compile
[INFO] | | \- org.eclipse.jetty:jetty-http:jar:8.1.14.v20131031:compile
[INFO] | | \- org.eclipse.jetty:jetty-io:jar:8.1.14.v20131031:compile
[INFO] | | \- org.eclipse.jetty:jetty-util:jar:8.1.14.v20131031:compile
[INFO] | +- org.eclipse.jetty:jetty-security:jar:8.1.14.v20131031:compile
[INFO] | \- org.apache.geronimo.specs:geronimo-servlet_3.0_spec:jar:1.0:compile
[INFO] \- org.apache.httpcomponents:httpclient:jar:4.2.3:compile
[INFO] +- org.apache.httpcomponents:httpcore:jar:4.2.2:compile
[INFO] +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] \- commons-codec:commons-codec:jar:1.6:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.865 s
[INFO] Finished at: 2016-09-18T17:17:41+02:00
[INFO] Final Memory: 14M/246M
[INFO] ------------------------------------------------------------------------