-
Notifications
You must be signed in to change notification settings - Fork 357
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
java.lang.IllegalStateException: The resource configuration is not modifiable in this context. #4617
Comments
Please provide a runnable reproducer |
if you run this on Tomcat that might be caused by any previously missing dependency (activation, jaxb etc). You shall either bundle all required dependencies inside your WAR or put them into the lib folder of Tomcat's shared libraries. |
@senivam in my case this has nothing to do with dependencies but with registering providers and some combinations of their proxies/scopes/injections. Very likely HK2 related. |
@namedgraph actually it can be related to dependencies (I was just fixing that in Tomcat environment when I was writing my previous answer). When you deploy Jersey dependent app inside Tomcat and do not provide activation (and jaxb if needed) besides, it fails to load just with this very exception you are providing in the issue description. But this was only presumption, in other cases the exception might be caused by other reasons. So, if you believe this has nothing to to with dependencies, just provide a reproducer which we could run and check what really happens there. And which AS do you use to deploy your app? |
I'm not disputing that it can be related to dependencies :) Looking at SO, people seem to identify a variety of causes. I will create a reproducer as soon as I can pin down the cause, which I haven't yet. I am using Tomcat 9.x. |
Here's the full error message: Exception
Root Cause
|
Where do you call the |
public class Application extends ResourceConfig
{
...
@PostConstruct
public void init()
{
...
register(new AbstractBinder()
{
@Override
protected void configure()
{
bindFactory(XsltExecutableSupplierFactory.class).to(XsltExecutableSupplier.class).
proxy(true).proxyForSameScope(false).
in(RequestScoped.class);
}
});
...
}
...
} |
I started getting this when upgrading from 2.34 to 2.35. |
@namedgraph Did you find any workaround for this issue? |
@dsvensson not really... This seems to happen when providers fail to register in the application. It went away for a while and now happening again after some non-Jersey dependency upgrade. And seems only to happen on GitHub's server and not my local WSL 2. Really weird. I'll keep you posted. |
FWIW, I had this issue when I had both Jersey 2.33 and 2.34 components rattling around in the same Spring Boot application. ( The result was that all our integration tests that made API calls to our Spring Boot application were failing. The first failed call had the following error message, which sure sounds like it's caused by an API difference between Jersey 2.33 and 2.34:
And then, presumably because that first initialization failed, all subsequent API calls died with the "resource config not modifiable" message:
|
This is happening randomly when stopping and then trying to re-start a Jetty server with
Admittedly it's an older version (Jetty 11 and Jersey 3.1.3), but I saw something about dropping support for Jetty 11 in 3.1.4 so I don't know if it's safe to update. |
I have no previous experience with Jersey, and got this issue "straight away" when trying to register factories. Running on Tomcat 10.1.25 inside IntelliJ IDEA. Also, I am extending I have committed a relatively small codebase https://github.com/niclash/qi4jwebdemo
I have also noticed that Update: Moving the factory registrations from |
After further investigation, the exception started happening after adding handler.addServlet(new ServletHolder(new ServletContainer(servlet)) where |
Jetty 11 support has been in Jersey 3.0.x, and Jetty 12 support is in Jersey 3.1.x. Now to demo. What is it supposed to be done to reproduce the issue with the demo @niclash ? |
If you have IntelliJ IDEA, then you should now have "run configuration" for Tomcat. Either way, mount the war as '/demo' context and go to http://localhost:8080/demo/api and you get the exception in the web browser. |
This is probably one of the most annoying issues I've encountered upgrading Jersey 1.x to 2.x:
In my case it comes from the factory
register()
related code:This causes the error with absolutely no explanation or seemingly even relation to the cause.
It's been plaguing users for years, and every report seems to have a different cause: https://stackoverflow.com/questions/20670310/why-would-java-lang-illegalstateexception-the-resource-configuration-is-not-mo
The text was updated successfully, but these errors were encountered: