9

I'm trying to use the Wicket Project 'QuickStart' with Netbeans 11, Java 11, Tomcat 10, Wicket 9, and Ubuntu 18.04.

When I install the WAR package and start it, it throws:

20-May-2020 09:23:37.067 GRAVE [] org.apache.catalina.core.StandardContext.filterStart Exception at start [wicket.quickstart]
    java.lang.ClassCastException: class org.apache.wicket.protocol.http.WicketFilter cannot be cast to class jakarta.servlet.Filter (org.apache.wicket.protocol.http.WicketFilter is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader) 

Has anyone seen this issue before and if so, what can I do to resolve this?

ti7
  • 16,375
  • 6
  • 40
  • 68
MADARASSOU David
  • 149
  • 1
  • 1
  • 5

3 Answers3

20

The issue is that Tomcat 10 uses jakarta.** packages (Jakarta EE 9) while Wicket 9.x is still based on javax.** packages (Java EE 8).

The solutions are:

  1. Use Tomcat 9.x
  2. Use https://github.com/apache/tomcat-jakartaee-migration to migrate the Wicket application (the .war file) from javax to jakarta
  3. Deploy the javax.** based application into $TOMCAT10_HOME/webapps-javaee/ folder. It will be automatically migrated to jakarta.** by Tomcat.
martin-g
  • 17,243
  • 2
  • 23
  • 35
  • Applying it to the generated jar is sometimes too late in the development process. But you can apply it to the used jars and use these in your project. See my answer below. – bebbo Feb 21 '23 at 07:26
4

Don't use Tomcat 10 yet, it works with the new jakarta packages.

Switch to version 9 instead.

svenmeier
  • 5,681
  • 17
  • 22
  • 1
    Two years later - is this still true? We actually want to switch over to tomcat 10 and resolve different javax.* and jakarta.* clashes where Wicket 10 comes into play. According to https://issues.apache.org/jira/browse/WICKET-6882, the (main?) reason that Apache Wicket 10 cannot be released yet is a non-released version of Apache commons-fileupload2. Since the current commons-fileupload 1.x shows vulnerabilities in Maven Central and fileupload 2 is still not available there, a new release of 1.x and 2.x should come soon. Thank you developers :) – user27772 May 06 '22 at 07:25
  • @user27772 The teams from the well known Java frameworks Wicket, Jetkins and Vaadin, are all still waiting for commons-fileupload: https://issues.apache.org/jira/browse/FILEUPLOAD-309 – Devabc Nov 08 '22 at 19:10
  • It seems that commons-fileupload won't be supported anymore, maybe due the fact that "it is not required from Servlet 3.1 onwards", see https://stackoverflow.com/questions/68820707/jetty-11-and-commons-fileupload. Dear Wicket developers, are there alternatives that can be used here to get Apache Wicket 10 ready? – user27772 Nov 25 '22 at 10:05
0

To make wicket 9 work with with jakarta, e.g. if using tomcat 10 or spring boot 3, you have to convert some jars. There is the tool jakartaee-migration which does this for a given jar. So apply it at least to these 4 jars and create new ones - I used -jakarta as appendix:

  • wicket-core -> wicket-core-jakarta
  • wicket-util -> wicket-util-jakarta
  • wicket-request -> wicket-request-jakarta
  • commons-fileupload -> commons-fileupload

Also create proper pom files put all together into your local/shared repository.

To use it, add the new dependencies and exclude the old ones where necessary. Run mvn dependency:tree until nothing bogus gets picked up.

Congrats - you now have wicket 9 for jakarta.

bebbo
  • 2,830
  • 1
  • 32
  • 37