Binder partially

If i have and Entity with several properties and i want to bind it with a form but not with all properties. How can i do it?

Entity with three properties

@Entity public Class Person { // with some bean validation anottations private String p1; private String p2; private String p3; ... } Form with only two fields with the same names of the properties

public Form extends FormLayout{ private TextField p1; private TextField p2; ... } Then bind

BeanValidationBinder<Person> binder = BeanValidation<>(Person.class)

// binder.bindInstaceFields(form) ?


When i deployed Wildfly complain about a NullPointer but the project appear runs perfect in the browser.
I suppose that the nullpointer is about property p3.

One solution would be create a superClass the person with p1 or p2 properties. Is it another?


Where is the null pointer coming from? Can you give a stack trace? I’m thinking this might be more of a bean validation issue than a Binder issue.


Perhaps you are right because in my project i load some data of Entities with restriction but unfortunatelly o don’t know what is happening. The project doesn’t start because of nullpointer exception.

This is the stack trace

20:58:41,146 ERROR []
(DeploymentScanner-threads - 1) WFLYCTL0013: Operation (“deploy”) failed - address: ([(“deployment” => “pra3.war”)]
) - failure description: {“WFLYCTL0080: Failed services” => {"jboss.deployment.unit."pra3.war".

WeldStartService" => "Failed to start service
Caused by: org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:

Exception 0 :
at sun.reflect.annotation.TypeAnnotationParser.mapTypeAnnotations(
at sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedTypeBaseImpl.(
at sun.reflect.annotation.AnnotatedTypeFactory.buildAnnotatedType(
at sun.reflect.annotation.TypeAnnotationParser.buildAnnotatedType(
at java.lang.reflect.Field.getAnnotatedType(
at org.hibernate.validator.internal.metadata.provider.TypeAnnotationAwareMetaDataProvider.findTypeAnnotationConstraintsForMember(
at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findPropertyMetaData(
at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getFieldMetaData(
at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.retrieveBeanConfiguration(
at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getBeanConfiguration(
at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getBeanConfigurationForHierarchy(
at org.hibernate.validator.internal.metadata.BeanMetaDataManager.createBeanMetaData(
at org.hibernate.validator.internal.metadata.BeanMetaDataManager.getOrCreateBeanMetaData(
at org.hibernate.validator.internal.metadata.BeanMetaDataManager.getBeanMetaData(
at org.hibernate.validator.internal.engine.ValidatorImpl.getConstraintsForClass(
at org.hibernate.validator.internal.cdi.ValidationExtension.determineConstrainedCallables(
at org.hibernate.validator.internal.cdi.ValidationExtension.processAnnotatedType(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(
at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(
at org.jboss.weld.injection.MethodInvocationStrategy$SimpleMethodInvocationStrategy.invoke(
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(
at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(
at org.jboss.weld.event.ObserverMethodImpl.notify(
at org.jboss.weld.bootstrap.BeanDeployer.processAnnotatedTypes(
at org.jboss.weld.bootstrap.BeanDeployment.createTypes(
at org.jboss.weld.bootstrap.WeldStartup.startInitialization(
at org.jboss.weld.bootstrap.WeldBootstrap.startInitialization(
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(
at org.jboss.msc.service.ServiceControllerImpl$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$
20:58:41,240 INFO []
(DeploymentScanner-threads - 1) WFLYSRV0010: Deployed “pra3.war” (runtime-name : “pra3.war”)
20:58:41,240 INFO []
(DeploymentScanner-threads - 1) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.deployment.unit.“pra3.war”.WeldStartService: Failed to start service

And my GitHub project


OK i found it something

My dependencies now are:

Caused by: org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:
Exception 0 :

If i omitted cdi-api and @Email restriction runs ok

I thought that it was neccessary (bean validation)

But if i put them in the POM i’ve got the next error:

Caused by: javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint ‘javax.validation.constraints.Email’ validating type ‘java.lang.String’. Check configuration for ‘email’

It seems that i need another dependency.
Any site to study better the plugin dependencies?

Maybe something like this:


Thanks Olli for the link.
After i read nothing change (well i understand a little why these dependencies)
i added:
validation-api (specification)
hibernate-validator (implementation)

Still the runtime error

Caused by: javax.ejb.EJBException: javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint ‘javax.validation.constraints.Email’ validating type ‘java.lang.String’. Check configuration for ‘email’

I read the cause and it seems that the container doesn’t find the validator to @Email annotation.

In the webinar “JPA bets practice” with the code jpa-adressbook it doesn’t use any of these dependencies (only deltaspike and vaadin-cdi).

Looks like in

they are using this to validate an email address String:

@Pattern(regexp = ".+@.+\\.[a-z]
+", message = "Must be valid email")
private String email;

For me it helped to patch WildFly with hibernate validators. See the chapter “1.1.4. Updating Hibernate Validator in WildFly” of the following article: