At least one other person reported this recently. I suspect that Castor and/or its plugin is not closing connections to release them back into the pool. You might try setting the pool max size to 1 and turning logging up everywhere and trying to use Castor twice.
Seems like you are right about your suspicions: It failed on the second request.
When I looked after, Castor JDO plugin was not using pooled connections. I added DatabasePooling=true to the configuration parameters. This revealed that there might be a bug in the JDO plugin, because it tries to release connections to the pool, that the pool apparently does not know about.
java.rmi.ServerException: disconnect(ManagedConnection mc: null, Object c: org.jboss.resource.adapter.jdbc.local.LocalConnection@9c2931) called with unknown managed connection; nested exception is:
java.lang.IllegalArgumentException: disconnect(ManagedConnection mc: null, Object c: org.jboss.resource.adapter.jdbc.local.LocalConnection@9c2931) called with unknown managed connection
Anyone who has a clue about this one?
Have you guys try posting your problem on the Castor mailing list? There are a lot of activites on that list and someone should be able to give you some insights.
If Castor is closing its connections at appropriate times you should not be running into that code. Does the ejb that uses castor implement equals and hashcode? If so you should use a more recent jboss version (from cvs), it is a JBoss bug I fixed recently.