Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Inject problem
Inject problem [message #1060492] Sat, 25 May 2013 07:32 Go to next message
Miroslav Lazarevic is currently offline Miroslav Lazarevic
Messages: 25
Registered: July 2009
Location: Sabac, Serbia
Junior Member
Well I'm experimenting with Eclipse4 RCP application and have noticed I must use @Inject if I want my part would initialized. If I put only @PostConstruct my part it's not initialized. What is needed to use only @PostConstruct and get method injected?

So this works for me

@Inject
public void createPart(Composite parent) {
...
}

while this don't work

@PostConstruct
public void createPart(Composite parent) {
...
}
Re: Inject problem [message #1060514 is a reply to message #1060492] Sat, 25 May 2013 16:48 Go to previous messageGo to next message
Miroslav Lazarevic is currently offline Miroslav Lazarevic
Messages: 25
Registered: July 2009
Location: Sabac, Serbia
Junior Member
Over 4000 views of this post and nobody has comment. Very strange.

Why in tutorials over Internet simple @PostConstruct works and won't for me. What I'm missing?
Re: Inject problem [message #1060532 is a reply to message #1060514] Sun, 26 May 2013 06:17 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 589
Registered: December 2010
Senior Member

I find it strange to complain why you're not getting a response within 10 hours on a Saturday. However it's as simple as looking at the wiki http://wiki.eclipse.org/Eclipse4/RCP/FAQ#Why_isn.27t_my_.40Inject-able.2F.40PostConstruct_methods_being_injected.3F and more details https://bugs.eclipse.org/bugs/show_bug.cgi?id=403814
Re: Inject problem [message #1060548 is a reply to message #1060532] Sun, 26 May 2013 11:34 Go to previous messageGo to next message
Miroslav Lazarevic is currently offline Miroslav Lazarevic
Messages: 25
Registered: July 2009
Location: Sabac, Serbia
Junior Member
Yeah you are absolutely right. Sorry and thanks for the answer. I wasn't use this forum about couple years so I forgot weekend issue Smile Anyway thank you again.
Re: Inject problem [message #1060551 is a reply to message #1060532] Sun, 26 May 2013 12:24 Go to previous messageGo to next message
Miroslav Lazarevic is currently offline Miroslav Lazarevic
Messages: 25
Registered: July 2009
Location: Sabac, Serbia
Junior Member
Well FAQ helped. Imported javax.annotation and javax.inject packages and now it works. I knew there is a trick even it is a bug.

[Updated on: Sun, 26 May 2013 12:32]

Report message to a moderator

Re: Inject problem [message #1060581 is a reply to message #1060551] Mon, 27 May 2013 03:31 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5020
Registered: July 2009
Senior Member
No you have to import javax.annotation to make @PostConstruct work!

Tom

On 26.05.13 18:24, Miroslav Lazarevic wrote:
> Just to confirm. I imported javax.inject package instead to put it in
> Required Plug-ins as it said in documents you sent me :) Hope this will
> help someone else who starts to play with new Eclipse 4 platform.
>
> best regards
Re: Inject problem [message #1063793 is a reply to message #1060551] Fri, 14 June 2013 05:23 Go to previous message
Ozgur Cagdas is currently offline Ozgur Cagdas
Messages: 28
Registered: May 2013
Junior Member
@Miroslav,

Don't you get any compilation/launching errors when you haven't got the javax.annoation imported? Could you have checked the 'Always launch without asking' box on the Error notification pop up?
Previous Topic:Standalone e4 RCP application, DI doesn't work
Next Topic:Ctrl+ (C/X/A) doesn't work with Mozilla Browser with Eclipse E4 on Windows
Goto Forum:
  


Current Time: Thu Apr 24 11:22:17 EDT 2014

Powered by FUDForum. Page generated in 0.01844 seconds