Kent,
I am using 1.3.5 fine with springbean.
some differences that I see between your/mine is that I have the
"protected" modifier.
Mine:
@SpringBean(name = "eventService")
protected EventService eventService;
another difference:
Try adding a slash to the beginning of your spring path
<param-value>classpath:/applicationContext.xml</param-value>
Do you have a bean by the name of userRegistrationService" in your
spring context?
In your code, you are just requesting a bean of the type, not by id.
try doing a ctx.getBean("userRegistrationService") and make sure it's
not null.
HTH
Phillip
On Jan 19, 2009, at 3:30 PM, Kent Larsson wrote:
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