To answer myself I post the solution, which I found with the help of AtomicGamer Dev Blog.
Since wicket-guice supports only Guice 1, Guice needs to be excluded from the wicket-guice extension.
<dependencies>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-guice</artifactId>
<version>${wicket.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.code.guice</groupId>
<artifactId>guice</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket</artifactId>
<version>${wicket.version}</version>
</dependency>
<dependencies>
The actual integrations happens in the init
method, which calls the addComponentInstantiationListener
method.
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.apache.wicket.Page;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.guice.GuiceComponentInjector;
public class NavigatorApplication extends WebApplication {
@Override
public Class<? extends Page> getHomePage() {
return Startpage.class;
}
@Override
protected void init() {
super.init();
Injector injector = Guice.createInjector(new WebAppModule());
addComponentInstantiationListener(
new GuiceComponentInjector(this, injector));
}
}