Vaadin Spring integration add-on doesn't work

I’m developing an application using Spring and Vaadin across SpringVaadinIntegration add-on, now when i inject the service in my main Vaadin UI class everythings work well, the problem is then i use this annotation in others class.

This is MyService

    public class MyService {
	public MyService() {
		// TODO Auto-generated constructor stub
	public String getLabel(){
		return "this is my label";
	public void saveUser(Utente utente){
		System.out.println("save user");


This is my main Vaadin UI class

    public class MyUI extends UI

    private transient ApplicationContext applicationContext;

    private MyService myService;
	private MainPanel mainPanel;
    private VerticalLayout verticalLayout; 
	protected void init(VaadinRequest request) {
		// TODO Auto-generated method stub
		verticalLayout = new VerticalLayout();
		mainPanel = new MainPanel();


in MyUI the @autowired work in fact myservice is not null while in Mainpanel doesn’t work

    public class MainPanel extends CustomComponent implements View {

	private VerticalLayout mainLayout;
	private Button button;

	MyService  secondService;
	public MainPanel() {
		// TODO add user code here
	private VerticalLayout buildMainLayout() {
		// common part: create layout
		button = new Button();
		mainLayout = new VerticalLayout();
		button.addClickListener(new Button.ClickListener() {
			public void buttonClick(ClickEvent event) {
				// TODO Auto-generated method stub
				secondService.saveUser(new Utente());

		return mainLayout;

Here where I try to save the user, the service is null. What am I doing wrong?

You don’t autowire the MainPanel instance in the MyUI class so it is not Spring-managed bean → autowiring does not apply.

Hi Mario,

Did you manage to solve this issue ? I am having similar problem, in my case I cannot autowire the service to the UI class. I had the same problem with the view class but I solved it my autowiring the constructor. I tried the same approach with UI class but it requires an empty constructor which (automatically) invoked.

I am really exhausted of dealing with this. Would you mind sending me a sample project just with a service being autowired in the UI so I can try to figure out what am I doing wrong.

I have already seen the examples at github but they are not helpful.

Best Regards,