After upgrading from Wicket 7 to Wicket 8, page mounting does not work anymore.
In Wicket 7 I added
new AnnotatedMountScanner().scanPackage("com.example").mount(this);
in my init()
method of my AuthenticatedWebApplication
And on my page I added @MountPath("/mypage")
.
In Wicket 8 this does not work anymore and instead of /mypage
the browser URL points to wicket/bookmarkable/com.example.MyPage
, however when I manually add
mountPage("AAA", MyPage.class);
it works.
Here is my classpath with all wicket dependencies:
$ mvn dependency:tree | grep wicket [INFO] +-
org.apache.wicket:wicket-core:jar:8.0.0:compile [INFO] | +-
org.apache.wicket:wicket-request:jar:8.0.0:compile [INFO] | +-
org.apache.wicket:wicket-util:jar:8.0.0:compile [INFO] +-
org.wicketstuff:wicketstuff-annotation:jar:8.0.0:compile [INFO] +-
org.apache.wicket:wicket-spring:jar:8.0.0:compile [INFO] | -
org.apache.wicket:wicket-ioc:jar:8.0.0:compile [INFO] +-
org.apache.wicket:wicket-datetime:jar:8.0.0-M7:compile [INFO] +-
org.apache.wicket:wicket-auth-roles:jar:8.0.0:compile [INFO] +-
de.agilecoders.wicket:wicket-bootstrap-core:jar:2.0.2:compile [INFO]
| +- de.agilecoders.wicket:jquery-selectors:jar:2.0.0:compile [INFO] | +- de.agilecoders.wicket.webjars:wicket-webjars:jar:2.0.7:compile [INFO] | +- org.apache.wicket:wicket-extensions:jar:8.0.0:compile [INFO] +- de.agilecoders.wicket:wicket-bootstrap-extensions:jar:2.0.2:compile
[INFO] +-
com.googlecode.wicket-jquery-ui:wicket-jquery-ui-plugins:jar:8.0.0-M7:compile [INFO] | -
com.googlecode.wicket-jquery-ui:wicket-jquery-ui-core:jar:8.0.0-M7:compile
But I do not want to add all mypages manually. Is it possible to also use the AnnotatedMountScanner
again in Wicket 8?
It turned out to be a class reloading issue with spring-boot devtools
.
When spring-boot-devtools
was added as dependency, the RestartClassLoader
always changed the Page Classes and Wickets Page Class Matching was out of order.
Explanation after debugging.
When my BookmarkablePageLink called getURL()
it went through normal Wicket processing of the RequestHandlers.
The crucial part began in the AbstractBookmarkableMapper#382
where Wicket tries to find out by calling checkPageClass
if the page class from the RequestHandler
matches to the class of the MountedMapper
internally represented via the pageClassProvider
.
@Override
protected boolean checkPageClass(Class<? extends IRequestablePage> pageClass)
{
return Objects.equals(pageClass, this.getPageClass());
}
As the objects were not the same (due to the use of RestartClassLoader
) my bookmarkable page did not get the URL from the MountedMapper
.