org.apache.activemq.jms.pool.PooledConnectionFactory creates a connection on startup without giving it back to the pool:
So no close() method of PooledConnection is called and so no decrementReferenceCount is called on ConnectionPool. So referenceCount never becomes 0.
Later on if an exception occurs and hasExpired of ConnectionPool is set to true, the connection will not be closed since expiredCheck() method of ConnectionPool always compares referenceCount with 0 and does close() only if it is 0.
So we have a dead ConnectionPool instance and all usages result in "XXX closed" errors.
The fix would be to add call to close() just after doing createConnection() in PooledConnectionFactory#start() to make referenceCount go to 0. Something like this: