Talend ESB Runtime and using context

Highlighted
Five Stars

Talend ESB Runtime and using context

I have been searching online and haven't been able to find a solution.

I am piloting use of TOS ESB Studio and Runtime deployed on a different server. It's not a subscription product.

 

I created a sample job to pilot basics, which reads data from a database and then listens to a rest request and sends immediate rest response.

It look like this:

 

tDBInput->tFileOutput->OnComponentOK->tRestRequest->tJavaRow->tRESTResponse

 

As long as I have REST Endpoint field in tRESTRequest component hardcoded it works fine running in the Runtime container.

 

However, if I change it to context to something like "http://"+context.hostname+"/:8089" the job fails to deploy.

Before throwing an exception it says

"g.apache.cxf.endpoint.ServerImpl 94 | 49 - org.apache.cxf.cxf-core - 3.3.1 | Setting the server's publish address to be http://"+context.Hostname+":8089/" then clearly fails to bind the port with 

"Caused by: org.apache.cxf.interceptor.Fault: Could not start Jetty server on port 8,089: Unresolved address"

When I unpack the jar and look at job.xml I see this:

"<jaxrs:server xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"
id="service"
address="http://&quot;+context.Hostname+&quot;:8089/">
<jaxrs:serviceBeans>
<ref component-id="serviceBean" />
</jaxrs:serviceBeans>"

 

I have created the file second-0.1.jar.cfg in container/etc folder with one single line:

-----------

context = Development

-----------

It doesn't help much despite all contexts and variables are present in the jar file.

 

However, context also used for the database component tDBInput in the same job and the job runs fine (as long as REST Endpoint is hardcoded).

However, the job keeps running in the same default context it was compiled with and changing context value in the container/etc/second-0.1.jar.cfg doesn't have any effect.

 

How can I fix this and use context properly?

 

Can someone please point me to an up to date tutorial on how it's done perhaps?

 

Thank you.


Accepted Solutions
Sixteen Stars TRF
Sixteen Stars

Re: Talend ESB Runtime and using context

Suppose your service is available through the URL "https://your_IP/services/api/v1/your_service".

The REST endpoint field of tRESTRequest component should be "/api/v1/your_service".

This way you can deploy it anywhere without any change for the URL which cannot use dynamic construction using context or global variable.


TRF

View solution in original post


All Replies
Sixteen Stars TRF
Sixteen Stars

Re: Talend ESB Runtime and using context

You should use relative path instead off complete URL.

TRF
Five Stars

Re: Talend ESB Runtime and using context

@TRF thank you for your reply, but can you please elaborate?

 

Where should I use relative path and how?

Sixteen Stars TRF
Sixteen Stars

Re: Talend ESB Runtime and using context

Suppose your service is available through the URL "https://your_IP/services/api/v1/your_service".

The REST endpoint field of tRESTRequest component should be "/api/v1/your_service".

This way you can deploy it anywhere without any change for the URL which cannot use dynamic construction using context or global variable.


TRF

View solution in original post

Five Stars

Re: Talend ESB Runtime and using context

Thank you @TRF . It makes sense and works - the service now running fine on default port 8040, but I have difficulties with invoking it.

 

I get HTTP/1.1 404 Not Found when making a call to it despite the service is up and running fine until I make a call, then it throws an exception in the wrapper.log

It also available on services page and its WADL looks fine

 

comm0.pngcomm1.png

As you can see, when I make a call, it just throws a HTTP error. It was not the case when I specified hostname and port in the REST Endpoint field. 

 

When I look at the logs I can see this exception

 

INFO | jvm 1 | 2019/11/25 16:53:58 | Exception in thread "Thread-76" java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
INFO | jvm 1 | 2019/11/25 16:53:58 | at java.lang.ClassLoader.defineClass1(Native Method)
INFO | jvm 1 | 2019/11/25 16:53:58 | at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(ModuleClassLoader.java:276)
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.defineClass(ClasspathManager.java:655)
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(ClasspathManager.java:578)
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:538)
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:525)
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:328)
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:368)
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:446)
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:395)
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:387)
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150)
INFO | jvm 1 | 2019/11/25 16:53:58 | at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
INFO | jvm 1 | 2019/11/25 16:53:58 | at local_project.second_0_1.second.tWriteJSONField_1_InProcess(second.java:4144)
INFO | jvm 1 | 2019/11/25 16:53:58 | at local_project.second_0_1.second$1ThreadXMLField_tWriteJSONField_1_Out.run(second.java:2998)
INFO | jvm 1 | 2019/11/25 16:53:58 | Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException cannot be found by local_project.second_0.1.0
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:484)
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:395)
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:387)
INFO | jvm 1 | 2019/11/25 16:53:58 | at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150)
INFO | jvm 1 | 2019/11/25 16:53:58 | at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
INFO | jvm 1 | 2019/11/25 16:53:58 | ... 16 more

 

It seems like it's linked to tWriteJSONField component. I dropped json-lib-2.4.1-talend.jar to JRE/lib/ext folder and restarted Karaf but it didn't help. Any ideas?

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read