@ Propiedad lateinit autocadenada '' no se ha inicializado

Intento crear un proyecto web usando Spring-boot + Vaadin y quiero usar spring-data-jpa con hibernate para recuperar los datos de la database PostgreSQL.

En mi opinión de Vaadin, trato de conectar automáticamente mi class de service pero siempre obtengo nulo y el seguimiento de la stack eror no me dice por qué.

kotlin.UninitializedPropertyAccessException: la propiedad lateinit clientService no se ha inicializado en com.apache.vaadin.view.Index.getClientService (Index.kt: 24) ~ [classes /: na] en com.apache.vaadin.view.Index $ readButton $ 1 .buttonClick (Index.kt: 40) ~ [classes /: na] at sun.reflect.NativeMethodAccessorImpl.invoke0 (Método nativo) ~ [na: 1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62 ) ~ [na: 1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) ~ [na: 1.8.0_131] en java.lang.reflect.Method.invoke (Method.java:498) ~ [na: 1.8.0_131] en com.vaadin.event.ListenerMethod.receiveEvent (ListenerMethod.java:510) ~ [vaadin-server-8.0.6.jar: 8.0.6] en com.vaadin.event.EventRouter.fireEvent (EventRouter.java:211) ~ [vaadin-server-8.0.6.jar: 8.0.6] en com.vaadin.event.EventRouter.fireEvent (EventRouter.java:174) ~ [vaadin-server-8.0.6. jar: 8.0.6] en com.vaadin.server.AbstractClientConnector.fireEvent (AbstractClientConnector.java:102 9) ~ [vaadin-server-8.0.6.jar: 8.0.6] en com.vaadin.ui.Button.fireClick (Button.java:370) ~ [vaadin-server-8.0.6.jar: 8.0.6 ] en com.vaadin.ui.Button $ 1.click (Button.java:57) ~ [vaadin-server-8.0.6.jar: 8.0.6] en sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) ~ [na : 1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) ~ [na: 1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) ~ [na: 1.8.0_131 ] en java.lang.reflect.Method.invoke (Method.java:498) ~ [na: 1.8.0_131] en com.vaadin.server.ServerRpcManager.applyInvocation (ServerRpcManager.java:155) ~ [vaadin-server-8.0 .6.jar: 8.0.6] en com.vaadin.server.ServerRpcManager.applyInvocation (ServerRpcManager.java:116) ~ [vaadin-server-8.0.6.jar: 8.0.6] en com.vaadin.server.communication .ServerRpcHandler.handleInvocation (ServerRpcHandler.java:445) [vaadin-server-8.0.6.jar: 8.0.6] en com.vaadin.server.communication.ServerRpcHandler.handleInvocations (ServerRpcHandler.java:41) 0) [vaadin-server-8.0.6.jar: 8.0.6] en com.vaadin.server.communication.ServerRpcHandler.handleRpc (ServerRpcHandler.java:274) [vaadin-server-8.0.6.jar: 8.0.6 ] en com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest (UidlRequestHandler.java:90) [vaadin-server-8.0.6.jar: 8.0.6] en com.vaadin.server.SynchronizedRequestHandler.handleRequest (SynchronizedRequestHandler.java: 41) [vaadin-server-8.0.6.jar: 8.0.6] en com.vaadin.server.VaadinService.handleRequest (VaadinService.java:1464) [vaadin-server-8.0.6.jar: 8.0.6] en com.vaadin.server.VaadinServlet.service (VaadinServlet.java:381) [vaadin-server-8.0.6.jar: 8.0.6] en javax.servlet.http.HttpServlet.service (HttpServlet.java:742) [tomcat -embed-core-8.5.15.jar: 8.5.15] en org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:231) [tomcat-embed-core-8.5.15.jar: 8.5.15 ] en org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.15.jar: 8.5.1 5] en org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:52) [tomcat-embed-websocket-8.5.15.jar: 8.5.15] en org.apache.catalina.core.ApplicationFilterChain .internalDoFilter (ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.15.jar: 8.5.15] en org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) [tomcat-embed- core-8.5.15.jar: 8.5.15] en org.springframework.web.filter.RequestContextFilter.doFilterInternal (RequestContextFilter.java:99) [spring-web-4.3.9.RELEASE.jar: 4.3.9.RELEASE] en org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107) [spring-web-4.3.9.RELEASE.jar: 4.3.9.RELEASE] en org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.15.jar: 8.5.15] en org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) [tomcat-embed-core- 8.5.15.jar: 8.5.15] en org.springframework.web.filter.HttpPutFormContentF ilter.doFilterInternal (HttpPutFormContentFilter.java:105) [spring-web-4.3.9.RELEASE.jar: 4.3.9.RELEASE] en org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107) [spring -web-4.3.9.RELEASE.jar: 4.3.9.RELEASE] en org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.15.jar: 8.5 .15] en org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.15.jar: 8.5.15] en org.springframework.web.filter.HiddenHttpMethodFilter. doFilterInternal (HiddenHttpMethodFilter.java:81) [spring-web-4.3.9.RELEASE.jar: 4.3.9.RELEASE] en org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107) [spring-web -4.3.9.RELEASE.jar: 4.3.9.RELEASE] en org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.15.jar: 8.5.15 ] en org.apache.catalina.core.ApplicationFilterChain.doFilt er (ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.15.jar: 8.5.15] en org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (CharacterEncodingFilter.java:197) [spring-web-4.3 .9.RELEASE.jar: 4.3.9.RELEASE] en org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107) [spring-web-4.3.9.RELEASE.jar: 4.3.9.RELEASE ] en org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.15.jar: 8.5.15] en org.apache.catalina.core.ApplicationFilterChain.doFilter ( ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.15.jar: 8.5.15] en org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java:198) [tomcat-embed-core-8.5 .15.jar: 8.5.15] en org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java:96) [tomcat-embed-core-8.5.15.jar: 8.5.15] en org.apache. catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase.java:478) [tomcat-embed-core-8.5. 15.jar: 8.5.15] en org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:140) [tomcat-embed-core-8.5.15.jar: 8.5.15] en org.apache.catalina .valves.ErrorReportValve.invoke (ErrorReportValve.java:80) [tomcat-embed-core-8.5.15.jar: 8.5.15] en org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java:87) [ tomcat-embed-core-8.5.15.jar: 8.5.15] en org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:342) [tomcat-embed-core-8.5.15.jar: 8.5. 15] en org.apache.coyote.http11.Http11Processor.service (Http11Processor.java:799) [tomcat-embed-core-8.5.15.jar: 8.5.15] en org.apache.coyote.AbstractProcessorLight.process (AbstractProcessorLight) .java: 66) [tomcat-embed-core-8.5.15.jar: 8.5.15] en org.apache.coyote.AbstractProtocol $ ConnectionHandler.process (AbstractProtocol.java:861) [tomcat-embed-core-8.5. 15.jar: 8.5.15] en org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun (NioEndpoint.java:1455) [tomcat-embed-core-8.5.15.jar: 8.5.15] en org .apache.tom cat.util.net.SocketProcessorBase.run (SocketProcessorBase.java:49) [tomcat-embed-core-8.5.15.jar: 8.5.15] en java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142) [na: 1.8.0_131] en java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:617) [na: 1.8.0_131] en org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run ( TaskThread.java:61) [tomcat-embed-core-8.5.15.jar: 8.5.15] en java.lang.Thread.run (Thread.java:748) [na: 1.8.0_131]

Mi configuration para la database:

@Configuration @EnableTransactionManagement @EnableJpaRepositories(basePackages = arrayOf("com.apache.vaadin.model")) @ComponentScan(basePackages = arrayOf("com.apache.vaadin.model")) open class DataSourceConfig { @Autowinetworking lateinit var environment: Environment @Bean open fun entityManagerFactory(): LocalContainerEntityManagerFactoryBean { var entityManagerFactory: LocalContainerEntityManagerFactoryBean = LocalContainerEntityManagerFactoryBean() entityManagerFactory.apply { dataSource = dataSource() setPackagesToScan("com.apache.vaadin.model") var vendorAdapter: HibernateJpaVendorAdapter = HibernateJpaVendorAdapter() vendorAdapter.apply { setGenerateDdl(true) setShowSql(true) } var properties: Properties = Properties() properties.apply { put("database.dialet", "org.hibernate.dialect.PostgreSQL95Dialect") put("database.globally_quoted_identifiers", "false") put("database.enable_lazy_load_no_trans", "true") put("database.show_sql", "true") } jpaVendorAdapter = vendorAdapter setJpaProperties(properties) } return entityManagerFactory } @Primary @Bean open fun dataSource(): DataSource { var source: ComboPooledDataSource = ComboPooledDataSource() source.apply { driverClass = "org.postgresql.Driver" jdbcUrl = "jdbc:postgresql://localhost:5432/ignite" user = "postgres" password = "1111" acquireIncrement = 5 idleConnectionTestPeriod = 60 maxPoolSize = 20 minPoolSize = 10 initialPoolSize = 10 } return source } @Bean open fun transactionManager() : PlatformTransactionManager { var manager: JpaTransactionManager = JpaTransactionManager() manager.apply { entityManagerFactory = entityManagerFactory().nativeEntityManagerFactory } return manager } @Bean open fun exceptionTranslator(): PersistenceExceptionTranslationPostProcessor = PersistenceExceptionTranslationPostProcessor() } 

Vista y UI:

 @SpringUI @Title(value = "Apache") class Navigator : UI() { @Autowinetworking lateinit var viewProvider: SpringViewProvider init { } private val INDEX = "" override fun init(p0: VaadinRequest?) { navigator = Navigator(this, this) navigator.addProvider(viewProvider) navigator.addView(INDEX, Index::class.java) } } @UIScope @SpringView open class Index : VerticalLayout(), View { private val logger: Logger = Logger.getLogger(Index::class.java) @Autowinetworking lateinit var clientService: IClientService // <--- error is here init { var menuBar: MenuBar = MenuBar() var file = menuBar.addItem("File", null, null) file.addItem("Save", {_ -> logger.info("Save clicked")}) file.addItem("Load", {_ -> logger.info("Load clicked")}) file.addItem("Open", {_ -> logger.info("Open clicked")}) file.addItem("Close", {_ -> logger.info("Close clicked")}) var settings = menuBar.addItem("Settings", null, null) settings.addItem("DataBase", {_ -> logger.info("DataBase clicked")}) addComponent(menuBar) var createButton: Button = Button("Create", { _ -> logger.info("Create clicked")}) var readButton: Button = Button("Read", { _ -> logger.info(clientService.findAll())}) var updateButton: Button = Button("Update", { _ -> logger.info("Update clicked")}) var deleteButton: Button = Button("Delete", { _ -> logger.info("Delete clicked")}) addComponent(createButton) addComponent(readButton) addComponent(updateButton) addComponent(deleteButton) } override fun enter(p0: ViewChangeListener.ViewChangeEvent?) { Notification.show("Welcome to the main com.ignite.app.view") } } 

pom.xml:

 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.apache.vaadin</groupId> <artifactId>ignite</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>ignite</name> <description></description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.4.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <vaadin.version>8.0.6</vaadin.version> <kotlin.version>1.1.3-2</kotlin.version> <hibernate>5.2.9.Final</hibernate> <hibernate-validator>5.4.1.Final</hibernate-validator> <postgres>42.1.1</postgres> </properties> <dependencies> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib-jre8</artifactId> <version>${kotlin.version}</version> </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-test</artifactId> <version>${kotlin.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-ehcache</artifactId> <version>${hibernate}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-c3p0</artifactId> <version>${hibernate}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>${hibernate-validator}</version> </dependency> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>${postgres}</version> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-bom</artifactId> <version>${vaadin.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-plugin</artifactId> <version>${kotlin.version}</version> <executions> <execution> <id>compile</id> <phase>compile</phase> <goals> <goal>compile</goal> </goals> </execution> <execution> <id>test-compile</id> <phase>test-compile</phase> <goals> <goal>test-compile</goal> </goals> </execution> </executions> <configuration> <jvmTarget>1.8</jvmTarget> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <executions> <execution> <id>compile</id> <phase>compile</phase> <goals> <goal>compile</goal> </goals> </execution> <execution> <id>testCompile</id> <phase>test-compile</phase> <goals> <goal>testCompile</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> 

Mi service:

 @NoRepositoryBean interface IClientService : CrudRepository<Client, Long> @Service class ClientService : IClientService { private val logger: Logger = Logger.getLogger(ClientService::class.java) @Autowinetworking lateinit var clientRepository: ClientRepository override fun delete(p0: Long?) { clientRepository.delete(p0) } override fun delete(p0: MutableIterable<Client>?) { clientRepository.delete(p0) } override fun delete(p0: Client?) { clientRepository.delete(p0) } override fun <S : Client?> save(p0: MutableIterable<S>?): MutableIterable<S> = clientRepository.save(p0) override fun <S : Client?> save(p0: S): S = clientRepository.save(p0) override fun findAll(p0: MutableIterable<Long>?): MutableIterable<Client> = clientRepository.findAll(p0) override fun findAll(): MutableIterable<Client> = clientRepository.findAll() override fun exists(p0: Long?): Boolean = clientRepository.exists(p0) override fun findOne(p0: Long?): Client = clientRepository.findOne(p0) override fun count(): Long = clientRepository.count() override fun deleteAll() { clientRepository.deleteAll() } } 

Y repository

 @Repository interface ClientRepository : CrudRepository<Client, Long> 

Project comstack correctamente, pero cuando trato de get cualquier dato de mi database obtengo este error. También traté de crear conexiones y consultas de forma manual y cuando lo hice no obtuve ningún error. Probablemente, el error en la configuration del origen de datos, pero no lo veo.

¡Gracias por tu ayuda!

Solución ACTUALIZADA :

 @SpringUI @Title(value = "Apache") class Navigator : UI() { @Autowinetworking lateinit var viewProvider: SpringViewProvider @Autowinetworking lateinit var index: Index// <- private val INDEX = "index" override fun init(p0: VaadinRequest?) { navigator = Navigator(this, this) navigator.addProvider(viewProvider) navigator.addView(INDEX, index) // <- } } @UIScope @SpringView @SpringComponent // <- open class Index : VerticalLayout(), View {...} 

    Esto se debe a que si intenta acceder a clientService en el bloque de init , no debe hacer eso, la Inyección de Dependencia de spring ocurre después de que el object se haya creado. por ejemplo:

     @Autowinetworking lateinit var clientService: IClientService init{ // v--- `clientService` is not injected by spring yet. clientService; } 

    Por otro lado, debe implementar InitializingBean para la initialization del componente de resorte, por ejemplo:

     open class Index : VerticalLayout(), View, InitializingBean { @Autowinetworking lateinit var clientService: IClientService override fun afterPropertiesSet(){ //copy your init block code here } }