NoClassDefFoundError when starting job in Karaf

Five Stars

NoClassDefFoundError when starting job in Karaf

Hi there,

 

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:

parentjob.JPG

restparent.JPG

 

And this is the design of the child job:

childjob.JPG

 

 

 

I used a simple API for testing the tRestClient:

restclientchild.JPG

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.

 

Best regards

Basit

Moderator

Re: NoClassDefFoundError when starting job in Karaf

Hello,

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?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: NoClassDefFoundError when starting job in Karaf

Hi @xdshi,

 

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...

 

Best regards,

 

Basit

Moderator

Re: NoClassDefFoundError when starting job in Karaf

Hello,

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?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Moderator

Re: NoClassDefFoundError when starting job in Karaf

Hello,

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.

Best regards

Sabrina

 

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: NoClassDefFoundError when starting job in Karaf

Hi,

 

thank you very much for your help.

These are my initial settings for tRunJob.tRunJob.JPG

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?

 

Best regards,


Basit

 

Highlighted
Seven Stars

Re: NoClassDefFoundError when starting job in Karaf

Having the exact same issue. How did you get around it?

 

Regards,

Five Stars

Re: NoClassDefFoundError when starting job in Karaf

Hi @navds,

 

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 Smiley Happy

 

Regards, 

 

Basit

Seven Stars

Re: NoClassDefFoundError when starting job in Karaf

Hi @Basit,
Apparently, this has something to do with class loading config in v7. I compiled an OSGi bundle of the same job from Talend 6.4.1 and put it in the Talend 7 container. It worked.
Unfortunately, you can't import project made with 7 in 6. I migrated from 6 and fortunately, I had the project archived under version control.
Maybe someone could find a workaround, probably editing pom files, but for now, I'll stay with Talend 6.

Regards,
Navds
Five Stars

Re: NoClassDefFoundError when starting job in Karaf

Hi @navds 

 

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 Smiley Happy

 

Regards,

Basit

Cloud Free Trial

Try Talend Cloud free for 30 days.

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.