Apache Camel 2.15.2 not able to create jetty insta

2019-07-26 05:08发布

问题:

When I was using 2.14 version of camel, I was able to get jetty instance created... however 2.15.2 is giving below error while tomcat loads the app

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jetty' defined in ServletContext resource [/WEB-INF/classes/camel-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.camel.component.jetty.JettyHttpComponent]: Is it an abstract class?; nested exception is java.lang.InstantiationException

Here is how my camel context config looks like

bean id="jetty" class="org.apache.camel.component.jetty.JettyHttpComponent"

回答1:

Camel hasn't updated their version of Jetty in a very long time.

The official documentation at camel.apache.org/jetty.html has references to codehaus.org (a website that no longer exists!)

The apidoc references at camel.apache.org/maven/camel-2.14.0/camel-jetty/apidocs/org/apache/camel/component/jetty/JettyHttpComponent.html have references to org.eclipse.jetty.server.nio.SelectChannelConnector which means they are using Jetty 7 or Jetty 8.

Both Jetty 7 and Jetty 8 are EOL (End of Life).

But all is not lost ...

Starting with Camel 2.15.0 there is support for Jetty 9.

  • Support for Jetty 9 using the new camel-component-jetty9 module

Would recommend upgrading Camel.



回答2:

Since Camel 2.15, Jetty component has been dispatched in two components camel-jetty8 and camel-jetty9. camel-jetty, only contains an abstract class that you cannot instantiate.

After importing camel-jetty8 or camel-jetty9, you can simply replace your line:

bean id="jetty" class="org.apache.camel.component.jetty.JettyHttpComponent"

by

bean id="jetty" class="org.apache.camel.component.jetty8.JettyHttpComponent8"

or

bean id="jetty" class="org.apache.camel.component.jetty9.JettyHttpComponent9"