You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by rwoolf <ro...@rosswoolf.com> on 2015/12/10 22:45:27 UTC
Jetty in route not working as expected
I have created a very simple route that uses Jetty to try to learn how to use
it. I am trying this in servicemix 6.0.1 My camel context is defined in
blueprint. The jetty server instance starts, but I always get 404 error
when trying to call anything.
In my browser I make a make a request to: http://localhost/test?id=2.
I would expect to get my ID of 2 to be output to the logs, and then the
response to the browser be the text "Hello World"
But nothing happens in Camel, the route is never called. What I get back in
the browser is:
HTTP ERROR: 404
Problem accessing /test. Reason:
Not Found
Powered by Jetty://
Am I missing something simple? Do I not understand the use of Jetty
correctly? Any help appreciated.
Here is my simple blueprint/camel context
<?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">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="jetty:http//localhost/test"/>
<log message="${in.header.id}"/>
<setBody>
<constant>Hello World</constant>
</setBody>
</route>
</camelContext>
</blueprint>
--
View this message in context: http://camel.465427.n5.nabble.com/Jetty-in-route-not-working-as-expected-tp5774970.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Jetty in route not working as expected
Posted by rwoolf <ro...@rosswoolf.com>.
I'm convinced that there is a bug here. I can't get jetty to open up any
port but 80 in a route, and I always get the error in my browser as stated
when I try to access it. I made the change to use the port 8888 as in your
example (<from uri="jetty:http//localhost:8888/test"/>). Prior to dropping
the blueprint file into the deploy directory I did an nmap, which shows
neither port 80 or 8888 are open.
PORT STATE SERVICE
22/tcp open ssh
53/tcp open domain
631/tcp open ipp
1099/tcp open unknown
3306/tcp open mysql
8181/tcp open unknown
After the blueprint is deployed it now shows port 80 is open (even though I
told it I wanted to use 8888).
PORT STATE SERVICE
22/tcp open ssh
53/tcp open domain
*80/tcp open http*
631/tcp open ipp
1099/tcp open unknown
3306/tcp open mysql
8181/tcp open unknown
And the logs are even more interesting as it says:
*Using default Jetty continuation timeout for:
Endpoint[http//localhost:8888/test]*
and then
*Started SelectChannelConnector@0.0.0.0:80*
and then
*Route: route1 started and consuming from:
Endpoint[http//localhost:8888/test]*
So it can be seen that it knows it should use 8888, but starts up the
channel connector on 80, and in the end none of it works right.
I even tried specifically configuring as <from
uri="jetty:http//localhost:80/test"/> to see if it would start working but I
still get the error when trying to access the url in my browser.
See log info in context below.
2015-12-11 10:29:17,180 | INFO | FelixStartLevel | JettyHttpComponent
| 330 - org.apache.camel.camel-jetty-common - 2.15.3 | Using default Jetty
continuation timeout for: Endpoint[http//localhost:8888/test]
2015-12-11 10:29:17,182 | INFO | FelixStartLevel | Server
| 50 - org.eclipse.jetty.aggregate.jetty-all-server - 8.1.17.v20150415 |
jetty-8.1.17.v20150415
2015-12-11 10:29:17,186 | INFO | FelixStartLevel | AbstractConnector
| 50 - org.eclipse.jetty.aggregate.jetty-all-server - 8.1.17.v20150415 |
Started SelectChannelConnector@0.0.0.0:80
2015-12-11 10:29:17,189 | INFO | FelixStartLevel | BlueprintCamelContext
| 134 - org.apache.camel.camel-core - 2.15.3 | Route: route1 started and
consuming from: Endpoint[http//localhost:8888/test]
2015-12-11 10:29:17,191 | INFO | FelixStartLevel | BlueprintCamelContext
| 134 - org.apache.camel.camel-core - 2.15.3 | Total 1 routes, of which 1 is
started.
2015-12-11 10:29:17,193 | INFO | FelixStartLevel | BlueprintCamelContext
| 134 - org.apache.camel.camel-core - 2.15.3 | Apache Camel 2.15.3
(CamelContext: camel-1) started in 0.374 seconds
--
View this message in context: http://camel.465427.n5.nabble.com/Jetty-in-route-not-working-as-expected-tp5774970p5775009.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Jetty in route not working as expected
Posted by Claus Ibsen <cl...@gmail.com>.
Make sure to type it correct, eg a colon was missing, and maybe avoid
using port 80, if that is not free on your computer
<from uri="jetty:http://localhost:8888/test"/>
And use 0.0.0.0 instead of localhost if it should be reachable from
outside the localhost.
On Thu, Dec 10, 2015 at 10:45 PM, rwoolf <ro...@rosswoolf.com> wrote:
> I have created a very simple route that uses Jetty to try to learn how to use
> it. I am trying this in servicemix 6.0.1 My camel context is defined in
> blueprint. The jetty server instance starts, but I always get 404 error
> when trying to call anything.
>
> In my browser I make a make a request to: http://localhost/test?id=2.
>
> I would expect to get my ID of 2 to be output to the logs, and then the
> response to the browser be the text "Hello World"
>
> But nothing happens in Camel, the route is never called. What I get back in
> the browser is:
> HTTP ERROR: 404
> Problem accessing /test. Reason:
> Not Found
> Powered by Jetty://
>
> Am I missing something simple? Do I not understand the use of Jetty
> correctly? Any help appreciated.
>
> Here is my simple blueprint/camel context
>
> <?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">
>
> <camelContext xmlns="http://camel.apache.org/schema/blueprint">
> <route>
> <from uri="jetty:http//localhost/test"/>
> <log message="${in.header.id}"/>
> <setBody>
> <constant>Hello World</constant>
> </setBody>
> </route>
> </camelContext>
> </blueprint>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Jetty-in-route-not-working-as-expected-tp5774970.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2