Vaadin TouchKit Spring Boot Application failing at service layer

Hi
I am using Vaadin TouchKit, Spring Boot . My application is working fine in local system . When I deploy in UAT server , view page is not autowiring service layer .So I tried through controller .That also failed.

Am I missing any configuration ?

Below is the code

@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class HrApplication extends SpringBootServletInitializer{

	public static void main(String[] args) {
		SpringApplication.run(HrApplication.class, args);
	}

My UI

/**
 * The UI's "main" class
 */
//@SuppressWarnings("serial")

// Use the TouchKit widget set for the TouchKit UI
@Widgetset("com.geomotion.hr.gwt.TouchKitSamplerWidgetSet")

// Use a custom theme
@Theme("mobiletheme")

// Cache static application files so as the application can be started
// and run even when the network is down.
@CacheManifestEnabled

// Switch to the OfflineMode client UI when the server is unreachable
@OfflineModeEnabled

// Make the server retain UI state whenever the browser reloads the app
@PreserveOnRefresh
@SpringUI(path = TouchKitHRUI.APP_ROOT)
public class TouchKitHRUI extends UI  {
		private static final long serialVersionUID = -7416079964703904927L;
	private static final Logger logger = LogManager.getLogger(TouchKitHRUI.class);
	public static final String APP_ROOT = "/hrapp";

	// TODO This is currently unused in the sampler
	private final TouchKitHRPersistToServerRpc serverRpc = new TouchKitHRPersistToServerRpc() {
		@Override
		public void persistToServer() {
			// TODO this method is called from client side to store offline data
		}
	};
	@Autowired
	TimesheetController timesheetController;

....
public static TimesheetController getTimesheetController() {
		
		logger.error("TimesheetController........ with emp:");
		return (TimesheetController) ((TouchKitHRUI) getCurrent()).timesheetController;
	}

View program


@UIScope
@SpringView()

public class SubmissionView extends NavigationView  {
...
try {
						employeeList = TouchKitHRUI.getTimesheetController().findAll();
						logger.error("employeeList 2"+employeeList);
					} catch (Exception e1) {
						 e1.printStackTrace();
						System.out.println( e1.toString()); logger.error("Here is the Error ::"+ e1.toString());
					}

I am getting **NullPointerException **at the line
employeeList = TouchKitHRUI.getTimesheetController().findAll();

Controller


@SpringComponent
@ViewScope
@UIScope
@SpringUI
public class TimesheetController implements Serializable{

	private static final Logger logger = LogManager.getLogger(TimesheetController.class);	
	@Autowired
	EmployeeService empService;
	
	public List<Employee> findAll() throws Exception {
		
		logger.error("I am inside controller");
		return empService.findAll();
	}

}

This line is not printing logger.error(“I am inside controller”);

Thanks in advance

This is a bit non-trivial. You have problems probably because Vaadin Spring add-on does not support multiple servlets out of the box. This is my first guess (I assume that you have desktop UI also).

Matti’s example is good starting point, i.e. you need to create classes analogous to here

https://github.com/mstahv/vaadin-spring-touchkit/blob/master/src/main/java/org/vaadin/tkspring/SpringAwareTouchKitServlet.java

But that is probably not enough, you most likely need also custom MobileUIProvider, something like this

/*
 * Vaadin Spring doesn't currently support multiple Servlet
 * This is helper class to overcome that
 */
public class MobileUIProvider extends SpringUIProvider {

    public MobileUIProvider(WebApplicationContext webApplicationContext) {
        super(webApplicationContext);
    }

    @Override
    protected void detectUIs() {
        // NOP
    }

    @Override
    public Class<? extends UI> getUIClass(
            UIClassSelectionEvent uiClassSelectionEvent) {
        return MobileUI.class;
    }

}

And then need to modify SpringAwareTouchKitServlet, so that MobileUIProvider is used and set servletInitialized(), roughly something like this

@Override
protected void servletInitialized() throws ServletException {
	super.servletInitialized();
	touchKitSettings = new TouchKitSettings(getService());
	final MobileUIProvider uiProvider = new MobileUIProvider(context);
	getService().addSessionInitListener(new SessionInitListener() {
		@Override
		public void sessionInit(SessionInitEvent event) {
			event.getSession().addUIProvider(uiProvider);
		}
	});		
}

I hope this helps a little bit.