Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
vaadin-spring and @Autowired woes
Hi,
I've started writing a Vaadin 7 web app which also uses Spring JPA and Spring CDI.
The DB access part is split off into a sub project (for re-use by another project), and the Vaadin UI uses this sub project.
To use the backend layer, and to allow the UI to access DAO/Service classes via @Autowired annotations, I added the vaadin-spring library to the project defs, and followed the directions at <https://vaadin.com/wiki?p_p_id=36&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=row-1&p_p_col_pos=1&p_p_col_count=3&_36_struts_action=%2Fwiki%2Fview&p_r_p_185834411_nodeName=vaadin.com+wiki&p_r_p_185834411_title=I+b+-+Getting+started+with+Vaadin+Spring+without+Spring+Boot>.
I could get the web app to start up, the configured DAO objects are scanned by spring (according to log messages), BUT I also added a DAO class as an @Autowired field to an UI - and this field stays at null, i.e. @Autowired does not work at this place.
This UI class is not a subclass of UI, but only a part of an UI, btw - is this a problem?
The main problem for me is - how can I track down the source of this bug? I have no idea where to even start here...
With greetings from Vienna,
Wolfgang Liebich
Hi, is your "injection chain" working? You can only use @Autowired if the object where you use it is a spring managed bean (e.g. created by @Autowired annotation in other spring managed bean. If you instantiate your object with "new" keyword, Autowired fields will be null.
cheers,
matti
Matti Tahvonen: Hi, is your "injection chain" working? You can only use @Autowired if the object where you use it is a spring managed bean (e.g. created by @Autowired annotation in other spring managed bean. If you instantiate your object with "new" keyword, Autowired fields will be null.
cheers,
matti
Hi,
Thanks - yes, that was the root of all evil at work here (I'm rather new at Spring). I found two solutions aout of this problem - in
https://vaadin.com/forum#!/thread/11090891/11107003 I describe my soluti