i am experiencing some issues when i want to call a job from Karaf. When I run it in Talen Open Studio it works fine.
I have one parent job which handles a POST request and then starts a child job which executes a POST with a tRESTClient component.
The parent job looks as follows:
And this is the design of the child job:
I used a simple API for testing the tRestClient:
As I already mentioned running this job in Open Studio works fine. The problem occurs when I deploy it in Karaf. I get this exception:
Exception in component tRunJob_1 (RestRequestParent) java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean at local_project.restrequestparent_0_1.RestRequestParent.tRESTRequest_1_LoopProcess(RestRequestParent.java:2145) at local_project.restrequestparent_0_1.RestRequestParent$RestServiceProviderImpl4TalendJob.processRequest(RestRequestParent.java:391) at local_project.restrequestparent_0_1.RestRequestParent$RestServiceProviderImpl4TalendJob.path1(RestRequestParent.java:479) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:192) at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:103) at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:247) at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:79) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1182) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1116) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134) at org.eclipse.jetty.server.Server.handle(Server.java:534) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:333) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108) at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean at local_project.restrequestparent_0_1.RestRequestParent.tRESTRequest_1_LoopProcess(RestRequestParent.java:1638) ... 34 more Caused by: java.lang.ClassNotFoundException: org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean cannot be found by local_project.RestRequestParent_0.1.0 at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:484) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:395) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:387) at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 35 more
Any idea how this can be solved? I am using version 7.0.1 and Java 1.8 by the way.
Did you deploy only the parent job in runtime? Have you tried to build and deploy the child job firstly to see if it works?
thanks for your reply.
At first I only deployed the parent job which resulted in this NoClassDefFoundError.
After I researched a little bit more I found the suggestion in another thread (https://community.talend.com/t5/Design-and-Development/REST-webservices-from-TOS-ESB-6-4-to-TOS-ESB-...) to deploy the child job also. But this gave me more problems. In Karaf the state of the child job was "Failure" and when I called my parent job I got some NullPointers and also a WebApplicationException (the REST service always returned 500 as a HTTP code).
Currently I really have no clue why I am not able to get this working...
Did you check out "Use an independent process to run subjob" option on tRunJob which is not compatible with the Runtime?
Could you please post your tRunJob component setting screenshots on forum?
Here is a related community knowledge article about:https://community.talend.com/t5/Design-and-Development/quot-Could-not-find-or-load-main-class-quot-e...
Feel free to let us know if it helps.
thank you very much for your help.
These are my initial settings for tRunJob.
I didn't check "Use an independent process to run subjob" which resulted in this NoClassDefFoundError.
However, I also tried to build this job with this option enabled and got the same result that is also described in your article and in the Jira issue: the child job returns 1 and the main class could not be found.
Now do I understand this correctly that this is currently a bug in Talend Open Studio and cannot be solved?
actually I still couldn't resolve this problem. But I will definitely post a message here as soon as we will find a workaround.
Did you also try to disable the "Use an independent process to run subjob" option? If you will be able to work this out please let me know
sorry for the late reply. I was a little bit busy the last couple of days.
Good to know that this problem doesn't occur in v6. All our jobs are made with v7 so I am not sure if we will fully downgrade to 6.
But I will definitely give it a try as soon as I will work on this task again. It's really strange that this seems to work with one version but not with the other one...
Anyhow, thanks again for this advice
Spent 2 weeks to refactor a job with subjobs so that it is easier to read / modify / change and added new features etc. Now I am running into this very same issue. Please let me know if you were able to find a solution for it. Deselecting "Use an independent process to run subjob" didn't work. Neither deploying the subjobs separately.
If it's up to me, I would recommend against Talend ESB for production. So many issues and instability without talking about lack of documentation and support
Same problem here,
we refactored some jobs with subjobs as they were starting to get very hard to read ... and run into the very same problems
Did you find any solution? seesing the post date i don't think so, but who knows?
(ps : sorry posted another thread before finding this one)
Problem seems to be with the build process when building osgi container, but i found a temporary solution : https://community.talend.com/t5/Design-and-Development/Job-with-Subjobs-error-when-deployed-as-OSGI-...
Talend named a Leader.
Kickstart your first data integration and ETL projects.
Learn how to use an API-First Approach to Modernize your Applications
Take a look at this technical overview video of Talend API Designer
Find out how to get started with APIs