1

I'm trying to migrate an ancient struts 1 application to struts 2 and upgrade to Java 17. I think I've found all the code changes I need to make, but when I deploy I get a stack trace that starts out:

java.lang.NoClassDefFoundError: jakarta/servlet/ServletContextListener

My server is apache-tomcat-10.1.5, and per Eclipse it's using Amazon Corretto JRE 17.0.6.

My maven dependencies include the following:

        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <version>6.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-convention-plugin</artifactId>
            <version>6.1.2</version>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet.jsp</groupId>
            <artifactId>jakarta.servlet.jsp-api</artifactId>
            <version>3.1.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <version>6.0.0</version>
            <scope>provided</scope>
        </dependency>

I can't escape the feeling that I'm just overlooking something simple that should be obvious to me, but I thought I had all the necessary dependencies. Any thoughts?

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
Sam
  • 25
  • 4
  • 1
    Does this answer your question? [Tomcat 10.x throws java.lang.NoClassDefFoundError on javax.servlet.\*](https://stackoverflow.com/questions/66711660/tomcat-10-x-throws-java-lang-noclassdeffounderror-on-javax-servlet) – John Williams May 26 '23 at 12:57
  • I'm not sure. What that says is that Tomcat 10 uses the jakarta.* servlet packages instead of the javax.* servlet packages, and that's why he's getting a class not found for javax/servlet/ServletRequestListener. I'm using the jakarta version everywhere, and it's saying it can't find jakarta/servlet/ServletContextListener. – Sam May 26 '23 at 13:12
  • 1
    AFAIK we're still not supporting Tomcat 10. https://stackoverflow.com/questions/73349418/does-latest-version-6-struts2-support-tomcat-10 – Dave Newton May 26 '23 at 14:07
  • 1
    If you have issues to migrate an *ancient* Struts 1 to struts 2 you should read [this](https://stackoverflow.com/a/20130845/573032). Note, Struts 2.3 is already EOL, so you have to dig into Struts docs for changes. – Roman C May 26 '23 at 14:26
  • @DaveNewton Which version do you recommend? And what's the most recent Java version I can use? – Sam May 26 '23 at 14:37
  • @Sam Which version of what? Tomcat? < 10. Java version *(likely)* doesn't matter. – Dave Newton May 26 '23 at 15:28
  • "I think I've found all the code changes I need to make" -- :D That's almost everything *(except the business logic, assuming the original app was properly architected)*. It's a non-trivial task. I'd make **sure** S2 is where you want to move to. – Dave Newton May 26 '23 at 15:33

0 Answers0