Skip to main content


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 11:32 Go to next message
Miroslav Lazarevic is currently offline Miroslav LazarevicFriend
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 20:48 Go to previous messageGo to next message
Miroslav Lazarevic is currently offline Miroslav LazarevicFriend
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 10:17 Go to previous messageGo to next message
Eclipse UserFriend
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 15:34 Go to previous messageGo to next message
Miroslav Lazarevic is currently offline Miroslav LazarevicFriend
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 16:24 Go to previous messageGo to next message
Miroslav Lazarevic is currently offline Miroslav LazarevicFriend
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 16:32]

Report message to a moderator

Re: Inject problem [message #1060581 is a reply to message #1060551] Mon, 27 May 2013 07:31 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
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 09:23 Go to previous message
Ozgur Cagdas is currently offline Ozgur CagdasFriend
Messages: 32
Registered: May 2013
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: Tue Apr 23 12:44:06 GMT 2024

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

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

Back to the top