It's a chicken and egg problem - you're wiring up your use case class through 
spring config.  Since it's not done loading, you can't use it to inject things 
during the constructor of your spring-configured usecase class.

I'd suggest just using Spring config to inject the DAOs into your usecase 
class.  

Jeremy Thomerson
http://www.wickettraining.com
-- sent from a wireless device


-----Original Message-----
From: Per Newgro <[EMAIL PROTECTED]>
Sent: Sunday, June 15, 2008 8:31 AM
To: wicket-ug <[email protected]>
Subject: Spring - InjectorHolder has not been assigned an injector

Hi *,

i've read almost every thread in mailing list or wiki but i can't get my stuf 
to work. I derived my application layout from Igors++ phone book example. SO 
far it was pretty easy. The daos have been injected via @SpringBean in the 
page. Because i had some business logic and i don't want it in my pages, i've 
externalized it into an usecase class. Until now i've delivered the daos to 
the usecase while calling the method (doMyStuff(myDao)). So far so good. 

My next step was to externalize the daos. They should be injected in my 
usecase. But they wasn't. So i've read the threads an came up with

public MyUsecase() {
  InjectorHolder.getInjector().inject(this);
}

but now i get 

ERROR - log                        - Failed startup of context 
[EMAIL PROTECTED]/,src/main/webapp}
org.springframework.beans.factory.BeanCreationException: Error creating bean 
with name 'myUC' defined in class path resource [usecases.xml]: Instantiation 
of bean failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Could not instantiate 
bean class [org.tipchamp.usecase.MyUsecase]: Constructor threw exception; 
nested exception is java.lang.IllegalStateException: InjectorHolder has not 
been assigned an injector. Use InjectorHolder.setInjector() to assign an 
injector. In most cases this should be done once inside SpringWebApplication 
subclass's init() method.
Caused by: 
org.springframework.beans.BeanInstantiationException: Could not instantiate 
bean class [org.tipchamp.usecase.MyUsecase]: Constructor threw exception; 
nested exception is java.lang.IllegalStateException: InjectorHolder has not 
been assigned an injector. Use InjectorHolder.setInjector() to assign an 
injector. In most cases this should be done once inside SpringWebApplication 
subclass's init() method.
Caused by: 
java.lang.IllegalStateException: InjectorHolder has not been assigned an 
injector. Use InjectorHolder.setInjector() to assign an injector. In most 
cases this should be done once inside SpringWebApplication subclass's init() 
method.
        at 
org.apache.wicket.injection.web.InjectorHolder.getInjector(InjectorHolder.java:64)
        at org.tipchamp.usecase.MyUsecase.<init>(MyUsecase.java:50)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

Can someone push me out here please?
Thanks
Per

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to