Error retrieving DataSource in JNDI ( org.osgi.framework.ServiceException: The use count for the service overflowed.)

Asked 2 years ago, Updated 2 years ago, 37 views

The system I am developing connects to DB as follows, but an error occurred when I played the test during the system test phase.I checked and found that it is related to the function of JNDI, which was created based on the OSGi framework.OSGi's service has an upper usage limit (Integer's upper limit) and accumulates the usage for each call.But for some reason, it seems that it has never been opened in accumulation.However, I cannot determine the cause because I cannot understand the movement of OSGi or JNDI at all.If you have any idea, could you tell me?

source code

InitialContext ctx=newInitialContext();
DataSource dataSource=(DataSource)ctx.lookup(dsName);
return dataSource.getConnection();

error logs

Cause by: org.osgi.framework.ServiceException: The use count for the service overflowed.
    at org.eclipse.osgi.internal.serviceregistry.ServiceUse.incrementUse (ServiceUse.java:154)
    at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:91)
    at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer $2.getService(ServiceConsumer.java:45)
    at org.eclipse.osgi.internal.serviceRegistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:496)
    at org.eclipse.osgi.internal.serviceRegistry.ServiceRegistry.getService(ServiceRegistry.java:461)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.getService (BundleContextImpl.java:619)
    at org.apache.aries.jndi.Utils $4.run (Utils.java:195)
    at java.security.AccessController.doPrivileged (AccessController.java:594)
    at org.apache.aries.jndi.Utils.getServicePrivileged (Utils.java:193)
    at org.apache.aries.jndi.ContextHelper.getContextProvider (ContextHelper.java:177)
    at org.apache.aries.jndi.ContextHelper.getInitialContext (ContextHelper.java:141)
    at org.apache.aries.jndi.OSGiInitialContextFactoryBuilder.getInitialContextFactoryBuilder.java:51)
    at javax.naming.spi.namingManager.getInitialContext (NamingManager.java:695)
    at javax.naming.InitialContext.getDefaultInitCtx (InitialContext.java:324)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx (InitialContext.java:352)
    at javax.naming.InitialContext.lookup (InitialContext.java:428)
    at jp.co.abc.dao.query.ConnectionUtils.getConnection(ConnectionUtils.java:130)

java

2022-09-30 15:55

1 Answers

I have a promise, but isn't the connection pool depleted?
I've never used Liberty, so I don't know if there's a management console, but I think it's because they check the status of the connection pool.For your information, there seems to be a way like this.

http://6h324.hatenablog.com/entry/2017/08/25/113626

Note:
If you look at the source code, you can see where it is.

void incrementUse(){
    if(useCount==Integer.MAX_VALUE){
        through new ServiceException (Msg.SERVICE_USE_OVERFLOW);
    }
    useCount++;
}

It says, and it seems to be spinning up to the integer maximum value of an integer.
In addition, if you look at ServiceFactoryUse.java,
It is designed to cache service objects every time a service is called.
Decrements that do the opposite are called when you unget services, so as a result of neglecting the release process, it seems that you have turned it around as many times as possible (2-31-1).

Confirmation: How long have you been running it until it's in this state?


2022-09-30 15:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.