Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Resource not available in @Singleton @Predestroy method

2642681Dec 21 2015

It seems like resources are not available to a Singleton's @Predestroy method.

@PreDestroy
public void cleanup() {
  logger
.info("*** Application shutting down. Dropping temporary tables ***");
 
try {
       connection
= dataSource.getConnection();

      
Statement statement = connection.createStatement();
       statement
.execute("drop table TABLE1");
       statement
.execute("drop table TABLE2");
       connection
.close();
       connection
= null;
  
} catch (SQLException sqle) {
       sqle
.printStackTrace();
  
}
}

The call to getConnection() fails with the error "No Pool Meta Data object associated with the pool". Note that the getConnection() call is successful in the @PostConstruct methods.

Is it a Bug in the application server implementation? If not, what is the most elegant way to drop temporary tables?

(Using Glassfish 4.1.1 + Derby DB.

Comments
Post Details
Added on Dec 21 2015
0 comments
591 views