bval-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Robertson <timrobertson...@gmail.com>
Subject Method validation guice: Property list does not follow javabean conventions
Date Fri, 11 Jan 2013 02:59:01 GMT
Hi all,

I am trying to use guice method interception on a jersey web service to
validate a posted object but I get:

javax.validation.ValidationException: error retrieving constraints for
class org.gbif.registry.ws.resources.NodeResource
...caused by:
javax.validation.ValidationException: Property list does not follow
javabean conventions.
at
org.apache.bval.jsr303.Jsr303MetaBeanFactory.processClass(Jsr303MetaBeanFactory.java:162)
at
org.apache.bval.jsr303.Jsr303MetaBeanFactory.buildMetaBean(Jsr303MetaBeanFactory.java:95)
at org.apache.bval.MetaBeanBuilder.buildForClass(MetaBeanBuilder.java:131)
at org.apache.bval.MetaBeanManager.findForClass(MetaBeanManager.java:102)
at
org.apache.bval.jsr303.ClassValidator.getConstraintsForClass(ClassValidator.java:258)
at
org.apache.bval.jsr303.extensions.MethodValidatorImpl.validateParameters(MethodValidatorImpl.java:85)
at
org.apache.bval.guice.ValidateMethodInterceptor.invoke(ValidateMethodInterceptor.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
....

My web service is very simple:

@Path("/node")
@Produces({MediaType.APPLICATION_JSON,
ExtraMediaTypes.APPLICATION_JAVASCRIPT})
@Consumes(MediaType.APPLICATION_JSON)
public class NodeResource implements NodeService {

  private final NodeService nodeService;

  @Inject
  public NodeResource(NodeService nodeService) {
    this.nodeService = nodeService;
  }

  @POST
  @Validate
  @Override
  public WritableNode create(@org.apache.bval.Validate WritableNode entity)
{
    return nodeService.create(entity);
  }
}

And WritableNode is a simple POJO with @NotNull markers on the fields.

I came across https://issues.apache.org/jira/browse/BVAL-107 which suggests
using MethodValidatorMetaBeanFactory.  Can someone please tell me how to do
that with Guice?  I tried adding this validation.xml to the CP but it did
not help.

<validation-config
    xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation=
        "http://jboss.org/xml/ns/javax/validation/configurationvalidation-configuration-1.0.xsd">
  <property
name="apache.bval.metabean-factory-classnames">org.apache.bval.jsr303.extensions.MethodValidatorMetaBeanFactory</property>
</validation-config>

Any help greatly appreciated!  I'm using bval 0.5

Thanks,
Tim

Mime
View raw message