Five Stars

Custom components tlog4j and tinitlog4j not functioning when deploying to talend runtime container (Talend version 7) (TOS ESB)

Hello,

 

I am trying to deploy a job with tlog4j (and tinitlog4j) components - these are custom components from the exchange. When I try locally , the job will function (I see output in the console and in the file configured as logger output in the log4j xml config). If I export as "standalone job", the job also functions correctly. However, when I try to export this job as OSGI and deploy it to a container, the logging appears to be completely disabled - there is no console output and no file output, and no error or anything else in the tesb.log or in the karaf log.

 

Has anyone had this problem and knows how to fix it? Any help would be appreciated. Thanks.
I attach a jpg of my simple test job .

 

2 REPLIES
Five Stars

Re: Custom components tlog4j and tinitlog4j not functioning when deploying to talend runtime container (Talend version 7) (TOS ESB)

After some experimenting I have found out that there is actually an exception thrown, which was not being logged anywhere. It looks like one of the dependencies can't be found:

 

Exception in component tRESTRequest_1_In (testservicelog)
java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/apache/log4j/BasicConfigurator
        at local_project.testservicelog_0_1.testservicelog.tRESTRequest_1_LoopProcess(testservicelog.java:3492)
        at local_project.testservicelog_0_1.testservicelog$RestServiceProviderImpl4TalendJob.processRequest(testservicelog.java:480)
        at local_project.testservicelog_0_1.testservicelog$RestServiceProviderImpl4TalendJob.abc(testservicelog.java:571)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        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(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/BasicConfigurator
        at org.courtine.talend.log4j.TalendLog4JConfigurator.configureLog4J(TalendLog4JConfigurator.java:36)
        at local_project.testservicelog_0_1.testservicelog.tInitLog4J_1Process(testservicelog.java:1458)
        at local_project.testservicelog_0_1.testservicelog.tFixedFlowInput_1Process(testservicelog.java:1308)
        at local_project.testservicelog_0_1.testservicelog.tRESTRequest_1_LoopProcess(testservicelog.java:3320)
        ... 34 more

 

I tried to manually import the needed dependencies in the job but this does not appear to solve the problem. Anyone have any ideas?

Five Stars

Re: Custom components tlog4j and tinitlog4j not functioning when deploying to talend runtime container (Talend version 7) (TOS ESB)

I have managed to work around this issue in the meantime.

It looks like it is not easily possible to use the tlog4j custom components with the Runtime (at least not in the latest versions  - 6.x or 7.x). The components rely on using a custom written log4j config and loading this with some methods/classes in the "standalone" log4j library - the karaf container uses pax logging and different implementations to "catch" logging from different frameworks. This means that some parts of the API have noop implementations - in this situation, parts used by these old custom components, namely by the tinitlog4j component.

What instead must be done is to modify the config files for the container logging directly ( <runtimefolder>/container/etc/org.ops4j.pax.logging.cfg ) and add any custom loggers and appenders there. Then in the job simply use a tJava type of component where you call log4j.getLogger("yourLoggerName"). One minor inconvenience was that not all messages are displayed to the console in the studio (I think only > Warn levels are displayed) so this made debugging the logging a bit harder but I got around this by writing a small routine which automatically prints every log command also to console.

One of the needs I had was to be able to easily have a separate log file per job, which can be achieved by using a "Routing" type appender - this was called "sifting" appender in the older versions of Karaf I believe - and will actually create a separate log file per bundle (in this case,per job).