IBM Support

WebSphere Application Server Liberty profile @PostConstruct and @PreDestroy servlet jnjection might work even when those methods are not strictly well formed

Troubleshooting


Problem

Servlets annotated with []@PostConstruct[] and []@PreDestroy[] injection methods might be put into service, and those methods might be injected and called, even when those methods are not strictly well formed.

Symptom

In the following scenarios, the @PostConstruct and @PreDestroy methods are used and the servlets are put into service, instead of returning a 404 error to the client:

1. @PostConstruct and @PreDestroy method must not declare to throw exceptions;
2. @PostConstruct and @PreDestroy method must not be static;
3. One object must not have two @PostConstruct or two @PreDestroy injections;
4. @PostConstruct and @PreDestroy must not be declared with passed in parameters;
5. @PostConstruct and @PreDestroy must not be declared final.

Resolving The Problem

This problem has been fixed in 8.5.5 releases. You can either use the latest 8.5.5 releases, or change the servlets to strictly obey the @PostConstruct and @PreDestroy method annotation rules in 8.5.0.x releases.

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Not Applicable","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"8.5","Edition":"Base;Express;Network Deployment","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Not Applicable","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"8.5","Edition":"Base;Express;Network Deployment","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
06 June 2019

UID

swg21593497