You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Christian Schlichtherle (JIRA)" <ji...@apache.org> on 2013/06/12 15:57:20 UTC

[jira] [Created] (OWB-873) NoSuchMethodException if no constructor with an empty parameter list is present AND the bean has @Decorator beans

Christian Schlichtherle created OWB-873:
-------------------------------------------

             Summary: NoSuchMethodException if no constructor with an empty parameter list is present AND the bean has @Decorator beans
                 Key: OWB-873
                 URL: https://issues.apache.org/jira/browse/OWB-873
             Project: OpenWebBeans
          Issue Type: Bug
          Components: Core, Interceptor and Decorators
    Affects Versions: 1.2.0
            Reporter: Christian Schlichtherle
         Attachments: mavenproject1.zip

In my test project, I have a {{StandardPrinter}} bean which takes a {{PrintStream}} as its sole constructor parameter. The bean archive descriptor also configures three {{@Decorator}} classes which decorate the output of the {{StandardPrinter}} bean.

Now, as a side effect of the decorator configuration, the container requires an empty-parameter list constructor for the {{StandardPrinter}} class, although this constructor is never actually called.

To reproduce the issue, build and run the attached standalone project. When run unchanged, the program succeeds and prints the decorated output:

{code}
---------- BEGIN PRINT ----------
Hello world!
----------  END PRINT  ----------
{code}

However, after removing the constructor {{ private StandardPrinter.<init>() { ... } }}, I get the following exception when running the program:

{code}
Exception in thread "main" org.apache.webbeans.proxy.ProxyGenerationException: java.lang.NoSuchMethodException: com.company.mavenproject1.StandardPrinter.<init>()
	at org.apache.webbeans.proxy.InterceptorDecoratorProxyFactory.createConstructor(InterceptorDecoratorProxyFactory.java:288)
	at org.apache.webbeans.proxy.AbstractProxyFactory.generateProxy(AbstractProxyFactory.java:211)
	at org.apache.webbeans.proxy.AbstractProxyFactory.createProxyClass(AbstractProxyFactory.java:175)
	at org.apache.webbeans.proxy.InterceptorDecoratorProxyFactory.createProxyClass(InterceptorDecoratorProxyFactory.java:186)
	at org.apache.webbeans.component.InjectionTargetBean.defineBeanInterceptorStack(InjectionTargetBean.java:172)
	at org.apache.webbeans.config.BeansDeployer.validate(BeansDeployer.java:426)
	at org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(BeansDeployer.java:392)
	at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:195)
	at org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:129)
	at com.company.mavenproject1.boot.BootWebBeans.startApplication(BootWebBeans.java:36)
	at com.company.mavenproject1.boot.BootWebBeans.run(BootWebBeans.java:27)
	at com.company.mavenproject1.boot.BootWebBeans.main(BootWebBeans.java:22)
Caused by: java.lang.NoSuchMethodException: com.company.mavenproject1.StandardPrinter.<init>()
	at java.lang.Class.getConstructor0(Class.java:2715)
	at java.lang.Class.getDeclaredConstructor(Class.java:1987)
	at org.apache.webbeans.proxy.InterceptorDecoratorProxyFactory.createConstructor(InterceptorDecoratorProxyFactory.java:266)
	... 11 more
{code}

As you can see from the constructor code, it's never actually called because it would throw a {{new AssertionError()}}.

For comparison, I get similar results from Weld, the RI implementation, except that Weld actually calls the constructor (it uses Class.newInstance() to instantiate it).

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