From fd92d1f134962fdd3302cd5ad575e072a3dae7bd Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 16 Jan 2017 16:42:03 +0200 Subject: Add separate modules to test Bean Validation lib necessity. (#8249) * Add separate modules to test Bean Validation lib necessity. Fixes #8141 --- server/src/main/java/com/vaadin/data/util/BeanUtil.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'server/src/main') diff --git a/server/src/main/java/com/vaadin/data/util/BeanUtil.java b/server/src/main/java/com/vaadin/data/util/BeanUtil.java index 6faef0ff89..2a6fb4834e 100644 --- a/server/src/main/java/com/vaadin/data/util/BeanUtil.java +++ b/server/src/main/java/com/vaadin/data/util/BeanUtil.java @@ -20,6 +20,7 @@ import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; @@ -229,14 +230,21 @@ public final class BeanUtil implements Serializable { private static boolean isAvailable() { try { - Class.forName("javax.validation.Validation"); + Class clazz = Class.forName("javax.validation.Validation"); + Method method = clazz.getMethod("buildDefaultValidatorFactory"); + method.invoke(null); return true; - } catch (ClassNotFoundException e) { + } catch (ClassNotFoundException | NoSuchMethodException + | InvocationTargetException e) { Logger.getLogger(BeanValidator.class.getName()) .fine("A JSR-303 bean validation implementation not found on the classpath. " + BeanValidator.class.getSimpleName() + " cannot be used."); return false; + } catch (IllegalAccessException | IllegalArgumentException e) { + throw new RuntimeException( + "Unable to invoke javax.validation.Validation.buildDefaultValidatorFactory()", + e); } } -- cgit v1.2.3