Hey there! I have an issue that I'm hoping someone can advise me on... I have an ESB service that I've created and it functionally works great. Within the job, I'm creating a database connection at the beginning (tMySQLConnection) and using that connection for other database components. The tMysqlConnection component has "specify a data source alias" enabled, so that a connection pool that's been defined at the ESB Runtime is used. In one portion of the job, I am using tMySQLOutput immediately followed by a tMysqlLastInsertID, to capture the ID of an inserted record. Both components have "Use an existing connection" selected. This works just fine when I run the job locally. When I deploy the job to the ESB Runtime, where I've defined connection pooling, the service throws a NullPointerException error on the tMySQLLastInsertID component. I believe what's happening is that while both components are sharing the same tMySQLConnection component, they are actually getting different sessions from the connection pool, thus causing tMysqlLastInsertID to not see the record inserted in tMysqlOutput. Does this sound correct? Any thoughts on how I can force these components to use the same session when using connection pooling?
Well, I was able to create a "test" job that confirms this specific issue. Please see the attached screenshots. The job is simple, I've created a REST service that, when called, inserts a row into a MySQL table and returns the row that was inserted, including the last insert id. The database connection is using a connection pool, that that obviously only takes effect when deploying to the ESB Runtime. When running the service in the Studio, it works just fine.
But, when running from the ESB Runtime, I get the below error. I've also included a screenshot of my Connection Pool file, which is based off the template provided in the ESB Runtime.
Does this seem like a bug??
Exception in component tMysqlLastInsertId_1
java.lang.NullPointerException
at br_cdh.test_connection_pool_0_1.test_connection_pool.tFixedFlowInput_1Process(test_connection_pool.java:1459)
at br_cdh.test_connection_pool_0_1.test_connection_pool.tRESTRequest_1_LoopProcess(test_connection_pool.java:2217)
at br_cdh.test_connection_pool_0_1.test_connection_pool$RestServiceProviderImpl4TalendJob.processRequest(test_connection_pool.java:478)
at br_cdh.test_connection_pool_0_1.test_connection_pool$RestServiceProviderImpl4TalendJob.run(test_connection_pool.java:578)
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:180)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:200)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:99)
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:251)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:180)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:293)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:217)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:268)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:271)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:497)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)