Sign in

E-mail *, (xx@domain.com)
Password *

Register | Forgot password

Pool's closed.

The "WCB: Java development" forum contains threads on issues that are related to Java while programming a WCB (WebManager Component Bundle). If you have questions that have impact on Java code, post them in this forum. Some example topics: authorization, the different component types, setting up component dependencies, data access, and so forth.

Answered
Not marked as answered yet

Forums  >  WCB: Java development  >  Pool's closed.


Author Pool's closed.
Cthulhu



Posts: 198

Posted: 30-10-2009 10:38

I just got the following error when attempting to get a connection to a database:


WARNING: Uncaught exception in unknown controller.
java.lang.IllegalStateException: Pool not open
at org.apache.commons.pool.BaseObjectPool.assertOpen(BaseObjectPool.java:78)
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:781)
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:96)
at sun.reflect.GeneratedMethodAccessor73.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at nl.gx.webmanager.services.dbcpmanager.impl.DBCPManagerService$StatisticsDataSource.invoke(DBCPManagerService.java:856)
at $Proxy23.getConnection(Unknown Source)
at nl.oberon.product.mijnElf.dao.MijnElfDao.getWCBStorageConnection(MijnElfDao.java:112)
at nl.oberon.product.mijnElf.dao.MijnElfDao.executeWcbStorageQuery(MijnElfDao.java:141)
at nl.oberon.product.mijnElf.dao.MijnElfDao.getVotesByMijnElfId(MijnElfDao.java:538)
at nl.oberon.product.mijnElf.element.CustomElementController.referenceData(CustomElementController.java:143)
at nl.gx.webmanager.springmvc.controller.BaseWebmanagerController.showForm(BaseWebmanagerController.java:287)
at nl.gx.webmanager.springmvc.controller.component.ComponentController.showForm(ComponentController.java:117)
at nl.gx.webmanager.springmvc.controller.BaseWebmanagerController.showForm(BaseWebmanagerController.java:300)
at nl.gx.webmanager.springmvc.controller.platform.PlatformController.showForm(PlatformController.java:146)
at nl.gx.webmanager.springmvc.controller.platform.PageVersionController.showForm(PageVersionController.java:258)
(etc ad semi-infinitum)



This only occurs in the back-end when attempting to retrieve the results from a 'votes'-table - in the front-end, where the results are written (with a rather awesome insert-or-update transaction-like query, btw), there's no problem.

So, what might cause this? Some problem in the database configuration? (I've got the amount of connections set to 5, and they're all neatly closed again in a finally block, and I expect another error to show if that's the problem, but I might be wrong.)

Cthulhu



Posts: 198

Posted: 30-10-2009 14:16

Update: I've further refactored my DAO-class, so that all queries are handled in a single method (including the setup and teardown of connections etc). Probably something sloppy on my side, ignore my post plx.

Michel Teunissen



Posts: 190

Posted: 02-11-2009 20:07

We will ;)

Regards,

Michel

Cthulhu



Posts: 198

Posted: 22-01-2010 11:42

In fact, don't ignore my post. The problem resurfaced, but this time, there's no connections left open as far as I know - at least, not in my own project, not sure about the other one that uses the same connection. But that one's not used or accessed at the moment, if I'm right.

Is there any other possible reason(s) why this problem occurs?

PeterK



Posts: 9

Posted: 22-06-2010 16:30 Solved

I assume your DAO class retains a local reference to the datasource and thus is not aware of changes in the connection pool. The pool could have been closed for several reasons. Let's mention two obvious reasons:
E.g.1, The DBCPManagerService stops/restarts. This surely will happen when a WCB with a depency to this service is upgraded. However, if your own WCB has the right service dependency you would be save here (since you WCB will restart as well).
E.g.2, The database settings in the web/setup are saved. If this happens all datasources (regardless actual changes) will be closed. (There is always room for approvement; this also counts for the WebManager platform.)
You might consider to catch the "IllegalStateException" in your getConnection method (and stick to the local reference). Nontheless, the best approach, without doubt, would be to repetitively request the datasourse from the service.
The same story counts when the scope is broadened to a more general scope. A rule of thumb would be; Don't retain objects if you don't know its lifecycle.

Cthulhu



Posts: 198

Posted: 09-07-2010 13:18

It's quite likely that the problem was indeed storing the datasource as a local variable in my data class. I would however note that this behavior seems to be undocumented - if it's considered bad practice or potentially dangerous to retain a reference to a datasource, it should be noted as such in its documentation, or in the method that retrieves that object.

In fact, the latter should have that documentation - the DataSource documentation itself ((http://download.oracle.com/docs/cd/E17476_01/java se/1.5.0/docs/api/javax/sql/DataSource.html)) does not hint at any unforseen consequences (it's an interface, it doesn't have to), nor do the implementation classes found in apache-dbcp (as referred to in the DataSourceManager class).

Insofar as I can see, the datasource object should be retainable, as it supports changing properties on the fly. Of course, I don't know the implementation details, so I'm probably wrong.

Anyways, problem solved, thanks!

Back to top

New message: "Pool's closed."
Message:
bold boitalicd underline url quote code smile cool eek grin mad razz sad wink
 
© 2010 GX creative online development B.V.

Disclaimer

This website (GXdeveloperweb.com) may discuss or contain opinions, (sample) coding, software or other information that does not include GX official interfaces, instructions or guidelines and therefore is not supported by GX. Changes made based on this information are not supported.  GX will not be held liable for any damages caused by using or misusing the information, software, instructions, code or methods suggested on this website, and anyone using these methods does so at his/her own risk. GX offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this website, including any liability resulting from incompatibility between the content of this website and the materials and services offered by GX. By using this website you will not hold, or seek to hold, GX responsible or liable with respect to the content of this website.