[
https://issues.apache.org/jira/browse/WICKET-6607?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Lukas Korten updated WICKET-6607:
---------------------------------
Description:
We are currently building a SpringBoot application with Wicket 8.1.0 and using
Constructor injection in the service layer. If a service that follows this
approach is injected into a Wicket component, the already known issue,
[reported on
stackoverflow|https://stackoverflow.com/questions/35260608/wicket-springbean-and-spring-autowired-with-injection-via-constructor],
occurs:
{code:java}
java.lang.IllegalArgumentException: Superclass has no null constructors but no
arguments were given at
net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:931)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:631)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:329)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.proxy.Enhancer.generate(Enhancer.java:492) ~[cglib-3.2.6.jar:na]
at
net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
~[cglib-3.2.6.jar:na] at
java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_131] at
net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:480)
~[cglib-3.2.6.jar:na] at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:305)
~[cglib-3.2.6.jar:na] at
org.apache.wicket.proxy.LazyInitProxyFactory.createProxy(LazyInitProxyFactory.java:192)
~[wicket-ioc-8.1.0.jar:8.1.0] at
org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:166)
~[wicket-spring-8.1.0.jar:8.1.0] at
org.apache.wicket.injection.Injector.inject(Injector.java:111)
~[wicket-ioc-8.1.0.jar:8.1.0]
{code}
The workaround for that issue is to use Objenesis.
But now another error occurs as soon as the spring-bean is used in a listener,
e.g. in an onClick method of an AjaxLink. The Spring-Bean itself can be
resolved in the onClick, but not its dependencies, these are then null.
I have attached a simple example project to reproduce the problem.
The attached application can be started with the command "gradlew bootrun".
After that the HomePage can be reached under localhost:8080. This page contains
a single link in whose onClick method the described Spring-Bean is used. When
you click on this link, a NullpointerException flies. This depends on the point
that the dependencies of the bean can no longer be resolved and are therefore
null.
was:
We are currently building a SpringBoot application with Wicket 8.1.0 and using
Constructor injection in the service layer. If a service that follows this
approach is injected into a Wicket component, the already known issue,
[reported on
stackoverflow|https://stackoverflow.com/questions/35260608/wicket-springbean-and-spring-autowired-with-injection-via-constructor],
occurs:
{code:java}
java.lang.IllegalArgumentException: Superclass has no null constructors but no
arguments were given at
net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:931)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:631)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:329)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.proxy.Enhancer.generate(Enhancer.java:492) ~[cglib-3.2.6.jar:na]
at
net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
~[cglib-3.2.6.jar:na] at
java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_131] at
net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291)
~[cglib-3.2.6.jar:na] at
net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:480)
~[cglib-3.2.6.jar:na] at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:305)
~[cglib-3.2.6.jar:na] at
org.apache.wicket.proxy.LazyInitProxyFactory.createProxy(LazyInitProxyFactory.java:192)
~[wicket-ioc-8.1.0.jar:8.1.0] at
org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:166)
~[wicket-spring-8.1.0.jar:8.1.0] at
org.apache.wicket.injection.Injector.inject(Injector.java:111)
~[wicket-ioc-8.1.0.jar:8.1.0]
{code}
The workaround for that issue is to use Objenesis.
But now another error occurs as soon as the spring-bean is used in a listener,
e.g. in an onClick method of an AjaxLink. The Spring-Bean itself can be
resolved in the onClick, but not its dependencies, these are then null.
I have attached a simple example project to reproduce the problem.
> Spring Beans with constructor injection used in an AjaxLink#onClick
> -------------------------------------------------------------------
>
> Key: WICKET-6607
> URL: https://issues.apache.org/jira/browse/WICKET-6607
> Project: Wicket
> Issue Type: Bug
> Components: wicket-cdi, wicket-core
> Affects Versions: 8.1.0
> Reporter: Lukas Korten
> Priority: Major
> Attachments: wicket-di.zip
>
>
> We are currently building a SpringBoot application with Wicket 8.1.0 and
> using Constructor injection in the service layer. If a service that follows
> this approach is injected into a Wicket component, the already known issue,
> [reported on
> stackoverflow|https://stackoverflow.com/questions/35260608/wicket-springbean-and-spring-autowired-with-injection-via-constructor],
> occurs:
> {code:java}
> java.lang.IllegalArgumentException: Superclass has no null constructors but
> no arguments were given at
> net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:931)
> ~[cglib-3.2.6.jar:na] at
> net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:631)
> ~[cglib-3.2.6.jar:na] at
> net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
> ~[cglib-3.2.6.jar:na] at
> net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:329)
> ~[cglib-3.2.6.jar:na] at
> net.sf.cglib.proxy.Enhancer.generate(Enhancer.java:492) ~[cglib-3.2.6.jar:na]
> at
> net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93)
> ~[cglib-3.2.6.jar:na] at
> net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91)
> ~[cglib-3.2.6.jar:na] at
> net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
> ~[cglib-3.2.6.jar:na] at
> java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_131] at
> net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
> ~[cglib-3.2.6.jar:na] at
> net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
> ~[cglib-3.2.6.jar:na] at
> net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116)
> ~[cglib-3.2.6.jar:na] at
> net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291)
> ~[cglib-3.2.6.jar:na] at
> net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:480)
> ~[cglib-3.2.6.jar:na] at
> net.sf.cglib.proxy.Enhancer.create(Enhancer.java:305) ~[cglib-3.2.6.jar:na]
> at
> org.apache.wicket.proxy.LazyInitProxyFactory.createProxy(LazyInitProxyFactory.java:192)
> ~[wicket-ioc-8.1.0.jar:8.1.0] at
> org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:166)
> ~[wicket-spring-8.1.0.jar:8.1.0] at
> org.apache.wicket.injection.Injector.inject(Injector.java:111)
> ~[wicket-ioc-8.1.0.jar:8.1.0]
> {code}
> The workaround for that issue is to use Objenesis.
> But now another error occurs as soon as the spring-bean is used in a
> listener, e.g. in an onClick method of an AjaxLink. The Spring-Bean itself
> can be resolved in the onClick, but not its dependencies, these are then null.
> I have attached a simple example project to reproduce the problem.
> The attached application can be started with the command "gradlew bootrun".
> After that the HomePage can be reached under localhost:8080. This page
> contains a single link in whose onClick method the described Spring-Bean is
> used. When you click on this link, a NullpointerException flies. This depends
> on the point that the dependencies of the bean can no longer be resolved and
> are therefore null.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)