You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@bval.apache.org by Tim Robertson <ti...@gmail.com> on 2013/01/11 03:59:01 UTC

Method validation guice: Property list does not follow javabean conventions

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

Re: Method validation guice: Property list does not follow javabean conventions

Posted by Matt Benson <gu...@gmail.com>.
Hi Tim,
  Honestly, AFAICT, what you've tried in your validation.xml should work.
If you can cook up a small example project, I'd be glad to look further.

br,
Matt


On Thu, Jan 10, 2013 at 10:05 PM, Tim Robertson
<ti...@gmail.com>wrote:

> Ok, so I simplified the code above and there was an extra method with
> @NotNull coming in from an interface definition, so I am seeing the
> validation of return types issue.
>
> Can someone please tell me how I go about including the fix which is to
> have:
> apache.bval.metabean-factory-classnames=org.apache.bval.jsr303.extensions.
> MethodValidatorMetaBeanFactory
>
> Thanks,
> Tim
>
>
>
> On Fri, Jan 11, 2013 at 10:59 AM, Tim Robertson <timrobertson100@gmail.com
> > wrote:
>
>> 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
>>
>>
>>
>>
>

Re: Method validation guice: Property list does not follow javabean conventions

Posted by Tim Robertson <ti...@gmail.com>.
Ok, so I simplified the code above and there was an extra method with
@NotNull coming in from an interface definition, so I am seeing the
validation of return types issue.

Can someone please tell me how I go about including the fix which is to
have:
apache.bval.metabean-factory-classnames=org.apache.bval.jsr303.extensions.
MethodValidatorMetaBeanFactory

Thanks,
Tim



On Fri, Jan 11, 2013 at 10:59 AM, Tim Robertson
<ti...@gmail.com>wrote:

> 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
>
>
>
>