I am using Camel 2.16.2. I am using camel restlet(camel-restlet version 2.16.2) to define my web services.
restConfiguration().component("restlet")
.dataFormatProperty("prettyPrint", "true")
.host(propertiesConfig.getString("localhost"))
.port("8568");
and defined a web service:
rest("/")
.post("/myService")
.consumes("application/json")
.to("direct:myServiceRoute");
I am using maven-assembly-plugin to build a jar with all dependencies. It is running smoothly on IDE(I am using intellij) but whenever I am starting the application using the jar(by doing java -jar), I am getting the exception:
Exception in thread "main" org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: restlet://http://127.0.0.1:8568/myService?restletMethod=POST due to: Could not find a suitable setter for property: restletMethod as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.restlet.data.Method with value POST
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:590)
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:603)
at org.apache.camel.component.restlet.RestletComponent.createConsumer(RestletComponent.java:747)
at org.apache.camel.component.rest.RestEndpoint.createConsumer(RestEndpoint.java:309)
at org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:68)
at org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:98)
at org.apache.camel.impl.RouteService.warmUp(RouteService.java:158)
at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:3453)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3383)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3160)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3016)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2812)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2808)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2831)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2808)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2777)
at org.apache.camel.main.Main.doStart(Main.java:126)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.main.MainSupport.run(MainSupport.java:124)
Caused by: java.lang.IllegalArgumentException: Could not find a suitable setter for property: restletMethod as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.restlet.data.Method with value POST
at org.apache.camel.util.IntrospectionSupport.setProperty(IntrospectionSupport.java:574)
at org.apache.camel.util.IntrospectionSupport.setProperty(IntrospectionSupport.java:602)
at org.apache.camel.util.IntrospectionSupport.setProperties(IntrospectionSupport.java:459)
at org.apache.camel.util.IntrospectionSupport.setProperties(IntrospectionSupport.java:469)
at org.apache.camel.util.EndpointHelper.setProperties(EndpointHelper.java:256)
EDIT: /org/apache/camel/component/restlet/ and its classes(including RestletConverter are present in the jar.
As suggested by @Claus Ibsen, I replaced my assembly plugin code in pom with this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>org.jboss.seam:jboss-seam</exclude>
</excludes>
</artifactSet>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>org.sreejit.demo.main.SampleMain</Main-Class>
</manifestEntries>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/services/org/apache/camel/TypeConverter</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>META-INF/maven/plugin.xml</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>META-INF/spring.tooling</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>META-INF/info.xml</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>META-INF/DISCLAIMER</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>META-INF/README.txt</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>META-INF/DEPENDENCIES</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>META-INF/LICENSE</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>META-INF/LICENSE.txt</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>META-INF/NOTICE</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>META-INF/NOTICE.txt</resource>
</transformer>
</transformers>
<filters>
<!-- filter out jar signatures from shaded jars -->
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
And it worked..:)