I'm trying to porting an E3.X application to E4 and following an tutorial by Lars Vogel. I created a view wrapper which extends the DIViewPart class, the view itself which uses dependency injection on the constructor and referenced the view wrapper in my plugin.xml.
However, when firing up the application an exception is thrown:
org.eclipse.e4.core.di.InjectionException: Could not find satisfiable constructor in my.application.views.MyView
I have no idea what is going wrong even after several hours of googling. Maybe I'm just searching for the wrong things, but I'm pretty clueless right now. I would be happy if someone could point me out what I'm missing.
Just to be sure I appended the affected views source code below:
public class MyViewWrapper extends DIViewPart {
public MyViewWrapper() {
super(MyView.class);
}
}
public class MyView {
public static final String ID = MyView.class.getCanonicalName();
private Label label;
@Inject
public MyView(Composite parent) {
this.label = new Label(parent, SWT.NONE);
this.label.setText("My view");
}
}
Any help is appreciated and thanks in advance.
Edit: Stefan pointed out that the issue might be related to the fact that e4 does not know the right composite during the constructor call and that the following code should do the trick:
public class MyView {
public static final String ID = MyView.class.getCanonicalName();
private Label label;
public MyView() { }
@PostConstruct
public void createPartControl(Composite parent) {
this.label = new Label(parent, SWT.NONE);
this.label.setText("Sensor view");
}
}
Sadly this was not the case. The exception changed but the cause might still be the same:
org.eclipse.e4.core.di.InjectionException: Unable to find matching method to invoke
My assumption is that dependency injection as a whole is not working correctly, but I have no idea why, since I've done everything exactly as in the tutorials I've found. Do I need to add a .e4xmi or something?