Eclipse4 and @PostConstruct and @PreDestroy not called (javax.annotation)

We are getting some error reports that @PostConstruct and @PreDestroy methods in Eclipse 4 RCP applications are not called by the framework.

If you are building Eclipse 4 RCP applications you shoudl enter the javax.annotation package as package dependency instead of plug-in dependency, otherwise you plug-in will be using a different @PostConstruct than the framework and your methods may not be called.

Wim Jongman fixed already the e4 tools in Bug 394327 , so a new version of the tools will also generate a package dependency.

If you are wondering where you can find the latest version of the tools, just build the e4 tools locally. 🙂

[EDIT – UPDATED entry to describe that import package is always required]

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of vogella.com. With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Eclipse. Bookmark the permalink.

5 Responses to Eclipse4 and @PostConstruct and @PreDestroy not called (javax.annotation)

Comments are closed.