users@glassfish.java.net

ok for session bean to keep connection reference & leak reclamation ?

From: <glassfish_at_javadesktop.org>
Date: Wed, 21 May 2008 17:51:05 PDT

I have a Session bean that sends a JMS message.

Is acceptable practice for the Session bean to keep a JMS connection open though out the Session bean’s life, or should the Connection be created/closed from the pool each time one of the Session bean’s JMS sender method is invoked.

Within my Session bean, I'm getting a JMS Connection on @PostCreate and closing it on @PreDestroy.

Or is it better to get a Connection from the pool each time the bean's method that sends JMS messages is invoked?

I'm seeing this error because the Session bean doesn't release the connection until @PreDestroy:

> A potential connection leak detected for connection pool


    /**
     * Creates the connection.
     */
    @PostConstruct
    public void makeConnection()
    {
        try
        {
            connection = connectionFactory.createConnection();
        }
...
[Message sent by forum member 'frenchdrip' (frenchdrip)]

http://forums.java.net/jive/thread.jspa?messageID=275878