deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <strub...@yahoo.de>
Subject Re: Log error: BeanProvider shall not be used to create @Dependent scoped beans help
Date Mon, 09 Feb 2015 14:06:52 GMT
Hi Esteve!

The reason why we log this message is that there might be some @Dependent scoped beans which
need cleanup. E.g. if they implement a @PreDestroy method. This method will not get called
if you get this bean via BeanProvider#getContextualReference().

There is an own method

BeanProvider#getDependent()

which gives you a DependentProvider<T> which implements get() and destroy().
That way you can implement your code without those nasty messages. Plus you will also be able
to properly destroy your @Dependent scoped beans (if needed).

hth.


LieGrue,
strub





> On Monday, 9 February 2015, 13:52, Esteve Avilés <eavilesa@gmail.com> wrote:
> > Hi,
> 
> Please, I need some help. We have created a RestEntityExceptionsHandler
> annotated with @ExceptionHandler and the log appears with this warning
> message every second:
> 
> [Server:dev-two] 13:46:30,207 WARNING
> [org.apache.deltaspike.core.api.provider.BeanProvider]
> (ajp-lxapldes3.xarxa.interna/172.28.191.50:8209-5) BeanProvider shall not
> be used to create @Dependent scoped beans. Bean: Managed Bean [class
> cat.tmb.tdo.ocicommerce.rest.exceptionhandling.handlers.rest.RestEntityExceptionsHandler]
> with qualifiers [@Any @Default]
> 
> 
> Could you please provide some feedback?
> 
> This is the class:
> 
> import
> cat.tmb.tdo.ocicommerce.domain.exceptionhandling.OciCommerceEntityHasChildrenException;
> import
> cat.tmb.tdo.ocicommerce.domain.exceptionhandling.OciCommerceEntityNotFoundException;
> import
> cat.tmb.tdo.ocicommerce.domain.exceptionhandling.OciCommerceIncorrectModelDataException;
> import cat.tmb.tdo.ocicommerce.rest.exceptionhandling.rest.RestRequest;
> import org.apache.deltaspike.core.api.exception.control.ExceptionHandler;
> import org.apache.deltaspike.core.api.exception.control.Handles;
> import
> org.apache.deltaspike.core.api.exception.control.event.ExceptionEvent;
> 
> import javax.persistence.EntityNotFoundException;
> import javax.persistence.NoResultException;
> import javax.validation.ConstraintViolationException;
> import javax.ws.rs.core.Response;
> 
> import static cat.tmb.tdo.ocicommerce.rest.util.FluentDictionary.*;
> 
> /**
> * Entity related exceptions handling.
> *
> * @author upe00196
> */
> @ExceptionHandler
> public class RestEntityExceptionsHandler extends RestBaseHandler {
> 
>     private static final String ENTITY_HAS_CHILDREN_ERROR_CODE = 
> "0003";
>     private static final String ENTITY_NOT_FOUND_ERROR_CODE = "0004";
>     private static final String CONSTRAINT_VIOLATION_ERROR_CODE = 
> "0011";
>     private static final String INCORRECT_MODEL_DATA_ERROR_CODE = 
> "0014";
> 
>     /**
>      * Handles the case when an entity cannot be removed because it has
> children entities associated with it
>      * that should be removed first.
>      *
>      * @param evt
>      * @param builder
>      */
>     public void handleEntityHasChildren(@Handles @RestRequest
> ExceptionEvent<OciCommerceEntityHasChildrenException> evt,
>                                         Response.ResponseBuilder builder) {
>         buildResponseFromCode(
>                 ENTITY_HAS_CHILDREN_ERROR_CODE,
>                 Response.Status.CONFLICT,
>                 builder);
>         evt.handled();
>     }
> 
> 
> Thanks in advance.
> 
> Regards,
> 
> -- 
> Esteve Avilés
>

Mime
View raw message