JDeveloper/Weblogic 12.2.1.4 - It appears that I have a connection leak in my code, and even though I can see clearly where the leak is being reported, I don't know why this code is causing a leak.
Stack trace:
weblogic.jdbc.extensions.PoolLimitSQLException: weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool MyDS to allocate to applications, please increase the size of the pool and retry..
at weblogic.jdbc.common.internal.JDBCUtil.wrapAndThrowResourceException(JDBCUtil.java:280)
at weblogic.jdbc.pool.Driver.connect(Driver.java:154)
at weblogic.jdbc.jts.Driver.getNonTxConnection(Driver.java:665)
at weblogic.jdbc.jts.Driver.connect(Driver.java:129)
at weblogic.jdbc.common.internal.WLDataSourceImpl.getConnectionInternal(WLDataSourceImpl.java:655)
at weblogic.jdbc.common.internal.WLDataSourceImpl.getConnection(WLDataSourceImpl.java:611)
at weblogic.jdbc.common.internal.WLDataSourceImpl.getConnection(WLDataSourceImpl.java:604)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:108)
at oracle.jbo.server.DBTransactionImpl.establishNewConnection(DBTransactionImpl.java:1018)
at oracle.jbo.server.DBTransactionImpl.initTransaction(DBTransactionImpl.java:1211)
at oracle.jbo.server.DBTransactionImpl.initTxn(DBTransactionImpl.java:7143)
at oracle.jbo.server.DBTransactionImpl2.connectToDataSource(DBTransactionImpl2.java:297)
at oracle.jbo.server.DBTransactionImpl2.connectToDataSource(DBTransactionImpl2.java:328)
at oracle.jbo.common.ampool.DefaultConnectionStrategy.connect(DefaultConnectionStrategy.java:203)
at oracle.jbo.server.ApplicationPoolMessageHandler.doPoolConnect(ApplicationPoolMessageHandler.java:655)
at oracle.jbo.server.ApplicationPoolMessageHandler.doPoolMessage(ApplicationPoolMessageHandler.java:440)
at oracle.jbo.server.ApplicationModuleImpl.doPoolMessage(ApplicationModuleImpl.java:10013)
at oracle.jbo.common.ampool.ApplicationPoolImpl.sendPoolMessage(ApplicationPoolImpl.java:4618)
at oracle.jbo.common.ampool.ApplicationPoolImpl.prepareApplicationModule(ApplicationPoolImpl.java:2503)
at oracle.jbo.common.ampool.ApplicationPoolImpl.doCheckout(ApplicationPoolImpl.java:2299)
at oracle.jbo.common.ampool.ApplicationPoolImpl.useApplicationModule(ApplicationPoolImpl.java:3216)
at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:611)
at oracle.jbo.http.HttpSessionCookieImpl.useApplicationModule(HttpSessionCookieImpl.java:224)
at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:544)
at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:539)
at oracle.adf.model.bc4j.DCJboDataControl.initializeApplicationModule(DCJboDataControl.java:659)
at oracle.adf.model.bc4j.DCJboDataControl.getApplicationModule(DCJboDataControl.java:1034)
at oracle.adf.model.binding.DCBindingContainer.findDataControl(DCBindingContainer.java:1747)
at oracle.jbo.uicli.binding.JUCtrlActionBinding.internalGetDataControl(JUCtrlActionBinding.java:636)
at oracle.jbo.uicli.binding.JUCtrlActionBinding.getDataControl(JUCtrlActionBinding.java:698)
at oracle.jbo.uicli.binding.JUCtrlActionBinding.internalCheckPermission(JUCtrlActionBinding.java:2320)
at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(JUCtrlActionBinding.java:830)
at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.executeEvent(PageLifecycleImpl.java:414)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding._execute(FacesCtrlActionBinding.java:257)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding.execute(FacesCtrlActionBinding.java:215)
at com.my_package.app.lifecycle.MyFacesPageLifecycle.getUsernameInAM(MyFacesPageLifecycle.java:611)
at com.my_package.app.lifecycle.MyFacesPageLifecycle.setUserData(MyFacesPageLifecycle.java:633)
at com.my_package.app.lifecycle.MyFacesPageLifecycle.prepareModel(MyFacesPageLifecycle.java:530)
at oracle.adf.controller.v2.lifecycle.Lifecycle$2.execute(Lifecycle.java:158)
at oracle.adfinternal.controller.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:201)
at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.startPageLifecycle(ADFPhaseListener.java:204)
at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$1.after(ADFPhaseListener.java:370)
at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.afterPhase(ADFPhaseListener.java:89)
at oracle.adfinternal.controller.faces.lifecycle.ADFLifecyclePhaseListener.afterPhase(ADFLifecyclePhaseListener.java:53)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executeAfterPhaseLogic(LifecycleImpl.java:478)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:400)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:239)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:650)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:295)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:353)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:207)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:105)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain$1.call(TrinidadFilterImpl.java:594)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain$1.call(TrinidadFilterImpl.java:590)
at org.apache.myfaces.trinidad.context.ExternalContextPropagator.processInScope(ExternalContextPropagator.java:216)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:599)
at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:91)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain$1.call(TrinidadFilterImpl.java:594)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain$1.call(TrinidadFilterImpl.java:590)
at org.apache.myfaces.trinidad.context.ExternalContextPropagator.processInScope(ExternalContextPropagator.java:216)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:599)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$1.call(TrinidadFilterImpl.java:374)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$1.call(TrinidadFilterImpl.java:370)
at org.apache.myfaces.trinidad.context.ExternalContextPropagator.processInScope(ExternalContextPropagator.java:216)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:385)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:242)
at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:101)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:169)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at oracle.security.jps.ee.http.JpsAbsFilter$3.run(JpsAbsFilter.java:175)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:314)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:650)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:112)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilterInternal(JpsAbsFilter.java:293)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:150)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:94)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at oracle.security.wls.filter.SSOSessionSynchronizationFilter.doFilter(SSOSessionSynchronizationFilter.java:417)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:248)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at oracle.jrf.servlet.ExtensibleGlobalFilter.doFilter(ExtensibleGlobalFilter.java:92)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:32)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3800)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3766)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:344)
at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2454)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2302)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2280)
at weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1739)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1699)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:274)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:352)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:337)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:57)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:655)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:420)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:360)
I am setting user data in the FacesPageLifecycle method, prepareModel as follows:
public void prepareModel(LifecycleContext ctx) {
setUserData();
super.prepareModel(ctx);
}
private void setUserData(){
if (getUsernameInAM().equals("")){
setUsernameInAM();
}
}
private void setUsernameInAM(String username){
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
DCBindingContainer bc = (DCBindingContainer)bindings.get("pageTemplateBinding1");
OperationBinding method = (OperationBinding)bc.get("setUsername");
if (method == null)
{
logger.info("OperationBinding: " + methodName + " not found.");
return;
}
Map paramsMap = method.getParamsMap();
paramsMap.put("username", username);
try {
method.execute();
List errors = method.getErrors();
if (!errors.isEmpty())
{
for (Object err : errors) {
logger.severe(err.toString());
}
}
} catch (Exception e){
e.printStackTrace();
}
}
private Object getUsernameInAM(){
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
DCBindingContainer bc = (DCBindingContainer)bindings.get("pageTemplateBinding1");
OperationBinding method = (OperationBinding)bc.get("getUsername");
if (method == null)
{
logger.info("OperationBinding: " + methodName + " not found.");
return "";
}
try {
Object result = method.execute();
List errors = method.getErrors();
if (!errors.isEmpty())
{
for (Object err : errors) {
logger.severe(err.toString());
}
} else {
if (result == null) return "";
return result;
}
} catch (Exception e){
e.printStackTrace();
}
return "";
}
Why would this code cause a leak that does not close itself upon the end of the request, or time out when the session times out?
I know I can set the Inactive Connection Timeout connection pool parameter to a value greater than 0 to clean up these leaks, but I would prefer to know why this code is leaking in the first place. Thank you.