Issue Type: Bug Bug
Affects Versions: 2.0.1.Final, 1.1.13.Final
Assignee: Jozef Hartinger
Created: 11/Jun/13 5:32 PM
Description:

I have a chain of decorators for a managed bean.

If they are enabled, the container tries to proxy the managed bean, although it uses the default @Dependent scope. When creating the proxy, it ignores the injected constructor with parameters and tries to use the default constructor with no parameters instead. As a result, this fails with an InstantiationException:

Exception in thread "main" org.jboss.weld.exceptions.WeldException: WELD-000033 Could not instantiate client proxy for org.jboss.weld.bean.proxy.DecorationHelper@62fa5ff3
	at org.jboss.weld.bean.proxy.DecorationHelper.createProxy(DecorationHelper.java:118)
	at org.jboss.weld.bean.proxy.DecorationHelper.getNextDelegate(DecorationHelper.java:101)
	at org.jboss.weld.injection.producer.AbstractDecoratorApplyingInstantiator.getOuterDelegate(AbstractDecoratorApplyingInstantiator.java:75)
	at org.jboss.weld.injection.producer.SubclassDecoratorApplyingInstantiator.applyDecorators(SubclassDecoratorApplyingInstantiator.java:45)
	at org.jboss.weld.injection.producer.AbstractDecoratorApplyingInstantiator.newInstance(AbstractDecoratorApplyingInstantiator.java:65)
	at org.jboss.weld.injection.producer.BasicInjectionTarget.produce(BasicInjectionTarget.java:86)
	at org.jboss.weld.injection.producer.BeanInjectionTarget.produce(BeanInjectionTarget.java:173)
	at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:157)
	at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:69)
	at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:718)
	at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:774)
	at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92)
	at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:372)
	at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:381)
	at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:72)
	at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:60)
	at org.jboss.weld.injection.producer.DefaultInjector$1.proceed(DefaultInjector.java:66)
	at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
	at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:64)
	at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:91)
	at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:158)
	at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:103)
	at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:718)
	at org.jboss.weld.event.ObserverMethodImpl.getReceiver(ObserverMethodImpl.java:302)
	at org.jboss.weld.event.ObserverMethodImpl.getReceiverIfExists(ObserverMethodImpl.java:295)
	at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:259)
	at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:240)
	at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:171)
	at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:167)
	at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:121)
	at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:114)
	at org.jboss.weld.event.EventImpl.fire(EventImpl.java:84)
	at org.jboss.weld.environment.se.Weld.initialize(Weld.java:153)
	at org.jboss.weld.environment.se.StartMain.go(StartMain.java:41)
	at org.jboss.weld.environment.se.StartMain.main(StartMain.java:52)
Caused by: java.lang.InstantiationException: com.company.mavenproject1.StandardPrinter$Proxy$_$$_Weld$Proxy$
	at java.lang.Class.newInstance0(Class.java:342)
	at java.lang.Class.newInstance(Class.java:310)
	at org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.jboss.weld.bean.proxy.DecorationHelper.createProxy(DecorationHelper.java:109)
	... 34 more

If I disable the chain of decorators, the example works as designed.

I will attach a ZIP file with the sample code.

I assess this as a critical bug because I don't want to rely on private field injection.

Environment: Weld SE with Java SE 6 on Mac OS X.
Project: Weld
Priority: Critical Critical
Reporter: Christian Schlichtherle
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira