I have a Spring Project with Wicket. I can successfully inject Services in Wicket components with @SpringBean annotation.
Now, I want to access the Spring Application Context. So I’ve declared a member variable of type ApplicationContext and annotated it with @SpringBean, just like other services as well:
trying to use @SpringBean to inject the Application
public class MyPanel extends Panel {
@SpringBean
private ApplicationContext applicationContext;
...
}
However, at runtime, this gives the error
bean of type [org.springframework.context.ApplicationContext] not found
Is it not possible to inject ApplicationContext into Wicket Components? If so, what would be a suitable way to get access to the ApplicationContext?
The ApplicationContext should be accessible in your application class.
Create a getApplicationContext method in your application class.
The application object can be accessed from any wicket component.