Why can't I add the bean child class of the bean class of the abstract parent class

I have a parameterized abstract class with one parameterized constructor:

public abstract class BasicEntidadController<T extends Entidad> implements Serializable { public BasicEntidadController(EntidadBean<T> entidadSessionBean) {....} // other methods } 

and a child class extending it:

 @SessionScoped @Named public class TiendaController extends BasicEntidadController<Tienda> implements Serializable {...} 

and WELD reports an error telling me that the "BasicEntidadController" is not proxy ....

 org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001435 Normal scoped bean class org.wgualla.sandbox.entity.BasicEntidadController is not proxyable because it has no no-args constructor - Managed Bean [class org.wgualla.sandbox.tienda.TiendaController] with qualifiers [@Any @Default @Named]. 

Why is WELD trying to create a proxy for this abstract / no-bean class ???

Should I execute all classes, in the inheritance tree, proxy files, if I want to use / use in the EL element only the last child element in the tree?

Thanks in advance.

+4
source share
1 answer

By definition, java bean has "the class must have an open default constructor (no arguments)."

See http://en.wikipedia.org/wiki/JavaBeans#JavaBeans_API

I would suggest that you change your constructor to

 public BasicEntidadController() {....} // other methods 

and then add the setter method

 setEntidadSessionBean(EntidadBean<T> entidadSessionBean) 

Or even better - read about dependency injection. Then you can use something like

 @Autowired EntidadBean<T> entidadSessionBean; 

See http://www.vogella.com/articles/SpringDependencyInjection/

Hope this helps

+2
source

Source: https://habr.com/ru/post/1488567/


All Articles