当我尝试从我的蓝图xml配置文件创建Camel上下文时,我的camel测试无法启动。似乎缺少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
答案 0 :(得分:1)
答案 1 :(得分: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>
并修改了我的一些依赖项:
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)。