Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » @PostConstruct not executed in 4.5.1(After upgrade from 4.4.1 my @PostConstruct methods don't get called anymore)
@PostConstruct not executed in 4.5.1 [message #1714557] Fri, 13 November 2015 14:23 Go to next message
quest ionnere is currently offline quest ionnereFriend
Messages: 57
Registered: January 2015
Member
Hi,

A few days ago I updated from 4.4.1 to 4.5.1 but now my methods annotated with @PostConstruct are not executed anymore.

Looking at and debugging the code, I found out that my method has another instance of the PostConstruct interface in its declaredAnnotations map and therefore does not match the "if (!method.isAnnotationPresent(annotation))" check in InjectorImpl.
I then realized that my method used the javax.annotation_1.2.jar instead of the rt.jar's javax.annotation package and removed the requirement from the Manifest file but still the Object ID of the annotation on the method differs from the one used in InjectorImpl although the same package is now used.

Is there anything I am missing here? Has PostConstruct been unsupported?

Thanks for your replies
Re: @PostConstruct not executed in 4.5.1 [message #1714560 is a reply to message #1714557] Fri, 13 November 2015 14:54 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
you need to import package with version constraint 1.2 in your manifest
Re: @PostConstruct not executed in 4.5.1 [message #1714562 is a reply to message #1714560] Fri, 13 November 2015 15:16 Go to previous messageGo to next message
quest ionnere is currently offline quest ionnereFriend
Messages: 57
Registered: January 2015
Member
I also tried that.
In my Dependencies tab I do not see the javax.annotation bundle unless I check "Show non-exported packages" although my osgi console lists it as RESOLVED after I start the program.

Also, when I then add it, I get a constraint violation on launch due to com.google.guava. I found a conversation that sounds like it could be the same issue: https://dev.eclipse.org/mhonarc/lists/equinox-dev/msg07890.html but unfortunately I also did not find a solution there.
Re: @PostConstruct not executed in 4.5.1 [message #1714563 is a reply to message #1714560] Fri, 13 November 2015 15:17 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Better NO version because if we once get rid of the javax.annotation
crap no change is required! The only important thing is to use a package
import for javax.annotation.

Tom

On 13.11.15 15:54, Dirk Fauth wrote:
> you need to import package with version constraint 1.2 in your manifest
Re: @PostConstruct not executed in 4.5.1 [message #1714565 is a reply to message #1714562] Fri, 13 November 2015 15:24 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Right welcome to the fun!

As of today there's no solution to your problem if you use the e4
platform provided as is.

In e(fx)clipse we fixed the problem by providing a stub
javax.annotation.jre bundle who delegates to the JRE.

See
http://git.eclipse.org/c/efxclipse/org.eclipse.efxclipse.git/tree/bundles/runtime/javax.annotation.jre
so all e(fx)clipse users are not bitten by this crazy javax.annotation
story.

There's an bugzilla open discussing solutions but the bottom line is we
need to get rid of our javax.annotation-bundle.

Tom

On 13.11.15 16:16, quest ionnere wrote:
> I also tried that. In my Dependencies tab I do not see the
> javax.annotation bundle unless I check "Show non-exported packages"
> although my osgi console lists it as RESOLVED after I start the program.
> Also, when I then add it, I get a constraint violation on launch due to
> com.google.guava. I found a conversation that sounds like it could be
> the same issue:
> https://dev.eclipse.org/mhonarc/lists/equinox-dev/msg07890.html but
> unfortunately I also did not find a solution there.
Re: @PostConstruct not executed in 4.5.1 [message #1714593 is a reply to message #1714563] Fri, 13 November 2015 17:53 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
Thomas Schindl wrote on Fri, 13 November 2015 16:17
Better NO version because if we once get rid of the javax.annotation
crap no change is required! The only important thing is to use a package
import for javax.annotation.

Tom


Hm, of course I agree that not using the version constraint is more interesting for future development. But when I migrated my apps for the EclipseCon talk to Mars.1 I needed to add the version constraint to make it work. Without the version constraint @PostConstruct wasn't called.
Re: @PostConstruct not executed in 4.5.1 [message #1714855 is a reply to message #1714565] Tue, 17 November 2015 10:12 Go to previous messageGo to next message
quest ionnere is currently offline quest ionnereFriend
Messages: 57
Registered: January 2015
Member
Thomas Schindl wrote on Fri, 13 November 2015 15:24

As of today there's no solution to your problem if you use the e4
platform provided as is.


Do you think the fix for e(fx)clipse should can also be used to fix my problem?
Re: @PostConstruct not executed in 4.5.1 [message #1714864 is a reply to message #1714855] Tue, 17 November 2015 11:18 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Sure - just remove javax.annotation from your target and put our
javax.annotation.jre there and you are fine.

Tom

On 17.11.15 11:12, quest ionnere wrote:
> Thomas Schindl wrote on Fri, 13 November 2015 15:24
>> As of today there's no solution to your problem if you use the e4
>> platform provided as is.
>
>
> Do you think the fix for e(fx)clipse should can also be used to fix my
> problem?
Re: @PostConstruct not executed in 4.5.1 [message #1714988 is a reply to message #1714864] Wed, 18 November 2015 10:59 Go to previous messageGo to next message
quest ionnere is currently offline quest ionnereFriend
Messages: 57
Registered: January 2015
Member
many thanks, that solved my issue!
Re: @PostConstruct not executed in 4.5.1 [message #1714991 is a reply to message #1714988] Wed, 18 November 2015 11:06 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Great you can now start removing all those crappy javax.annotation
imports ;-)

Tom

On 18.11.15 11:59, quest ionnere wrote:
> many thanks, that solved my issue!
Previous Topic:Stand-alone Listener to EPartService
Next Topic:Eclipse Luna RC1 shows blank window after start.
Goto Forum:
  


Current Time: Fri Sep 20 13:53:06 GMT 2024

Powered by FUDForum. Page generated in 0.04246 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top