I’m struggling… An app that has been in use for many years started taking a dump on me after an update and I can’t seem to figure out what the problem is.
Maybe some boss around here might have an idea or two I could try, hopefully?
Problem description
The app installs and generally seems to be working and running (e.g. I can see scheduled jobs from the plugin too). No errors in the logs, everything is fine, all modules enabled. You’d think we hit a jackpot with this one and I can finally retire.
However, no servlets are working. Trying to open a servlet page will result in an error like this:
024-10-18 12:11:28,190 ERROR [https-jsse-nio-8443-exec-17 url: /plugins/servlet/pua/dashboard; user: helpme] [atlassian.plugin.servlet.DefaultServletModuleManager] getInstance Unable to create new reference LazyLoadedServletReference{descriptor=com.helpme.confluence.services.pluginUsageAnalyzer:pua-dashboard-servlet (Overview Dashboard), servletContext=org.apache.catalina.core.ApplicationContextFacade@10033943}
-- url: /plugins/servlet/pua/dashboard | userName: helpme | traceId: 434a40ba7efea427
io.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.ClassCastException: class com.helpme.servlets.DashboardServlet cannot be cast to class javax.servlet.http.HttpServlet (com.helpme.servlets.DashboardServlet is in unnamed module of loader org.apache.felix.framework.BundleWiringImpl$BundleClassLoader @1a116e98; javax.servlet.http.HttpServlet is in unnamed module of loader java.net.URLClassLoader @86be70a)
at io.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:156)
at io.atlassian.util.concurrent.LazyReference.get(LazyReference.java:116)
at com.atlassian.plugin.servlet.DefaultServletModuleManager.getInstance(DefaultServletModuleManager.java:431)
at com.atlassian.plugin.servlet.DefaultServletModuleManager.getServlet(DefaultServletModuleManager.java:410)
at com.atlassian.plugin.servlet.DefaultServletModuleManager.getServlet(DefaultServletModuleManager.java:230)
at com.atlassian.plugin.servlet.ServletModuleContainerServlet.service(ServletModuleContainerServlet.java:40)
at com.atlassian.confluence.servlet.ServletModuleContainerServlet.service(ServletModuleContainerServlet.java:52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:623)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:199)
... blabla ...
Caused by: java.lang.ClassCastException: class com.helpme.servlets.DashboardServlet cannot be cast to class javax.servlet.http.HttpServlet (com.helpme.servlets.DashboardServlet is in unnamed module of loader org.apache.felix.framework.BundleWiringImpl$BundleClassLoader @1a116e98; javax.servlet.http.HttpServlet is in unnamed module of loader java.net.URLClassLoader @86be70a)
at com.atlassian.plugin.servlet.descriptors.ServletModuleDescriptor.getModule(ServletModuleDescriptor.java:42)
at com.atlassian.plugin.servlet.DelegatingPluginServlet.<init>(DelegatingPluginServlet.java:30)
at com.atlassian.plugin.servlet.DefaultServletModuleManager$LazyLoadedServletReference.create(DefaultServletModuleManager.java:529)
at com.atlassian.plugin.servlet.DefaultServletModuleManager$LazyLoadedServletReference.create(DefaultServletModuleManager.java:513)
at io.atlassian.util.concurrent.LazyReference$Sync.run(LazyReference.java:332)
at io.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:150)
... 373 more
Other notes
I’ve tried a lot… changing dependency scopes, cleaning and rebuilding, upping a few versions here and there. Bashing the wall and bandaging up. Nothing works.
Especially tried to change
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
from downgrading, upgrading, etc. It just doesn’t care about my pain and suffering.
More servlet info
import javax.servlet.http.HttpServlet;
..
@Named
public class DashboardServlet extends HttpServlet {
..
@Override
protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException {
..
}
..
}
^ standard stuff
<servlet name="PUA - Dashboard Servlet" key="pua-dashboard-servlet" class="com.helpme.servlets.DashboardServlet">
<description>Overview Dashboard</description>
<url-pattern>/pua/dashboard</url-pattern>
</servlet>
^ also standard stuff
System info (update)
Application ServerApache: Tomcat/9.0.91
Servlet Version: 4.0
Java Version: 17.0.12
Java Vendor: Eclipse Adoptium
JVM Version: 17
JVM Vendor: Oracle Corporation
JVM Implementation Version: 17.0.12+7
Java Runtime: OpenJDK Runtime Environment
Java VM: OpenJDK 64-Bit Server VM
Assumptions
Just seeing the cause… I reckon, class loader problems, been there before. But, like, how do I fix that in here? -.-
Could try to create my own class that just extends it and see if the class loader is happy about it, but it doesn’t sound like a proper solution or even understanding of why this is happening.
Final begging moments
Any ideas? Have you ever run into class loader problems perhaps not with servlets, but something similar?
I’m not paying, but I will thank you generously for any hint or clue.