Grokbase Groups Camel users May 2015
FAQ
I was originally testing out the Rest DSL and using Jetty as the server.
This works great and I'm a big fan. My next step was to try and get SSL
working with my test application. Based on the reading that I did, it looks
like I needed to add a jetty bean definition in blueprint.xml, and specify
the keystore, keystore password and key password. When I add the bean
definition for jetty, I'm getting the exception listed below. I have tried
a number of different troubleshooting attempts, but always get this
exception whenever I attempt to define the bean in blueprint xml (even
taking SSL completely out the equation). The exception, details of my
environment and the applicable snippets of code/config are below - I would
appreciate any help that could be provided!!

******* Environment Info: *******

Camel 2.15.2
camel-blueprint 2.15.2
camel-jetty 2.15.2

******* Exception: *******

org.osgi.service.blueprint.container.ComponentDefinitionException: Error
when instantiating bean jetty of class class
org.apache.camel.component.jetty.JettyHttpComponent
  at
org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:333)
  at
org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:806)
  at
org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)
  at
org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at
org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
  at
org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)
  at
org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)
  at
org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:668)
  at
org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:370)
  at
org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at
org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)
  at
org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
  at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
  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:745)
Caused by: java.lang.InstantiationException
  at
sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
  at
org.apache.aries.blueprint.utils.ReflectionUtils.newInstance(ReflectionUtils.java:329)
  at
org.apache.aries.blueprint.container.BeanRecipe.newInstance(BeanRecipe.java:962)
  at
org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:331)
  ... 21 more

******* blueprint.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"
        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
" rel="nofollow">http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">

     <bean id="jetty"
class="org.apache.camel.component.jetty.JettyHttpComponent">
         <property name="sslPassword" value="mypassword"/>
         <property name="sslKeyPassword" value="mypassword"/>
         <property name="keystore" value="/path/to/keystore"/>
     </bean>

   <bean id="restRouter" class="com.diversecomputing.RestRouter" />

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

</blueprint>

******* RouteBuilder: *******

public class RestRouter extends RouteBuilder {

     @Override
     public void configure() throws Exception {

         restConfiguration()
             .component("jetty")
             .host("localhost")
             .port("8082")
             //.scheme("https")
             .contextPath("rest")
             .bindingMode(RestBindingMode.auto)
             .dataFormatProperty("prettyPrint", "true");

         rest("/say")
             .get("/hello").to("direct:hello")
             .get("/bye").consumes("application/json").to("direct:bye")
             .post("/bye").to("mock:update");

         from("direct:hello")
             .transform().constant("Hello World");
         from("direct:bye")
             .transform().constant("Bye World");
     }
}



--
View this message in context: http://camel.465427.n5.nabble.com/Rest-DSL-with-jetty-and-SSL-tp5767572.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 4 | next ›
Discussion Overview
groupusers @
categoriescamel
postedMay 27, '15 at 8:48p
activeMay 31, '15 at 1:51a
posts4
users4
websitecamel.apache.org

People

Translate

site design / logo © 2021 Grokbase