Last updated on NOVEMBER 05, 2016
Applies to:Oracle GlassFish Server - Version 3.1.2 and later
Information in this document applies to any platform.
There is a mismatch in the number of @PostConstruct invocations compared to the number of @PreDestroy invocations when a web service is invoked.
Everytime the above web service is invoked and a new invocation context created, the @PostConstruct annotated method is called. However, due to this issue that @PostConstruct method is being called twice for each invocation. For example, if the web service is called 5 times concurrently, there are 10 calls of the @PostConstruct method, and only 5 calls to the @PreDestroy annotated method.
Note that the web service implementations that are created are cached and re-used, so the number of instances that are created, and hence the number of @PostConstruct and @PreDestroy calls invoked will depend on the number of concurrent requests for the web service.
In addition, the @PreDestroy method may not be called under some circumstances, for example when the application server instance is being shutdown. However, if the application containing the web service is undeployed then the @PreDestroy methods are called, as the specification requires. This complies with the JAX-WS 2.2 specification, pages 126-127.
Sign In with your My Oracle Support account
Don't have a My Oracle Support account? Click to get started
Million Knowledge Articles and hundreds of Community platforms