Moin
Ich versuche mich gerade an Vaadin und wollte damit eine Form erstellen.
Sobald ich in die meine Form Klasse einen Datepicker
erstelle bekomme ich eine Exception.
Erstelle ich den Datepicker in der Main bekomme ich aber keine Exception.
Was übersehe ich hier ?
Grüße und danke.
Form Klasse
Exception
Ich versuche mich gerade an Vaadin und wollte damit eine Form erstellen.
Sobald ich in die meine Form Klasse einen Datepicker
Code:
DatePicker datePicker = new DatePicker();
Erstelle ich den Datepicker in der Main bekomme ich aber keine Exception.
Was übersehe ich hier ?
Grüße und danke.
Form Klasse
Code:
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.datepicker.DatePicker;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.component.timepicker.TimePicker;
import de.laprison.vaadin.uicomponents.fields.ComboBoxes;
import de.laprison.vaadin.uicomponents.fields.DateTimePickers;
import de.laprison.vaadin.uicomponents.fields.TextFields;
import org.springframework.stereotype.Service;
@Service
public class ReferenceForm extends FormLayout {
private final ComboBoxes comboBoxes;
private final TextFields textFields;
private final DateTimePickers dateTimePickers;
ComboBox<String> cobo = new ComboBox<>();
TextField tfChargeNr = new TextField();
TimePicker timePicker = new TimePicker();
DatePicker datePicker = new DatePicker();
public ReferenceForm() {
addClassName("reference-view");
setSizeFull();
comboBoxes = new ComboBoxes();
textFields = new TextFields();
dateTimePickers = new DateTimePickers();
add(
configCobo(),
configChargeNr(),
configTimePicker()
);
}
Code:
2020-07-10 09:20:47.650 INFO 6032 --- [ restartedMain] dev-webpack : Started webpack-dev-server. Time: 397487874ms
Vaadin application has been deployed and started to the context path "/".
2020-07-10 09:20:47.743 WARN 6032 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'referenceForm' defined in file [D:\intellij-projects\testProjects\vaadin-testui\target\classes\de\laprison\vaadin\reference\ReferenceForm.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [de.laprison.vaadin.reference.ReferenceForm]: Constructor threw exception; nested exception is java.lang.NullPointerException
2020-07-10 09:20:47.746 INFO 6032 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-07-10 09:20:47.751 WARN 6032 --- [ restartedMain] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [Thread-4] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base@12.0.1/java.net.PlainSocketImpl.accept0(Native Method)
java.base@12.0.1/java.net.PlainSocketImpl.socketAccept(PlainSocketImpl.java:159)
java.base@12.0.1/java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:458)
java.base@12.0.1/java.net.ServerSocket.implAccept(ServerSocket.java:556)
java.base@12.0.1/java.net.ServerSocket.accept(ServerSocket.java:524)
app//com.vaadin.flow.server.DevServerWatchDog$WatchDogServer.run(DevServerWatchDog.java:58)
java.base@12.0.1/java.lang.Thread.run(Thread.java:835)
2020-07-10 09:20:47.751 WARN 6032 --- [ restartedMain] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [webpack] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base@12.0.1/java.io.FileInputStream.readBytes(Native Method)
java.base@12.0.1/java.io.FileInputStream.read(FileInputStream.java:273)
java.base@12.0.1/java.io.BufferedInputStream.read1(BufferedInputStream.java:290)
java.base@12.0.1/java.io.BufferedInputStream.read(BufferedInputStream.java:351)
java.base@12.0.1/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
java.base@12.0.1/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
java.base@12.0.1/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
java.base@12.0.1/java.io.InputStreamReader.read(InputStreamReader.java:185)
java.base@12.0.1/java.io.BufferedReader.fill(BufferedReader.java:161)
java.base@12.0.1/java.io.BufferedReader.readLine(BufferedReader.java:326)
java.base@12.0.1/java.io.BufferedReader.readLine(BufferedReader.java:392)
app//com.vaadin.flow.server.DevModeHandler.readLinesLoop(DevModeHandler.java:488)
app//com.vaadin.flow.server.DevModeHandler.lambda$logStream$2(DevModeHandler.java:456)
app//com.vaadin.flow.server.DevModeHandler$$Lambda$650/0x00000008015b4840.run(Unknown Source)
java.base@12.0.1/java.lang.Thread.run(Thread.java:835)
2020-07-10 09:20:47.758 INFO 6032 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-10 09:20:47.767 ERROR 6032 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'referenceForm' defined in file [D:\intellij-projects\testProjects\vaadin-testui\target\classes\de\laprison\vaadin\reference\ReferenceForm.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [de.laprison.vaadin.reference.ReferenceForm]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1320) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at de.laprison.vaadin.Application.main(Application.java:14) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.2.0.RELEASE.jar:2.2.0.RELEASE]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [de.laprison.vaadin.reference.ReferenceForm]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:213) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1312) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
... 22 common frames omitted
Caused by: java.lang.NullPointerException: null
at com.vaadin.flow.component.datepicker.DatePicker.<init>(DatePicker.java:89) ~[vaadin-date-picker-flow-2.1.0.jar:na]
at com.vaadin.flow.component.datepicker.DatePicker.<init>(DatePicker.java:76) ~[vaadin-date-picker-flow-2.1.0.jar:na]
at de.laprison.vaadin.reference.ReferenceForm.<init>(ReferenceForm.java:26) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) ~[na:na]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) ~[na:na]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:200) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
... 24 common frames omitted