I've built a project based on the Camel CXF (code first) Tomcat example where the CFX web service is defined by a java interface. In the example, the WS interface is IncidentService.java. In my project the service interface is called Ingester and defines an upload(String body, String id) method. The service deploys to tomcat and I call the service from a client in another project using this code:
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.setServiceClass(Ingester.class);
factory.setAddress(toURL);
Ingester client = (Ingester) factory.create();
String out = client.upload(exchange.getIn().getBody(String.class),"2");
The client project references the Ingester interface by importing the server project as a referenced project (in Eclipse).
It all works as expected.
Now I want to deploy just the client on a user machine (and have it still work).
The first approach I simply jar'd the client (using maven). When I run the executable jar I get the error that the ws.Ingester class is not found.
org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-VSWINLT019-1541482662292-0-1]
at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1846)
at org.apache.camel.impl.DefaultExchange.setException(DefaultExchange.java:385)
at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:66)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:197)
at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:79)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: ws.Ingester
at qp.PullRoute$1.process(PullRoute.java:54)
at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63)
... 9 more
Caused by: java.lang.ClassNotFoundException: ws.Ingester
I am not sure which way to go on this and I have tried several approaches with no success.
I'd like to do something like the following which removes the reference to the IncidentService interface:
.to("cxf://http://localhost:8080/data-ingest-service/webservices/ws"
+ "?serviceClass=ws.Ingester"
+ "?serviceName=upload"
+ "?id=1")
Is this the right direction? I get the following exception, how to make it work?
Exception in thread "main" org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[cxf://http://localhost:8080/data-ingest-service/webservices/ws?serviceClass=ws.Ingester?serviceName=upload?id=1] <<< in route: Route(route1)[[From[timer://Timer?period=60000]] -> [OnExcep... because of Failed to resolve endpoint: cxf://http://localhost:8080/data-ingest-service/webservices/ws?serviceClass=ws.Ingester%3FserviceName%3Dupload%3Fid%3D1 due to: ws.Ingester?serviceName=upload?id=1
Could someone give me advice on this please. The 'id' parameter seems to be part of the problem and I am assuming the body will be passed to the body parameter as it does in the code first example above.
I don't feel that packaging up the server and including it as a dependent repository is the correct way to go, mainly because it seems like overkill.
thanks