My camel test fails to start when I try to create the Camel context from my blueprint xml config file. Seems to be missing a snappyjava.dll.
Does anyone have experience with this type of issue?
I am running my test using gradle 2.6 and Java 1.8.0_60 on a windows 8.1 platform.
My blueprint xml looks like this:
<?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>
My dependencies in the gradle project are:
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'
and I get the following output on standard err when running the test:
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
Could it be that you are missing snappy-java in your classpath and you need it add as a dependency in your pom.xml? See here for similar issue.
http://crunchify.com/how-to-fix-java-lang-unsatisfiedlinkerror-no-snappyjava-in-java-library-path-error/
It seems that the issue was not the inability of IntelliJ to running tests on a camel context defined by an OSGI blueprint, but rather a series of issues in the blueprint XML and in my dependencies.
I updated my blueprint XML to:
<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>
and modfied some of my dependencies:
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'
Especially excluding the wrong version (3.3.1) of ASM from CXF and including version 4.0 helped. (Thanks to Dennis Bohnstedt Hansen).
Related
I'm working on a simple "hello-world" Camel3 (Camel version 3.4.3) REST API example with the following setup:
REST API is described in OpenAPI specification (Swagger v2.0)
The API spec is converted to Java DSL with camel-restdsl-swagger-plugin
Using Camel Main
100% Java (i.e. no XML)
The example below works as expected but I fail to set jetty port. Therefore on every run the web server runs on a random port. How do I set the port (e.g. to 8081) in the Java code ? It also seems to be possible to set the port in application.properties file. Example of that option is also appreciated.
// https://camel.apache.org/components/latest/others/main.html
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.main.Main;
import org.apache.camel.main.RestConfigurationProperties;
import rest.dsl.generated.Api101;
public class App {
public static void main(String[] args) throws Exception {
Main main = new Main();
// How do I set the rest properties ?
// The code below doesn't seem to have effect.
RestConfigurationProperties p = main.configure().rest()
.withComponent("jetty")
.withHost("localhost")
.withPort(8081)
;
main.configure().addConfiguration(p);
// The route generated by camel-restdsl-swagger-plugin
main.configure().addRoutesBuilder(
new Api101()
);
// The actual route.
main.configure().addRoutesBuilder(
new RouteBuilder() {
public void configure() {
from("direct:rest1")
.routeId("Rest1Route")
.log("START:")
.setBody(constant("{hello: \"Hello, World!\"}"))
.log("END:")
;
}
}
);
main.run(args);
}
}
Generated Api101 code:
package rest.dsl.generated;
import javax.annotation.Generated;
import org.apache.camel.builder.RouteBuilder;
/**
* Generated from Swagger specification by Camel REST DSL generator.
*/
#Generated("org.apache.camel.generator.swagger.PathGenerator")
public final class Api101 extends RouteBuilder {
/**
* Defines Apache Camel routes using REST DSL fluent API.
*/
public void configure() {
rest("/api101")
.get("/hello")
.description("Basic Hello World")
.to("direct:rest1");
}
}
Compilation & run example:
/tmp/openapi$ mvn clean compile exec:java
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.stackoverflow:openapi >----------------------
[INFO] Building openapi 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # openapi ---
[INFO] Deleting /tmp/openapi/target
[INFO]
[INFO] --- camel-restdsl-swagger-plugin:3.4.3:generate-with-dto (default) # openapi ---
[INFO] reading from /tmp/openapi/swagger.yaml
[INFO] Generating Camel DSL source in directory: /tmp/openapi/target/generated-sources/restdsl-swagger
[INFO] Generating DTO classes using io.swagger:swagger-codegen-maven-plugin:2.4.12
[INFO] reading from /tmp/openapi/swagger.yaml
[WARNING] Output directory does not exist, or is inaccessible. No file (.swagger-codegen-ignore) will be evaluated.
[WARNING] 'host' not defined in the spec. Default to 'localhost'.
[INFO] writing file /tmp/openapi/target/generated-sources/swagger/src/main/java/io/swagger/client/model/InlineResponse200.java
[WARNING] 'host' not defined in the spec. Default to 'localhost'.
[INFO]
[INFO] --- build-helper-maven-plugin:3.2.0:add-source (default) # openapi ---
[INFO] Source directory: /tmp/openapi/target/generated-sources/restdsl-swagger added.
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # openapi ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # openapi ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /tmp/openapi/target/classes
[INFO]
[INFO] --- exec-maven-plugin:3.0.0:java (default-cli) # openapi ---
[ App.main()] BaseMainSupport INFO Using properties from: classpath:application.properties;optional=true
[ App.main()] DefaultRoutesCollector INFO No additional Camel XML routes discovered from: classpath:camel/*.xml
[ App.main()] DefaultRoutesCollector INFO No additional Camel XML rests discovered from: classpath:camel-rest/*.xml
[ App.main()] AbstractCamelContext INFO Apache Camel 3.4.3 (camel-1) is starting
[ App.main()] AbstractCamelContext INFO StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
[ App.main()] JettyHttpComponent WARN JMX disabled in CamelContext. Jetty JMX extensions will remain disabled.
[ App.main()] log INFO Logging initialized #8774ms to org.eclipse.jetty.util.log.Slf4jLog
[ App.main()] Server INFO jetty-9.4.29.v20200521; built: 2020-05-21T17:20:40.598Z; git: 77c232aed8a45c818fd27232278d9f95a021095e; jvm 11.0.8+10-post-Ubuntu-0ubuntu120.04
[ App.main()] ContextHandler INFO Started o.e.j.s.ServletContextHandler#4d9f9a55{/,null,AVAILABLE}
[ App.main()] AbstractConnector INFO Started ServerConnector#157aa401{HTTP/1.1, (http/1.1)}{0.0.0.0:44267}
[ App.main()] Server INFO Started #8938ms
[ App.main()] InternalRouteStartupManager INFO Route: route1 started and consuming from: jetty:http://0.0.0.0:0/api101/hello
[ App.main()] InternalRouteStartupManager INFO Route: Rest1Route started and consuming from: direct://rest1
[ App.main()] AbstractCamelContext INFO Total 2 routes, of which 2 are started
[ App.main()] AbstractCamelContext INFO Apache Camel 3.4.3 (camel-1) started in 0.225 seconds
[ qtp1580225589-17] Rest1Route INFO START:
[ qtp1580225589-17] Rest1Route INFO END:
^C[ad #0 - CamelHangupInterceptor] DefaultMainShutdownStrategy INFO Received hang up - stopping the main instance.
[ App.main()] AbstractCamelContext INFO Apache Camel 3.4.3 (camel-1) is shutting down
[ad #0 - CamelHangupInterceptor] DefaultMainShutdownStrategy INFO Waiting for CamelContext to graceful shutdown, elapsed: 0.000 seconds
[ App.main()] DefaultShutdownStrategy INFO Starting to graceful shutdown 2 routes (timeout 45 seconds)
[el-1) thread #1 - ShutdownTask] DefaultShutdownStrategy INFO Route: Rest1Route shutdown complete, was consuming from: direct://rest1
[el-1) thread #1 - ShutdownTask] AbstractConnector INFO Stopped ServerConnector#157aa401{HTTP/1.1, (http/1.1)}{0.0.0.0:0}
[el-1) thread #1 - ShutdownTask] ContextHandler INFO Stopped o.e.j.s.ServletContextHandler#4d9f9a55{/,null,UNAVAILABLE}
[el-1) thread #1 - ShutdownTask] DefaultShutdownStrategy INFO Route: route1 shutdown complete, was consuming from: rest://get:/api101:/hello
[ App.main()] DefaultShutdownStrategy INFO Graceful shutdown of 2 routes completed in 0 seconds
[ App.main()] MainLifecycleStrategy INFO CamelContext: camel-1 has been shutdown, triggering shutdown of the JVM.
[ App.main()] AbstractCamelContext INFO Apache Camel 3.4.3 (camel-1) uptime 44.386 seconds
[ App.main()] AbstractCamelContext INFO Apache Camel 3.4.3 (camel-1) is shutdown in 0.037 seconds
/tmp/openapi$
As you can see from the above the web server is available in port 44267:
Started ServerConnector#157aa401{HTTP/1.1, (http/1.1)}{0.0.0.0:44267}
And can be successfully accessed:
$ sudo netstat -tulpn | grep /java
tcp6 0 0 :::44267 :::* LISTEN 16926/java
$ curl http://0.0.0.0:44267/api101/hello
{hello: "Hello, World!"}
$
I found an answer to my secondary question: this is the way to define the port with the properties:
$ cat src/main/resources/application.properties
camel.rest.port=8081
$
This is also the method how to set all the other configuration options mention in the documentation. Might be obvious for Java veterans, but it was not obvious for me.
I have two standalone modules that use Camel's Main. Both of them contain:
main.setPropertyPlaceholderLocations( "classpath:application.properties" );
and I also tried:
main.setPropertyPlaceholderLocations( "application.properties" );
If I run them from within Eclipse both work fine (having added <project>/target to the Run Configurations' Classpath).
If I run them from the cmd line:
...\target> java -jar <module>.jar
with target containing both application.properties and <module>.jar, one works fine. The other results in:
Exception in thread "main" org.apache.camel.RuntimeCamelException: java.io.FileNotFoundException:
Properties file application.properties not found in classpath
I've seen Q: Camel properties file not found in class path but my application.properties is in src/main/resources, and copied to target during mvn package.
UPDATE 1
For clarification. In my projects' POMs I use:
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>application.properties</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>application.properties</include>
</includes>
<targetPath>..</targetPath> <!-- relative to target/classes -->
</resource>
<resources>
to prevent application.properties residing inside <module>.jar.
UPDATE 2
90 [main] INFO <module> - Starting Camel...
182 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.22.0 (CamelContext: camel-1) is shutting down
195 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.22.0 (CamelContext: camel-1) uptime
198 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.22.0 (CamelContext: camel-1) is shutdown in 0.017 seconds
Exception in thread "main" org.apache.camel.RuntimeCamelException: java.io.FileNotFoundException: Properties file application.properties not found in classpath
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1830)
at org.apache.camel.model.RouteDefinitionHelper.initRouteInputs(RouteDefinitionHelper.java:382)
at org.apache.camel.model.RouteDefinitionHelper.prepareRouteImp(RouteDefinitionHelper.java:298)
at org.apache.camel.model.RouteDefinitionHelper.prepareRoute(RouteDefinitionHelper.java:270)
at org.apache.camel.model.RoutesDefinition.route(RoutesDefinition.java:205)
at org.apache.camel.model.RoutesDefinition.from(RoutesDefinition.java:158)
at org.apache.camel.builder.RouteBuilder.from(RouteBuilder.java:169)
at <module>Route.configure(<module>Route.java:24)
at org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:462)
at org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:402)
at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:383)
at org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:1029)
at org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:1026)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3272)
at org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:1026)
at org.apache.camel.main.MainSupport.postProcessCamelContext(MainSupport.java:612)
at org.apache.camel.main.MainSupport.postProcessContext(MainSupport.java:550)
at org.apache.camel.main.Main.doStart(Main.java:136)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.main.MainSupport.run(MainSupport.java:170)
at <module>.run(<module>.java:44)
at <module>.main(<module>.java:20)
Caused by: java.io.FileNotFoundException: Properties file application.properties not found in classpath
at org.apache.camel.component.properties.DefaultPropertiesResolver.loadPropertiesFromClasspath(DefaultPropertiesResolver.java:112)
at org.apache.camel.component.properties.DefaultPropertiesResolver.resolveProperties(DefaultPropertiesResolver.java:69)
at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:207)
at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:178)
at org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:2552)
at org.apache.camel.model.ProcessorDefinitionHelper.resolvePropertyPlaceholders(ProcessorDefinitionHelper.java:735)
at org.apache.camel.model.RouteDefinitionHelper.initRouteInputs(RouteDefinitionHelper.java:380)
... 20 more
204 [Camel Thread #0 - CamelHangupInterceptor] INFO org.apache.camel.main.MainSupport$HangupInterceptor - Received hang up - stopping the main instance.
Now I know why one module ran while the other didn't. Apparently Camel performs lazy loading after setPropertyPlaceholderLocations() and since I didn't use any property of application.properties (yet) it didn't even try to read the file.
Now that I'm using them the previously working module fails as well. (One of the rare cases where an error leads to truth. ;)
The solution is to use:
String jarPath = new File(
this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI().getPath() )
.getParent();
main.setPropertyPlaceholderLocations("file:" + jarPath + "/application.properties" )
as commented by Claus a few hours ago, rather than:
main.setPropertyPlaceholderLocations("classpath:...")
I have a unit test in Camel for testing a simple route from a file to a JMS queue.
The route looks like this:
public class File2QueueRouteBuilder extends RouteBuilder {
#Override
public void configure() throws Exception {
from("file:src/data/").to("jms:demo_queue");
}
}
I Test the route by generating a file with a producer template and getting the message from the queue by adding a route from the JMS queue to a mock endpoint. I inject seda as the JMS component in the camel context to avoid depending on activeMQ for unittest.
The test code looks like this:
public class CamelRiderTest extends CamelTestSupport {
#Override
protected CamelContext createCamelContext() throws Exception {
CamelContext context = super.createCamelContext();
// use a simple in memory JMS implementation in stead of ActiveMQ as in the production code.
context.addComponent("jms", context.getComponent("seda"));
return context;
}
#Override
protected RouteBuilder createRouteBuilder() throws Exception {
// Get the production route to test.
RouteBuilder toTest = new File2QueueRouteBuilder();
// Add a test route that reads the message from the queue to a mock
toTest.includeRoutes(new RouteBuilder() {
#Override
public void configure() throws Exception {
from("jms:demo_queue").to("mock:demo_queue");
}
});
return toTest;
}
#Test
public void testFile2QueueRouteBuilder() throws InterruptedException {
// Get the mock endpoint for verification
MockEndpoint demoQueueOutput = getMockEndpoint("mock:demo_queue");
// Set the expected result
demoQueueOutput.expectedMessageCount(2); // Assert that two messages are received.
demoQueueOutput.setAssertPeriod(1000); // Asserts after 1000 millis that no more than 2 messages were received
demoQueueOutput.allMessages().body().contains("Hello"); // Assert contents of messages
// Use a template producer to create an input file containing "Hello world"
template.sendBodyAndHeader("file://src/data", "Hello camel", Exchange.FILE_NAME, "hello1.txt");
template.sendBodyAndHeader("file://src/data", "Hello again", Exchange.FILE_NAME, "hello2.txt");
// Wait for the route to process input
Thread.sleep(1000);
// Assert mock endpoint expected result.
demoQueueOutput.assertIsSatisfied();
}
}
The messages seem to come through as expected but i get the following error when trying to validate the contents:
15/07/29 09:38:18 INFO demo.CamelRiderTest: ********************************************************************************
15/07/29 09:38:18 INFO demo.CamelRiderTest: Testing: testFile2QueueRouteBuilder(dk.systematic.cura.demo.CamelRiderTest)
15/07/29 09:38:18 INFO demo.CamelRiderTest: ********************************************************************************
15/07/29 09:38:18 INFO impl.DefaultCamelContext: Apache Camel 2.15.2 (CamelContext: camel-1) is starting
15/07/29 09:38:18 INFO management.DefaultManagementStrategy: JMX is disabled
15/07/29 09:38:18 INFO converter.DefaultTypeConverter: Loaded 186 type converters
15/07/29 09:38:18 INFO seda.SedaEndpoint: Endpoint Endpoint[jms://demo_queue] is using shared queue: jms://demo_queue with size: 2147483647
15/07/29 09:38:18 INFO impl.DefaultCamelContext: AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance.
15/07/29 09:38:18 INFO impl.DefaultCamelContext: StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
15/07/29 09:38:18 INFO impl.DefaultCamelContext: Route: route1 started and consuming from: Endpoint[jms://demo_queue]
15/07/29 09:38:18 INFO impl.DefaultCamelContext: Route: route2 started and consuming from: Endpoint[file://src/data/]
15/07/29 09:38:18 INFO impl.DefaultCamelContext: Total 2 routes, of which 2 is started.
15/07/29 09:38:18 INFO impl.DefaultCamelContext: Apache Camel 2.15.2 (CamelContext: camel-1) started in 0.137 seconds
15/07/29 09:38:19 INFO mock.MockEndpoint: Asserting: Endpoint[mock://demo_queue] is satisfied
15/07/29 09:38:19 INFO demo.CamelRiderTest: ********************************************************************************
15/07/29 09:38:19 INFO demo.CamelRiderTest: Testing done: testFile2QueueRouteBuilder(dk.systematic.cura.demo.CamelRiderTest)
15/07/29 09:38:19 INFO demo.CamelRiderTest: Took: 1.056 seconds (1056 millis)
15/07/29 09:38:19 INFO demo.CamelRiderTest: ********************************************************************************
15/07/29 09:38:19 INFO impl.DefaultCamelContext: Apache Camel 2.15.2 (CamelContext: camel-1) is shutting down
15/07/29 09:38:19 INFO impl.DefaultShutdownStrategy: Starting to graceful shutdown 2 routes (timeout 10 seconds)
15/07/29 09:38:20 INFO impl.DefaultShutdownStrategy: Route: route2 shutdown complete, was consuming from: Endpoint[file://src/data/]
15/07/29 09:38:20 INFO impl.DefaultShutdownStrategy: Route: route1 shutdown complete, was consuming from: Endpoint[jms://demo_queue]
15/07/29 09:38:20 INFO impl.DefaultShutdownStrategy: Graceful shutdown of 2 routes completed in 0 seconds
15/07/29 09:38:20 INFO impl.DefaultCamelContext: Apache Camel 2.15.2 (CamelContext: camel-1) uptime 2.202 seconds
15/07/29 09:38:20 INFO impl.DefaultCamelContext: Apache Camel 2.15.2 (CamelContext: camel-1) is shutdown in 1.006 seconds
Assertion error at index 0 on mock mock://demo_queue with predicate: Simple: body contains Hello evaluated as: GenericFile[hello1.txt] contains Hello on Exchange[hello1.txt]
java.lang.AssertionError: Assertion error at index 0 on mock mock://demo_queue with predicate: Simple: body contains Hello evaluated as: GenericFile[hello1.txt] contains Hello on Exchange[hello1.txt]
at org.apache.camel.util.PredicateAssertHelper.assertMatches(PredicateAssertHelper.java:43)
at org.apache.camel.component.mock.AssertionClause.applyAssertionOn(AssertionClause.java:106)
at org.apache.camel.component.mock.MockEndpoint$18.run(MockEndpoint.java:976)
at org.apache.camel.component.mock.MockEndpoint.doAssertIsSatisfied(MockEndpoint.java:410)
at org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:378)
at org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:366)
at dk.systematic.cura.demo.CamelRiderTest.testFile2QueueRouteBuilder(CamelRiderTest.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Looks like I don't get the contents of the read file from the queue, but something else. What am I doing wrong?
I am running on windows 7 with java 1.7 (64 bit) and Camel 2.15.2
Camel File produces a GenericFile-Object as body of the exchange.
In your Unit-Test you expected a String. Change your route to:
from("file:src/data/").convertBodyTo(String.class).to("jms:demo_queue");
I am using Apache Solr on my drupal website.
Tomcat 6 is installed and I have replaced schema.xml, solr-config.xml and protwords.txt files with the new files which was present in module installation directory.
When I run localhost:8983, I get this error.
Log4j (org.slf4j.impl.Log4jLoggerFactory)
2528 [coreLoadExecutor-3-thread-1] ERROR org.apache.solr.core.CoreContainer – Failed to load file /opt/solr-4.5.1/example/solr/collection1/conf/solrconfig.xml
2529 [coreLoadExecutor-3-thread-1] ERROR org.apache.solr.core.CoreContainer – Unable to create core: egitraining-dev.esc.rl.ac.uk
org.apache.solr.common.SolrException: Could not load config file /opt/solr-4.5.1/example/solr/collection1/conf/solrconfig.xml
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:490)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:557)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:247)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:239)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.io.IOException: Can't find resource 'solrconfig.xml' in classpath or 'solr/collection1/conf/conf/', cwd=/opt/solr-4.5.1/example
at org.apache.solr.core.SolrResourceLoader.openResource(SolrResourceLoader.java:322)
at org.apache.solr.core.SolrResourceLoader.openConfig(SolrResourceLoader.java:287)
at org.apache.solr.core.Config.<init>(Config.java:116)
at org.apache.solr.core.Config.<init>(Config.java:86)
at org.apache.solr.core.SolrConfig.<init>(SolrConfig.java:129)
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:487)
... 11 more
2531 [coreLoadExecutor-3-thread-1] ERROR org.apache.solr.core.CoreContainer – null:org.apache.solr.common.SolrException: Unable to create core: egitraining-dev.esc.rl.ac.uk
at org.apache.solr.core.CoreContainer.recordAndThrow(CoreContainer.java:934)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:566)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:247)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:239)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
Caused by: org.apache.solr.common.SolrException: Could not load config file /opt/solr-4.5.1/example/solr/collection1/conf/solrconfig.xml
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:490)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:557)
... 10 more
Caused by: java.io.IOException: Can't find resource 'solrconfig.xml' in classpath or 'solr/collection1/conf/conf/', cwd=/opt/solr-4.5.1/example
at org.apache.solr.core.SolrResourceLoader.openResource(SolrResourceLoader.java:322)
at org.apache.solr.core.SolrResourceLoader.openConfig(SolrResourceLoader.java:287)
at org.apache.solr.core.Config.<init>(Config.java:116)
at org.apache.solr.core.Config.<init>(Config.java:86)
at org.apache.solr.core.SolrConfig.<init>(SolrConfig.java:129)
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:487)
... 11 more
2533 [main] INFO org.apache.solr.servlet.SolrDispatchFilter – user.dir=/opt/solr-4.5.1/example
2533 [main] INFO org.apache.solr.servlet.SolrDispatchFilter – SolrDispatchFilter.init() done
2576 [main] INFO org.eclipse.jetty.server.AbstractConnector – Started SocketConnector#0.0.0.0:8983
Can anyone help Please?
Thanks
This might have something to do with the default Solr config files provided by the Search API Solr module. Try to remove the next couple of lines from solrconfig.xml:
<useCompoundFile>false</useCompoundFile>
<ramBufferSizeMB>32</ramBufferSizeMB>
<mergeFactor>10</mergeFactor>
Patch found at https://drupal.org/comment/7945999#comment-7945999.
We are running standalone java application using apache camel. We've embedded haw.io in the application and everything seems to be working.
When we add a dependency on camel-http, hawtio will no longer start. Are these not compatible?
This is the exception we are getting:
2013-07-01 13:55:10,002 WARN [Thread-5] - HawtioLoader.run (HawtioLoader.java:35) - hawt.io failed to run
java.lang.SecurityException: class "javax.servlet.FilterRegistration"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:806) ~[?:1.6.0_51]
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:487) ~[?:1.6.0_51]
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:625) ~[?:1.6.0_51]
at java.lang.ClassLoader.defineClass(ClassLoader.java:615) ~[?:1.6.0_51]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) ~[?:1.6.0_51]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) ~[?:1.6.0_51]
at java.net.URLClassLoader.access$000(URLClassLoader.java:58) ~[?:1.6.0_51]
at java.net.URLClassLoader$1.run(URLClassLoader.java:197) ~[?:1.6.0_51]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.6.0_51]
at java.net.URLClassLoader.findClass(URLClassLoader.java:190) ~[?:1.6.0_51]
at java.lang.ClassLoader.loadClass(ClassLoader.java:306) ~[?:1.6.0_51]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) ~[?:1.6.0_51]
at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ~[?:1.6.0_51]
at org.eclipse.jetty.servlet.ServletContextHandler.<init>(ServletContextHandler.java:129) ~[jetty-webapp-8.1.3.v20120416.jar:8.1.3.v20120416]
at org.eclipse.jetty.servlet.ServletContextHandler.<init>(ServletContextHandler.java:109) ~[jetty-webapp-8.1.3.v20120416.jar:8.1.3.v20120416]
at org.eclipse.jetty.servlet.ServletContextHandler.<init>(ServletContextHandler.java:97) ~[jetty-webapp-8.1.3.v20120416.jar:8.1.3.v20120416]
at org.eclipse.jetty.webapp.WebAppContext.<init>(WebAppContext.java:171) ~[jetty-webapp-8.1.3.v20120416.jar:8.1.3.v20120416]
at io.hawt.embedded.Main.run(Main.java:56) ~[hawtio-embedded-1.1.jar:?]
at HawtioLoader.run(HawtioLoader.java:33) [classes/:?]
I think the problem is that both hawt.io and camel-http will include some javax-packages. From what I remember when I had this problem the solution was to look at the chained dependencies (in for example Eclipse) and find packages that are linked in from both. When you have found them (probably javax.servlet-something) exclude them from the camel-http dependency definition and your project will most likely work.
/S Laven