1

We have taken over several Java 6 webservices using Tomcat 6, in production at a customer site, which we’re attempting to upgrade to Java 11 and Tomcat 10

This software currently includes a custom XxxxxxWebActionServlet class, which extends from an old version of org.apache.struts.action.ActionServlet – this old version of struts ActionServlet currently used in production, and our current production XxxxxxWebActionServlet, both import javax.servlet.* classes

For Java 11 we have upgraded our XxxxxxWebActionServlet to import jakarta.servlet.* classes

Our upgrade results in the run-time ClassCastException shown below (from Tomcat 10’s localhost.yyyy-mm-dd.log)

Our guess is that this ClassCastException occurs because our upgraded XxxxxxWebActionServlet, which now imports jakarta.servlet., continues to extend the same older version of struts ActionServlet which imports javax.servlet. classes

After much web searching, we can’t seem to find a version of org.apache.struts.action.ActionServlet which imports jakarta.servlet.*

The last version of org.apache.struts.action.ActionServlet that we can find (in https://archive.apache.org/dist/struts/1.3.10) imports javax.servlet.* - ActionFormValidationInterceptor.java in struts-2.3.20.1 imports (but does not seem to use) org.apache.struts.action.ActionServlet, but ActionServlet.java itself does not seem to be present within struts-2.3.20.1/src

#1) Would a version of org.apache.struts.action.ActionServlet which imports jakarta.servlet.* exist somewhere else ?

#2) If not, we’d be very appreciative of any suggestions for how to circumvent this ClassCastException

Thanks very much in advance

22-Jun-2022 11:29:26.084 INFO [main] org.apache.catalina.core.ApplicationContext.log Marking servlet [action] as unavailable 22-Jun-2022 11:29:26.084 SEVERE [main] org.apache.catalina.core.StandardContext.loadOnStartup Servlet [action] in web application [/xxware] threw load() exception java.lang.ClassCastException: class com.xxxxxx.ui.web.jspframework.XxxxxxWebActionServlet cannot be cast to class jakarta.servlet.Servlet (com.xxxxxx.ui.web.jspframework.XxxxxxWebActionServlet is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @3ce3b176; jakarta.servlet.Servlet is in unnamed module of loader java.net.URLClassLoader @6ddf90b0) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1071) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1011) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4906) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5213) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1027) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:2001) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118) at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:828) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:478) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1708) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:320) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423) at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:946) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:886) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:795) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476)

Roman C
  • 49,761
  • 33
  • 66
  • 176
7579
  • 61
  • 6
  • 1
    Why do you need to move old Struts 1 app which is EOL to the new web server Tomcat 10 using new Java EE technology called Jakarta EE? – Roman C Jun 25 '22 at 14:22

2 Answers2

2

If you're still on struts 1.x, split your upgrade into multiple steps:

  • Upgrade to a currently supported version of Tomcat
  • Upgrade your Struts code to a currently supported version (or framework)

There's no need to go to Tomcat 10 and the jakarta.servlet-world. Simply upgrade to Tomcat 9. Struts 1.x is from a time that jakarta.servlet was unheard of. So you won't find them together.

When you get your current code running on Tomcat 9, examine Struts' applicability and supported versions - consider upgrading (or consider picking a different framework). You can go live with your updated version long before that (e.g. just when everything works on Tomcat 9)

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
  • Moving to another framework require skills and it is not always available for migration puporses. Even if migration is not provided by the supported framework looking to the project documentation makes sense before answering. – Roman C Jun 25 '22 at 17:48
  • It's just one of the options that i mentioned, largely because I'm unaware of the current struts story and support lifetime. I only know that 1.x reached eol a long time ago – Olaf Kock Jun 25 '22 at 20:54
  • It's not Struts story, it's just a story of the Java EE which for some reason renamed to Jakarta EE. The web server Tomcat 10 has already adapted its packages to use new servlet technology, but Struts didn't. OP is just looking for someone who might be updated Struts 1.x to Jakarta EE. I always suggested to move Struts 1.x apps to Struts 2 because it's only framework which provided support for migrating Struts 1.x apps. [Here](https://stackoverflow.com/a/20130845/573032) you can see how to do it in parts and obstacles on the way. – Roman C Jun 26 '22 at 06:12
  • Gentlemen, I sincerely apologize for not responding sooner to genuinely thank both of you for your helpful responses. Other work priorities have arisen, but I hope to be able to return to this topic soon. Thank you again. – 7579 Jul 15 '22 at 19:48
0

I'm currently working to upgrade struts1 (currently JakartaEE 8) and I think I'll reach JakartaEE 9-compatility next week (till 25. Nov. 2022).

In meantime take a look at my struts1-github-project to follow the progress: Weblegacy/Struts1

Greetings Stefan

Stefan
  • 1
  • 1
  • Hey Stefan, I had a look at your struts1-project. When do you release version 1.4.5? – myborobudur Jan 04 '23 at 14:00
  • 1
    Hi, I'm working on updating two struts1-dependencies (common-chain, tiles-request) to Jakarta9. I hope I can finish it at the end of January. Greetings Stefan – Stefan Jan 08 '23 at 22:23
  • hi Stefan, great work on this! Am so thankful to come across your repo to help me address CVE with my legacy apps. May I know when will you release an update for Jakarta 9, and hopefully to 10 as well? Am really looking forward to it! – louis xie Jul 04 '23 at 12:41