[GLASSFISH-20332] @PreDestroy not called on Application subclass in GlassFish 4 build 83 Created: 17/Apr/13  Updated: 23/Apr/13  Resolved: 23/Apr/13

Status: Resolved
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.0_b83
Fix Version/s: 4.0_b86_RC2

Type: Bug Priority: Major
Reporter: tware Assignee: Jakub Podlesak
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows, GlassFish 4 build 83 installed from zip

Application subclass is packaged in a web-fragment jar which is contained in a war file


Issue Links:
Dependency
depends on GLASSFISH-20385 Integrate Jersey 2.0-rc2 into the GF ... Resolved
Tags: GlassFish_4_0-approved

 Description   

A method annotated with @PreDestroy is not getting called on my Application subclass. The @PostConstruct method on the same class IS being called. Here is the class:

@ApplicationPath("/persistence/")
public class JPARSApplication extends Application {

private final Set<Class<?>> classes;

public JPARSApplication()

{ HashSet<Class<?>> c = new HashSet<Class<?>>(); // Unversioned Resources (resources that do not have version in the url) c.add(org.eclipse.persistence.jpa.rs.resources.unversioned.PersistenceResource.class); c.add(org.eclipse.persistence.jpa.rs.resources.unversioned.PersistenceUnitResource.class); c.add(org.eclipse.persistence.jpa.rs.resources.unversioned.EntityResource.class); c.add(org.eclipse.persistence.jpa.rs.resources.unversioned.SingleResultQueryResource.class); c.add(org.eclipse.persistence.jpa.rs.resources.unversioned.QueryResource.class); // Versioned Resources (resources that do have version in the url) c.add(org.eclipse.persistence.jpa.rs.resources.PersistenceResource.class); c.add(org.eclipse.persistence.jpa.rs.resources.PersistenceUnitResource.class); c.add(org.eclipse.persistence.jpa.rs.resources.EntityResource.class); c.add(org.eclipse.persistence.jpa.rs.resources.SingleResultQueryResource.class); c.add(org.eclipse.persistence.jpa.rs.resources.QueryResource.class); // Exception Mapping c.add(ClassNotFoundExceptionMapper.class); c.add(ConversionExceptionMapper.class); c.add(DatabaseExceptionMapper.class); c.add(EntityExistsExceptionMapper.class); c.add(EntityNotFoundExceptionMapper.class); c.add(IllegalAccessExceptionMapper.class); c.add(IllegalArgumentExceptionMapper.class); c.add(IllegalStateExceptionMapper.class); c.add(InvocationTargetExceptionMapper.class); c.add(IOExceptionMapper.class); c.add(JAXBExceptionMapper.class); c.add(JPARSExceptionMapper.class); c.add(MalformedURLExceptionMapper.class); c.add(NamingExceptionMapper.class); c.add(NonUniqueResultExceptionExceptionMapper.class); c.add(NoResultExceptionMapper.class); c.add(NoSuchMethodExceptionMapper.class); c.add(OptimisticLockExceptionMapper.class); c.add(PersistenceExceptionMapper.class); c.add(PessimisticLockExceptionMapper.class); c.add(QueryTimeoutExceptionMapper.class); c.add(RollbackExceptionMapper.class); c.add(TransactionRequiredExceptionMapper.class); c.add(JPARSConfigurationExceptionMapper.class); classes = Collections.unmodifiableSet(c); }

@Override
public Set<Class<?>> getClasses()

{ return classes; }

@PostConstruct
public void start()

{ System.out.println("---------START----------"); }

@PreDestroy
public void predestroy()

{ System.err.println("---------SHUTDOWN2----------"); System.out.println("---------SHUTDOWN----------"); throw new RuntimeException("BLA"); }

}

I do not see either the output or the exception in the GlassFish log when I undeploy the app or when I shut down glassfish.



 Comments   
Comment by shreedhar_ganapathy [ 17/Apr/13 ]

Can you evaluate and reassign as appropriate?

Comment by Jakub Podlesak [ 17/Apr/13 ]

Confirmed this is a bug that should get fixed for 4.0.

Comment by Jakub Podlesak [ 18/Apr/13 ]

Adjusted fixBy version and tag as per Shreedhar's request.

Comment by Jakub Podlesak [ 23/Apr/13 ]

This has already been fixed in Jersey 2.0-rc2.

Comment by Jakub Podlesak [ 23/Apr/13 ]

Fixed with Jersey 2.0-rc2 integration (https://java.net/jira/browse/GLASSFISH-20385)

Generated at Tue Mar 31 17:23:53 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.