Server side gwt-validation doesn't work (?)

200 views
Skip to first unread message

Nicolas.Rocca

unread,
Dec 6, 2011, 10:46:15 AM12/6/11
to Google Web Toolkit, vsomm...@googlemail.com
We use gwt-validation-2.0-BETA-SNAPSHOT-r269.jar and GWT 2.4.
The field of the entity is annotated with
javax.validation.constraints.NotNull
Client side validation works and also server side validation in hosted
mode (jetty).

But when deployed in tomcat (6.0.20), we get the following exception
when server side validation is invoked:

Caused by: javax.validation.UnexpectedTypeException: No validator was
found for javax.validation.constraints.NotNull with type
[...deleted...]
at
com.em.validation.client.CoreValidatorImpl.validateConstraint(CoreValidatorImpl.java:
372)
at
com.em.validation.client.CoreValidatorImpl.validateValue(CoreValidatorImpl.java:
202)
at
com.em.validation.client.CoreValidatorImpl.validateProperty(CoreValidatorImpl.java:
119)
at
com.em.validation.client.CoreValidatorImpl.validate(CoreValidatorImpl.java:
76)
at
com.em.validation.client.CoreValidatorImpl.validate(CoreValidatorImpl.java:
96)
at com.em.validation.client.ValidatorImpl.validate(ValidatorImpl.java:
48)
at ...

Our war-file contains the gwt-validation-2.0-BETA-SNAPSHOT-r269.jar
and also the validation-api-1.0.0.GA.jar.

Replacing the gwt-validation-2.0-BETA-SNAPSHOT-r269.jar in the war
file with hibernate-validator-4.2.0.Final.jar seems to fix the problem
(as a workaround).

Thanks for help in advance!

Nick Chalko

unread,
Dec 6, 2011, 12:22:53 PM12/6/11
to google-we...@googlegroups.com, vsomm...@googlemail.com
Partially Correct,  Try just adding the hibernate-validator jar. and leave the GWT one in place.

To have server side validation you need hibernate or some other vilidation provider like apache-bval.  

GWT validation only handles the client side part

Nicolas.Rocca

unread,
Dec 7, 2011, 4:01:40 AM12/7/11
to Google Web Toolkit
Hi Nick,

unfortunately, this doesn't work. With both jars, I get the same
error.
I also wonder why the dependencies-list (http://code.google.com/p/gwt-
validation/wiki/Dependencies) of gwt-validation doesn't mention any
validation framework like hibernate if it is really necessary. Doesn't
gwt-validation provide own client AND server side validators?

Ashwin Desikan

unread,
Dec 7, 2011, 6:21:01 AM12/7/11
to google-we...@googlegroups.com, Nicolas.Rocca
It may be the version of hibernate validator you are using.

I have the following def in my project POM and it works fine

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.1.0.Final</version>
<exclusions>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>


Thanks
Ashwin

Nicolas.Rocca

unread,
Dec 7, 2011, 7:27:05 AM12/7/11
to Google Web Toolkit
Thanks for your pom snippet. But my problem is not the hibernate
validator. I use this just as a workaround. The problem is that in my
opinion it shouldn't be necessary to use hibernate-validator at all! I
use it just as a replacement for gwt-validation-2.0-BETA-SNAPSHOT-
r269.jar which doesn't seem to work correctly.

Nicolas.Rocca

unread,
Dec 7, 2011, 10:50:01 AM12/7/11
to Google Web Toolkit
Further investigations:

After some debugging, I found out that in the class
com.em.validation.rebind.scan.ClassScanner ,
"this.reflections.getSubTypesOf(ConstraintValidator.class)" returns an
empty list (while it is filled in hosted mode). But I couldn't find
out why.

I tried to replace the gwt-validation-2.0-BETA-SNAPSHOT-r269.jar with
hibernate-validator-4.2.0.Final.jar in the final .war with the
following maven config:
<dependency>
<groupId>com.em</groupId>
<artifactId>gwt-validation</artifactId>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>

<version>4.2.0.Final</version>
<scope>runtime</scope>
</dependency>

This worked in tomcat now, but made the hosted mode crash:
00:00:21,970 [ERROR] Line 1: The type org.joda.time.ReadableInstant
cannot be resolved. It is indirectly referenced from required .class
files

:-(

chris.ruffalo

unread,
Dec 7, 2011, 1:28:32 PM12/7/11
to Google Web Toolkit
The Reflections library that gwt-validation uses to mine the classpath
for information does not seem to work at all in a containerized
environment.

See: http://code.google.com/p/gwt-validation/issues/detail?id=52 for
more information.

Reply all
Reply to author
Forward
0 new messages