Sembra che le risorse non siano disponibili per il metodo @Predestroy di Singleton.Risorsa non disponibile nel metodo @Singleton @Predestroy
@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();
}
}
La chiamata a getConnection() non riesce con l'errore "No Pool Meta Data object associated with the pool
". Si noti che la chiamata getConnection() ha esito positivo nei metodi @PostConstruct.
Si tratta di un bug nell'implementazione del server delle applicazioni? In caso contrario, qual è il modo più elegante per rilasciare tabelle temporanee?
(Usando Glassfish 4.1.1 + Derby DB L'origine dati viene creata usando pesci vetro-resources.xml schierato con l'EAR
<resources>
<jdbc-resource pool-name="EmbeddedDerbyPool"
jndi-name="java:app/jdbc/ActionBazaarDS" />
<jdbc-connection-pool name="EmbeddedDerbyPool"
res-type="javax.sql.DataSource"
datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource"
is-isolation-level-guaranteed="false">
<property name="databaseName" value="memory:action-bazaar-db"/>
<property name="createDatabase" value="create"/>
</jdbc-connection-pool>
</resources>
.)
Aggiornamento:
ho creato un bug report in GlassFish https://java.net/jira/browse/GLASSFISH-21476.