Hi,
I've tried to solve this for several hours now, without success, but then
again I'm not that experienced. :-)
I have an application with Spring beans which I want to use from Wicket,
using @SpringBean. To see that Spring works fine I've tried using my bean
without the @SpringBean annotation. By having
@Override
protected void init() {
super.init();
ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
}
public UserRegistrationService getUserRegistrationService() {
return (UserRegistrationService) BeanFactoryUtils.beanOfType(ctx,
UserRegistrationService.class);
}
In my class which extends WebApplication (my Application class). It works
fine that way! So it must have something to do with how I try to use the
@SpringBean annotation.
First I have
@Override
protected void init() {
super.init();
addComponentInstantiationListener(new
SpringComponentInjector(this));
}
In my Application class and in my web.xml I have added
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
and in my Page where I try to use the UserRegistrationService I have
@SpringBean
UserRegistrationService userRegistrationService;
/**
* Constructor...
*/
public UserRegistrationPage(final PageParameters parameters) {
add(new Label("message",
userRegistrationService.takeSomeString("hello service") ));
}
But when I try this I get
" WicketMessage: Can't instantiate page using constructor public
net.mycompany.webcarrot.presentation.pages.UserRegistrationPage(org.apache.wicket.PageParameters)
and argument "
I have a complete stack trace at pastebin (to not pollute the mail with it)
http://pastebin.com/f7c12d56c
I hope someone more experienced with Wicket than me knows what's going on
here. I've tried to solve it for a couple of hours, but I can't find any
faults in it (I'm trying to follow the instructions in Wicket in Action).
Thank you for your time reading! Any help is HIGHLY appreciated! Have a nice
day!
Best regards, Kent