[jboss-jira] [JBoss JIRA] (WFLY-11956) @PostConstruct on @ApplicationScoped bean called too late in case @Valid is annotated on a business method

Guillaume Smet (Jira) issues at jboss.org
Thu Apr 25 14:06:00 EDT 2019


    [ https://issues.jboss.org/browse/WFLY-11956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13726807#comment-13726807 ] 

Guillaume Smet commented on WFLY-11956:
---------------------------------------

Hi Ron,

Well, for the first one, you'll see that the HV part does not have the value, just the root object and the property name: it's Hibernate ORM doing the value resolution in the end.

I asked on the hibernate-dev list if we could have a way to know if a class is potentially managed by ORM because it doesn't make sense to ask ORM if a property is loaded if the root object is not managed by ORM.

The issue is that we are talking JPA here as the current model supports potentially having several persistence providers.

About your getter question: Bean Validation really supposes that your objects are following the Java Beans specification.

> @PostConstruct on @ApplicationScoped bean called too late in case @Valid is annotated on a business method
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: WFLY-11956
>                 URL: https://issues.jboss.org/browse/WFLY-11956
>             Project: WildFly
>          Issue Type: Bug
>          Components: Bean Validation, REST
>    Affects Versions: 16.0.0.Final
>            Reporter: Joerg Baesner
>            Assignee: Ronald Sigal
>            Priority: Major
>         Attachments: logging.txt, playground.zip
>
>
> Having a bean class with {{@ApplicationScoped}}, which has a {{@PostConstruct}} and is implementing  the following _Interface_:
> {code}
> @Path("/validated")
> public interface ValidatedJaxRsInterface {
>     
>     @GET
>     @Valid
>     @Produces(MediaType.APPLICATION_JSON)
>     GreetingModel getHelloGreeting();
> }
> {code}
> will result in calling the {{getHelloGreeting}} method of the implementation class twice *_before_* the {{@PostConstruct}} is getting executed.
> This can be reproduced with the attached reproducer application...



--
This message was sent by Atlassian Jira
(v7.12.1#712002)


More information about the jboss-jira mailing list