I've created a routine that depends on Apache HTTP Components , so I've downloaded the jar files and added those files to the Build Path.
I've set up both Classpath Variables and User Libraries under Java\\Build Path , but it still doesn't work.
My code compile without any errors, but it fails to run with the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/RedirectStrategy
at routines.downloadXls.start(downloadXls.java:10)
[...]
The piece of Java code is the following, it runs with Eclipse:
private CloseableHttpClient createHttpClient() {
HttpClientBuilder builder = HttpClientBuilder.create();
httpCtx.setAttribute(HttpClientContext.COOKIE_STORE, store);
return builder.setRedirectStrategy(LaxRedirectStrategy.INSTANCE).build();
}
I've already seen a similar question on talend community , but it didn't help me.
Any suggestion, please?
Thanks
You need to add your jar(s) in your Talend job using tLibraryLoad
component (one per jar).
tLibraryLoad
|
OnSubjobOk
|
Code using apache components
When you build your job, the jars will be bundled with it and added to your classpath (in .bat and .sh launchers).
I noticed you're setting a cookie in your code, maybe if you give more detail about your requirement I can recommend a solution using dedicated Talend components, as it's best to use native components whenever possible (or you can ask a separate question).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.