New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NoClassDefFoundError for org.springframework.integration.util.ClassUtils if first called from JMX #3875
Comments
How do you register that MBean? |
In our exact case they aren't registered by Spring because of some legacy stuff that we've got around this. However, they are fully constructed Spring Beans that are built in the Spring context, and there's a bean that is also built in the Spring context that is given a reference to both our MBean and the MBeanServer and is just calling The problem doesn't appear to be with registering the MBeans though. It's that, if the first time the Spring Integration code is exercised is by a call that came in over JMX then this is the first time the |
OK. So, the idea is to initialize |
That's definitely a solution. And is probably what we'll end up doing in our code - having a Spring bean that triggers something on It could also work though - at least in this case - to ensure that |
Fixes spring-projects#3875 The class `static` variables and initialization block are performed on first class access. * Add "fake" `ClassUtils.resolvePrimitiveType(Integer.class)` call to the `IntegrationRegistrar` to trigger `ClassUtils` initialization with the current Spring `ClassLoader` **Cherry-pick to `5.5.x`**
Fixes #3875 The class `static` variables and initialization block are performed on first class access. * Add "fake" `ClassUtils.resolvePrimitiveType(Integer.class)` call to the `IntegrationRegistrar` to trigger `ClassUtils` initialization with the current Spring `ClassLoader` **Cherry-pick to `5.5.x`**
Fixes #3875 The class `static` variables and initialization block are performed on first class access. * Add "fake" `ClassUtils.resolvePrimitiveType(Integer.class)` call to the `IntegrationRegistrar` to trigger `ClassUtils` initialization with the current Spring `ClassLoader` **Cherry-pick to `5.5.x`**
FYI that I've just built and run our service using Spring Integration 5.5.15-SNAPSHOT and the problem no longer reproduces :) |
In what version(s) of Spring Integration are you seeing this issue?
Describe the bug
We have a Spring Integration setup in an application, and we have some healthchecks that exercise this and are triggered via JMX. In general this works fine, but in some cases we instead get
java.lang.NoClassDefFoundError: Could not initialize class org.springframework.integration.util.ClassUtils
errors.After much digging, it turns out that this is because:
org.springframework.integration.util.ClassUtils
is entirely static.This all means that, if the first time
org.springframework.integration.util.ClassUtils
is referenced is by code executing within an MBean, then it is running in the Tomcat common classloader and not in the webapp classloader. This in turn means that it is unable to see other classes that it expects to see - for example,org.springframework.integration.core.GenericSelector
To Reproduce
I'll see if I can put together a minimal reproducing project, but essentially it will be:
Expected behavior
This would all still work correctly and not fail.
Sample
Coming soon.
The text was updated successfully, but these errors were encountered: