See the rest examples that can help you on the way, such as https://github.com/apache/camel/tree/master/examples/camel-example-cdi-rest-servlet
Since you use JEE then you can use CDI to kick-start as that example does. Or you can kick-start using war http://camel.apache.org/tutorial-on-using-camel-in-a-web-application.html Or use the camel servletlistener http://camel.apache.org/servlet-tomcat-no-spring-example.html Q2 you configure this on the rest configuration, or if you use servlet component then on the servlet itself. Q3 see the json binding at http://camel.apache.org/rest-dsl and add camel-jackson to the classpath. On Sun, Feb 21, 2016 at 3:11 AM, zappee <arnold.somo...@gmail.com> wrote: > Hi, > > Currently I am learning how to use Apache Camel Rest and I would like to ask > some questions about it. I would greatly appreciate any answer. > > I have a rest camel route which is packed in a jar. This jar locates in an > ear file and deployed on GlassFish app. server. > *Q1:* I am not able to figure out how I can start/bootstrap this route. > > I want to use localhost:port/api/user/generate url for my route. It > generates a simple json answer based on my java pojo with getters/setters. > *Q2:* How to configure the base url of my route OR figure out the correct > path of my deployed route? > *Q3:* How I can send back a json response based on a java object (object is > automatically convert to json by camel on the fly)? Is my code correct (i am > not able to test my code till it is not bootstrapped)? > > My ear is deployed on server, stateless ejb service and web application are > working but my camel rest api is not available. > > *Structure of my ear:* > *.EAR > |-lib/ > | |- dependencies, ex.: camel jars > | |- my-common.jar > | |- my-camel-restapi.jar <- it contains my camel rest route > | > |- my-web-ui.war > |- my-stateless-ejb.jar > > > *Camel route java:* > public class UserServiceRouteBuilder extends RouteBuilder { > private static final String APPLICATION_JSON_UTF_8 = > "application/json;charset=UTF-8"; > > @Override > public void configure() throws Exception { > restConfiguration().component("jetty") > .bindingMode(RestBindingMode.json) > .dataFormatProperty("prettyPrint", "true"); > > User user = new User(); > user.setEmail("a...@gmail.com"); > user.setFirstName("John"); > user.setLastName("Connor"); > > rest("/user") > .description("user rest service") > .produces(APPLICATION_JSON_UTF_8) > > .get("/generate").route().routeId("GET@/generate").transform().constant(user).endRest(); > } > } > > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/camel-rest-route-tp5777992.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