Hi,
Wicket tries to create a proxy for your bean.
Apparently UserScopeFinder doesn't have a default constructor, which is
required for creation of a proxy class.
Easiest solution is to introduce an interface (e.g. IUserScopeFinder)
and let your bean implement that:
@SpringBean(name = "userScopeFinder")
private IUserScopeFinder userScopeFinder;
Hope this helps
Sven
On 07.03.21 09:58, Per Newgro wrote:
Hi,
i would like to extend a session (metadata) with scope of user logged in. Something like
"allowed countries", "allowed companies" and so on.
That scope is provided by a spring bean (UserScopeFinder). This bean is created
in a Configuration as a @Bean.
What i tried so far is add an ISessionListener to WebApplication and inject the
UserScopeFinder.
@com.giffing.wicket.spring.boot.context.extensions.ApplicationInitExtension
public class AuthorizationInitializer implements
com.giffing.wicket.spring.boot.context.extensions.WicketApplicationInitConfiguration
{
@Override
public void init(WebApplication webApplication) {
IAuthorizationStrategy strategy;
strategy = new ApplicationAuthorizationStrategy(new
UserRolesAuthorizer());
webApplication.getSecuritySettings().setAuthorizationStrategy(strategy);
webApplication.getSessionListeners().add(new
UserScopeInjector());
}
}
public class UserScopeInjector implements ISessionListener {
@SpringBean(name = "userScopeFinder")
private UserScopeFinder userScopeFinder;
public UserScopeInjector() {
super();
Injector.get().inject(this);
}
@Override
public void onCreated(Session session) {
System.out.println("Works");
}
}
But in that case i get:
...
Caused by: java.lang.RuntimeException: error while injecting object
[my.app.core.wicket.authorization.UserScopeInjector@283465af] of type
[my.app.core.wicket.authorization.UserScopeInjector]
at org.apache.wicket.injection.Injector.inject(Injector.java:122)
at
org.apache.wicket.spring.injection.annot.SpringComponentInjector.inject(SpringComponentInjector.java:124)
at
my.app.core.wicket.authorization.UserScopeInjector.(UserScopeInjector.java:17)
at
my.app.core.wicket.authorization.AuthorizationInitializer.init(AuthorizationInitializer.java:19)
at
com.giffing.wicket.spring.boot.starter.app.WicketBootSecuredWebApplication.init(WicketBootSecuredWebApplication.java:83)
at org.apache.wicket.Application.initApplication(Application.java:762)
at
org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:441)
... 47 common frames omitted
Caused by: java.lang.IllegalArgumentException: Superclass has no null
constructors but no arguments were given
at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:931)
at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:631)
at
net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at
net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:332)
at net.sf.cglib.proxy.Enhancer.generate(Enhancer.java:492)
at
net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:96)
at
net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:94)
at net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at
net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
at net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
at
net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:119)
at
net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:294)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:480)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:305)
at
org.apache.wicket.proxy.LazyInitProxyFactory.createProxy(LazyInitProxyFactory.java:191)
at
org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:166)
at org.apache.wicket.injection.Injector.inject(Injector.java:111)
... 53 common frames omitted
I'm a little bit lost, if my strategy is working in common. Has someone maybe
an example for me?
Thanks for your support
Per
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: