Skip to content
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

Cannot have different configuration for different webapps in same container (Tomcat) - p6spy 3.9.0 #525

Open
Dealus opened this issue Mar 4, 2021 · 3 comments

Comments

@Dealus
Copy link

Dealus commented Mar 4, 2021

Hello,
The use case is pretty straight forward and I cannot find a way to make it work.
We use p6spy in a Tomcat container. The library is in Tomcat's classpath (/lib).
We want to be able to specify a different spy.properties configuration for each webapp that is deployed. This can help having different log files, different thresholds, ...

It seems to work at first, injecting the spy.properties file in the webapp's classpath works fine (using Tomcat's PreResource in webapp's context file).

But the first datasource that gets initialize seems to set the configuration for the whole JVM.
Other configuration files are simply ignored.

This seems to be caused by P6ModuleManager:private static P6ModuleManager instance which is loaded from the Tomcat global class loader, thus unique for the whole tomcat.

@Dealus Dealus changed the title Cannot have different configuration for different webapps in same container (Tomcat) Cannot have different configuration for different webapps in same container (Tomcat) - p6spy 3.9.0 Mar 4, 2021
@typekpb
Copy link
Member

typekpb commented Mar 5, 2021

@Dealus , thanks for your analysis, I have currently very limited capacity for this project. Would you have an idea how to solve this one?

@Dealus
Copy link
Author

Dealus commented Mar 9, 2021

@typekpb , I gave it a try. This seems to work fine, passes the tests, and allows me to use different configurations.
But it's a pretty wild change.
With this, the P6ModuleManager holds an instance for each different contextClassLoader it is used from, defaulting to current class loader if no context one is found.

You can check the idea here #526

@avrecko
Copy link

avrecko commented Jul 6, 2023

@Dealus I think you just need to put p6spy jar in the webapps and not in the server. Then in the individual webapps you just wrap the DataSource you get from Tomcat/Server with the P6DataSource and you are good to go. If you don't have access to the source code there might be a little work involved to set up a P6DataSource for each webapp individually.

@typekpb I'd close this issue as invalid. I don't think any code changes are needed to p6spy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants