2015-09-28 40 views
0

當我嘗試從我的藍圖xml配置文件創建駱駝上下文時,我的駱駝測試無法啓動。似乎缺少一個snappyjava.dll。啓動藍圖包時駱駝測試失敗

有沒有人有這種類型的問題的經驗?

我在Windows 8.1平臺上使用gradle 2.6和Java 1.8.0_60進行測試。

我的藍圖XML看起來是這樣的:

<?xml version="1.0" encoding="UTF-8"?> 
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:cxf="http://camel.apache.org/schema/cxf" 
      xsi:schemaLocation=" 
      http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd 
      http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"> 

    <!-- Defined the real JAXRS back end service --> 
    <cxf:rsServer id="lookUpService" 
        address="http://localhost:8083/someapp/rest" 
        serviceClass="com.somecompany.someapp.MyEndpoint"> 
     <cxf:serviceBeans> 
      <ref bean="customerService"/> 
     </cxf:serviceBeans> 
    </cxf:rsServer> 

    <bean id="routBuilder" class="com.somecompany.someapp.SomeRoute"/> 

    <camelContext id="someapp" xmlns="http://camel.apache.org/schema/blueprint"> 
     <routeBuilder ref="routBuilder"/> 
    </camelContext> 

</blueprint> 

我在gradle這個項目的依賴關係是:

compile 'dk.sosi.seal:seal:2.2.6' 
compile 'org.apache.camel:camel-servlet:2.15.1' 
compile 'org.apache.camel:camel-test-blueprint:2.15.1' 
compile 'org.apache.cxf:cxf-rt-transports-http-jetty:3.0.4' 
compile 'org.apache.camel:camel-core:2.15.1' 
compile 'org.apache.camel:camel-blueprint:2.15.1' 
compile 'org.apache.camel:camel-jms:2.15.1' 
compile 'org.apache.camel:camel-cxf:2.15.1' 
compile 'org.apache.camel:camel-stream:2.15.1' 
compile 'org.apache.activemq:apache-activemq:5.11.0' 

testCompile 'junit:junit:4.12' 
testCompile 'org.apache.camel:camel-test:2.15.1' 

並運行測試時,我得到的標準錯誤的輸出如下:

SLF4J: Class path contains multiple SLF4J bindings. 
SLF4J: Found binding in [jar:file:/C:/Users/svt/.gradle/caches/modules-2/files-2.1/org.apache.activemq/activemq-all/5.11.0/5bcc10ea13c5723c1587f54245616cae1243b54c/activemq-all-5.11.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: Found binding in [jar:file:/C:/Users/svt/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-log4j12/1.7.10/b3eeae7d1765f988a1f45ea81517191315c69c9e/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] 
15/09/25 15:25:58 INFO blueprint.CamelBlueprintHelper: Using Blueprint XML file: /C:/someapp/build/resources/main/OSGI-INF.blueprint/someapp.xml 
15/09/25 15:25:59 INFO metadata.RawBuilder: Copy thread finished. 
15/09/25 15:25:59 INFO osgi.Activator: Camel activator starting 
15/09/25 15:25:59 INFO osgi.Activator: Camel activator started 
15/09/25 15:25:59 INFO blueprint.NamespaceHandlerRegisterer: Registered blueprint namespace handler for http://cxf.apache.org/transports/http-jetty/configuration 
org.osgi.framework.BundleException: Unable to start bundle 
    at de.kalpatec.pojosr.framework.PojoSRBundle.start(PojoSRBundle.java:144) 
    at de.kalpatec.pojosr.framework.PojoSR.startBundles(PojoSR.java:406) 
    at de.kalpatec.pojosr.framework.PojoSR.<init>(PojoSR.java:323) 
    at de.kalpatec.pojosr.framework.PojoServiceRegistryFactoryImpl.newPojoServiceRegistry(PojoServiceRegistryFactoryImpl.java:51) 
    at org.apache.camel.test.blueprint.CamelBlueprintHelper.createBundleContext(CamelBlueprintHelper.java:137) 
    at org.apache.camel.test.blueprint.CamelBlueprintHelper.createBundleContext(CamelBlueprintHelper.java:102) 
    at org.apache.camel.test.blueprint.CamelBlueprintTestSupport.createBundleContext(CamelBlueprintTestSupport.java:72) 
    at org.apache.camel.test.blueprint.CamelBlueprintTestSupport.setUp(CamelBlueprintTestSupport.java:180) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
... <cut stuff out to fit in stackoverflow post> ...  
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:744) 
Caused by: java.lang.UnsatisfiedLinkError: no snappyjava.dll in java.library.path 
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857) 
    at java.lang.Runtime.loadLibrary0(Runtime.java:870) 
    at java.lang.System.loadLibrary(System.java:1119) 
    at org.xerial.snappy.SnappyBundleActivator.start(SnappyBundleActivator.java:58) 
    at de.kalpatec.pojosr.framework.PojoSRBundle.start(PojoSRBundle.java:132) 
    ... 54 more 
15/09/25 15:25:59 INFO blueprint.NamespaceHandlerRegisterer: Registered blueprint namespace handler for http://cxf.apache.org/blueprint/jaxrs 
15/09/25 15:25:59 INFO blueprint.NamespaceHandlerRegisterer: Registered blueprint namespace handler for http://cxf.apache.org/blueprint/jaxws 
15/09/25 15:25:59 INFO blueprint.NamespaceHandlerRegisterer: Registered blueprint namespace handler for http://cxf.apache.org/clustering 
15/09/25 15:25:59 INFO blueprint.NamespaceHandlerRegisterer: Registered blueprint namespace handler for http://cxf.apache.org/blueprint/bindings/soap 
org.osgi.framework.BundleException: Unable to start bundle 
    at de.kalpatec.pojosr.framework.PojoSRBundle.start(PojoSRBundle.java:144) 
    at de.kalpatec.pojosr.framework.PojoSR.startBundles(PojoSR.java:406) 
    at de.kalpatec.pojosr.framework.PojoSR.<init>(PojoSR.java:323) 
    at de.kalpatec.pojosr.framework.PojoServiceRegistryFactoryImpl.newPojoServiceRegistry(PojoServiceRegistryFactoryImpl.java:51) 
    at org.apache.camel.test.blueprint.CamelBlueprintHelper.createBundleContext(CamelBlueprintHelper.java:137) 
    at org.apache.camel.test.blueprint.CamelBlueprintHelper.createBundleContext(CamelBlueprintHelper.java:102) 
    at org.apache.camel.test.blueprint.CamelBlueprintTestSupport.createBundleContext(CamelBlueprintTestSupport.java:72) 
    at org.apache.camel.test.blueprint.CamelBlueprintTestSupport.setUp(CamelBlueprintTestSupport.java:180) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
... <cut stuff out to fit in stackoverflow post> ...  
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) 
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:744) 
Caused by: java.lang.NoClassDefFoundError: org/eclipse/core/runtime/Plugin 
    at java.lang.ClassLoader.defineClass1(Native Method) 
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760) 
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) 
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) 
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73) 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:367) 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    at de.kalpatec.pojosr.framework.PojoSRBundle.start(PojoSRBundle.java:130) 
    ... 54 more 
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.Plugin 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372) 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 67 more 
15/09/25 15:25:59 INFO container.BlueprintExtender: No quiesce support is available, so blueprint components will not participate in quiesce operations 
15/09/25 15:25:59 INFO osgi.CXFActivator: Adding the extensions from bundle org.apache.cxf.cxf-rt-transports-http-jetty (8) [org.apache.cxf.transport.http_jetty.JettyDestinationFactory, org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory, org.apache.cxf.transport.http.ContinuationProviderFactory] 
15/09/25 15:25:59 INFO osgi.CXFActivator: Adding the extensions from bundle org.apache.camel.camel-cxf-transport (15) [org.apache.camel.component.cxf.transport.CamelTransportFactory] 
15/09/25 15:25:59 INFO osgi.CXFActivator: Adding the extensions from bundle org.apache.cxf.cxf-rt-frontend-jaxws (17) [org.apache.cxf.jaxws.context.WebServiceContextResourceResolver] 
15/09/25 15:25:59 INFO osgi.CXFActivator: Adding the extensions from bundle org.apache.cxf.cxf-rt-bindings-soap (20) [org.apache.cxf.binding.soap.SoapBindingFactory, org.apache.cxf.binding.soap.SoapTransportFactory] 
15/09/25 15:25:59 INFO osgi.CXFActivator: Adding the extensions from bundle org.apache.cxf.cxf-rt-transports-http (68) [org.apache.cxf.transport.http.HTTPTransportFactory, org.apache.cxf.transport.http.HTTPWSDLExtensionLoader, org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder, org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder, org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider] 
15/09/25 15:25:59 INFO osgi.CXFActivator: Adding the extensions from bundle org.apache.cxf.cxf-rt-bindings-xml (73) [org.apache.cxf.binding.xml.XMLBindingFactory, org.apache.cxf.binding.xml.wsdl11.XMLWSDLExtensionLoader] 
15/09/25 15:25:59 INFO osgi.CXFActivator: Adding the extensions from bundle org.apache.cxf.cxf-rt-ws-addr (75) [org.apache.cxf.ws.addressing.policy.AddressingAssertionBuilder, org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder, org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider, org.apache.cxf.ws.addressing.impl.AddressingWSDLExtensionLoader, org.apache.cxf.ws.addressing.WSAddressingFeature$WSAddressingFeatureApplier, org.apache.cxf.ws.addressing.MAPAggregator$MAPAggregatorLoader] 
15/09/25 15:25:59 INFO osgi.CXFActivator: Adding the extensions from bundle org.apache.cxf.cxf-rt-wsdl (77) [org.apache.cxf.wsdl.WSDLManager] 
15/09/25 15:25:59 INFO osgi.CXFActivator: Adding the extensions from bundle org.apache.cxf.cxf-rt-ws-policy (108) [org.apache.cxf.ws.policy.PolicyEngine, org.apache.cxf.policy.PolicyDataEngine, org.apache.cxf.ws.policy.AssertionBuilderRegistry, org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry, org.apache.cxf.ws.policy.PolicyBuilder, org.apache.cxf.ws.policy.PolicyAnnotationListener, org.apache.cxf.ws.policy.attachment.ServiceModelPolicyProvider, org.apache.cxf.ws.policy.attachment.external.DomainExpressionBuilderRegistry, org.apache.cxf.ws.policy.attachment.external.EndpointReferenceDomainExpressionBuilder, org.apache.cxf.ws.policy.attachment.external.URIDomainExpressionBuilder, org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider, org.apache.cxf.ws.policy.mtom.MTOMAssertionBuilder, org.apache.cxf.ws.policy.mtom.MTOMPolicyInterceptorProvider] 
15/09/25 15:25:59 INFO blueprint.NamespaceHandlerRegisterer: Registered blueprint namespace handler for http://cxf.apache.org/blueprint/core 
15/09/25 15:25:59 INFO blueprint.NamespaceHandlerRegisterer: Registered blueprint namespace handler for http://cxf.apache.org/configuration/beans 
... <cut stuff out to fit in stackoverflow post> ...  
15/09/25 15:26:00 INFO blueprint.NamespaceHandlerRegisterer: Registered blueprint namespace handler for http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd 
15/09/25 15:26:00 INFO blueprint.NamespaceHandlerRegisterer: Registered blueprint namespace handler for http://www.w3.org/2000/09/xmldsig# 
15/09/25 15:26:00 INFO blueprint.NamespaceHandlerRegisterer: Registered blueprint namespace handler for http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702 
15/09/25 15:26:00 INFO rest.MyTestCase: ******************************************************************************** 
15/09/25 15:26:00 INFO rest.MyTestCase: Testing: testFile2QueueRouteBuilderWithMockEndpointExtension(com.somecompany.someapp.rest.MyTestCase) 
15/09/25 15:26:00 INFO rest.MyTestCase: ******************************************************************************** 
15/09/25 15:26:00 INFO container.BlueprintContainerImpl: Bundle MyTestCase is waiting for namespace handlers [http://camel.apache.org/schema/cxf] 
15/09/25 15:26:30 WARN blueprint.CamelBlueprintHelper: Test bundle headers: Bundle-ManifestVersion=2, Bundle-Name=System Bundle, Bundle-SymbolicName=de.kalpatec.pojosr.framework, Bundle-Vendor=kalpatec, Bundle-Version=0.2.1 
15/09/25 15:26:30 WARN blueprint.CamelBlueprintHelper: ServiceReference: [org.codehaus.stax2.osgi.Stax2ValidationSchemaFactoryProvider], bundle: woodstox-core-asl [106], symbolicName: woodstox-core-asl 
15/09/25 15:26:30 WARN blueprint.CamelBlueprintHelper: ServiceReference: [org.codehaus.stax2.osgi.Stax2InputFactoryProvider], bundle: woodstox-core-asl [106], symbolicName: woodstox-core-asl 
... <cut stuff out to fit in stackoverflow post> ...  
15/09/25 15:26:30 WARN blueprint.CamelBlueprintHelper: ServiceReference: [org.apache.camel.spi.ComponentResolver], bundle: org.apache.camel.camel-http [59], symbolicName: org.apache.camel.camel-http 
15/09/25 15:26:30 WARN blueprint.CamelBlueprintHelper: ServiceReference: [org.apache.aries.blueprint.NamespaceHandler], bundle: org.apache.cxf.cxf-core [67], symbolicName: org.apache.cxf.cxf-core 
15/09/25 15:26:30 WARN blueprint.CamelBlueprintHelper: ServiceReference: [org.apache.camel.spi.ComponentResolver], bundle: org.apache.camel.camel-servlet [6], symbolicName: org.apache.camel.camel-servlet 
15/09/25 15:26:30 WARN blueprint.CamelBlueprintHelper: ServiceReference: [org.apache.camel.spi.ComponentResolver], bundle: org.apache.activemq.activemq-camel [21], symbolicName: org.apache.activemq.activemq-camel 
15/09/25 15:26:30 WARN blueprint.CamelBlueprintHelper: ServiceReference: [org.osgi.service.cm.ManagedService], bundle: org.apache.cxf.cxf-rt-transports-http [68], symbolicName: org.apache.cxf.cxf-rt-transports-http 
15/09/25 15:26:30 WARN blueprint.CamelBlueprintHelper: ServiceReference: [org.osgi.service.blueprint.container.BlueprintContainer], bundle: org.apache.camel.camel-cxf-transport [15], symbolicName: org.apache.camel.camel-cxf-transport 
15/09/25 15:26:30 WARN blueprint.CamelBlueprintHelper: ServiceReference: [org.apache.aries.blueprint.NamespaceHandler], bundle: org.apache.cxf.cxf-rt-rs-client [76], symbolicName: org.apache.cxf.cxf-rt-rs-client 
15/09/25 15:26:30 INFO rest.MyTestCase: ******************************************************************************** 
15/09/25 15:26:30 INFO rest.MyTestCase: Testing done: testFile2QueueRouteBuilderWithMockEndpointExtension(com.somecompany.someapp.rest.MyTestCase) 
15/09/25 15:26:30 INFO rest.MyTestCase: Took: 31.460 seconds (31460 millis) 
15/09/25 15:26:30 INFO rest.MyTestCase: ******************************************************************************** 
15/09/25 15:26:30 INFO container.BlueprintExtender: Destroying BlueprintContainer for bundle MyTestCase 
15/09/25 15:26:30 INFO osgi.CXFActivator: Removing the extensions for bundle 68 
15/09/25 15:26:30 INFO osgi.CXFActivator: Removing the extensions for bundle 8 
15/09/25 15:26:30 INFO osgi.CXFActivator: Removing the extensions for bundle 73 
15/09/25 15:26:30 INFO osgi.CXFActivator: Removing the extensions for bundle 75 
15/09/25 15:26:30 INFO osgi.CXFActivator: Removing the extensions for bundle 108 
15/09/25 15:26:30 INFO osgi.CXFActivator: Removing the extensions for bundle 77 
15/09/25 15:26:30 INFO osgi.CXFActivator: Removing the extensions for bundle 15 
15/09/25 15:26:30 INFO osgi.CXFActivator: Removing the extensions for bundle 17 
15/09/25 15:26:30 INFO osgi.CXFActivator: Removing the extensions for bundle 20 
15/09/25 15:26:30 INFO container.BlueprintExtender: Destroying BlueprintContainer for bundle org.apache.aries.blueprint 
15/09/25 15:26:30 INFO container.BlueprintExtender: Destroying BlueprintContainer for bundle org.apache.cxf.cxf-rt-features-clustering 
15/09/25 15:26:30 INFO container.BlueprintExtender: Destroying BlueprintContainer for bundle org.apache.camel.camel-cxf-transport 
15/09/25 15:26:30 INFO container.BlueprintExtender: Destroying BlueprintContainer for bundle org.apache.camel.camel-cxf 
15/09/25 15:26:30 INFO container.BlueprintExtender: Destroying BlueprintContainer for bundle org.apache.camel.camel-blueprint 
15/09/25 15:26:30 INFO osgi.Activator: Camel activator stopping 
15/09/25 15:26:30 INFO osgi.Activator: Camel activator stopped 
15/09/25 15:26:30 INFO blueprint.CamelBlueprintHelper: Deleting work directory target/bundles/1443187558935 

回答

1

似乎問題不在於IntelliJ無法在由OSGI藍圖定義的駝峯上下文上運行測試,而是在藍圖XML和我的依賴項中發生了一系列問題。

我我的藍圖XML更新爲:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:camel="http://camel.apache.org/schema/blueprint" 
      xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf" 
      xsi:schemaLocation=" 
      http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd 
      http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd"> 

    <!-- Defined the real JAXRS back end service --> 
    <cxf:rsServer id="lookUpService" 
      address="http://localhost:8083/" 
      serviceClass="com.somecompany.someapp.MyEndpoint"> 
    </cxf:rsServer> 

    <bean id="routBuilder" class="com.somecompany.someapp.SomeRoute"/> 

    <camel:camelContext id="someapp"> 
     <camel:routeBuilder ref="routBuilder"/> 
    </camel:camelContext> 

</blueprint> 

和modfied我的一些相關性:

compile 'dk.sosi.seal:seal:2.2.6' 
compile 'org.apache.cxf:cxf-rt-transports-http-jetty:3.1.3' 
compile 'org.apache.camel:camel-core:2.15.1' 
compile 'org.apache.camel:camel-blueprint:2.15.1' 
compile 'org.apache.camel:camel-jms:2.15.1' 
compile ('org.apache.camel:camel-cxf:2.15.1') { 
    exclude group: 'asm', module: 'asm' 
} 
compile 'org.apache.camel:camel-http:2.15.1' 
compile 'org.ow2.asm:asm-all:4.0' 
compile ('org.apache.activemq:apache-activemq:5.11.0') { 
    exclude group: 'org.apache.activemq', module: 'activemq-leveldb-store' 
} 
compile 'org.slf4j:slf4j-log4j12:1.7.10' 
compile 'commons-io:commons-io:2.4' 

testCompile 'junit:junit:4.12' 
testCompile 'org.apache.camel:camel-test-blueprint:2.15.1' 
testCompile 'org.apache.camel:camel-test:2.15.1' 

尤其排除從CXF ASM的錯誤版本(3.3.1),幷包括4.0版本幫助。 (感謝Dennis Bohnstedt Hansen)。

1

難道是你在類路徑中缺少snappy-java,你需要將它添加爲一個依賴在你的pom.xml中註冊?在這裏看到類似的問題。 http://crunchify.com/how-to-fix-java-lang-unsatisfiedlinkerror-no-snappyjava-in-java-library-path-error/

+0

我試過了,但它似乎已經包含在activemq的依賴中。 試圖註釋掉我的activemq依賴關係,導致問題消失(由另一個取代)。想要在某些時候包含activemq。 –

+0

你可以在沒有osgi部署的情況下將它作爲本地駱駝上下文嗎? –

+0

我從我的IntelliJ IDEA運行它。所以這是沒有osgi部署,對吧? –