سؤال

I'm developing an IceFaces application, targeting multiple application server platforms. One of the targeted servers is JBoss AS 7.2, but validating my entites over it results in strange behaviour. In an entity, I set up the following contraints for an Integer field, which bound to an input field:

@Min(value=1)
@Max(value=99)
@Column(name = "ORDER")
private Integer order;

By specification null values are considered valid. This is exactly what happens over Weblogic 12c. But with JBoss, when I submit a null value, a javax.validation.ConstraintViolationException thrown. Moreover the default converter (if I let it) converts the null value to zero. Over Weblogic it does the expected thing again: ignore null, thus leave the input field empty.

Any ideas what makes the difference, and how to overcome it?

هل كانت مفيدة؟

المحلول

If anybody encounters the same problem, here is a solution that could help: Looks like Tomcat (the servlet container of JBoss) always converts null values, thus empty input field values to zero, if the field is bound to a Number instance. But zero obviously less then the given contraint (min 1), so persisting the entity generates an exception.

Setting the following JVM option fixes the problem: -Dorg.apache.el.parser.COERCE_TO_ZERO=false

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top