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

Can't access ContinuousStopwatch #187

Closed
Trentondmiller opened this issue Nov 1, 2021 · 2 comments
Closed

Can't access ContinuousStopwatch #187

Trentondmiller opened this issue Nov 1, 2021 · 2 comments

Comments

@Trentondmiller
Copy link

Trentondmiller commented Nov 1, 2021

Hi There,
I recently upgraded to version 5.4.0 of dropwizard-guicey and am having issues stemming from a direct reference in the code to
com/google/inject/internal/util/ContinuousStopwatch

The error I get is

java.lang.NoClassDefFoundError: com/google/inject/internal/util/ContinuousStopwatch
	at ru.vyarus.dropwizard.guice.module.context.stat.GuiceStatsTracker.getLogger(GuiceStatsTracker.java:58)
	at ru.vyarus.dropwizard.guice.module.context.stat.GuiceStatsTracker.injectLogsInterceptor(GuiceStatsTracker.java:26)
	at ru.vyarus.dropwizard.guice.module.GuiceyRunner.createInjector(GuiceyRunner.java:108)
	at ru.vyarus.dropwizard.guice.GuiceBundle.run(GuiceBundle.java:140)
	at ru.vyarus.dropwizard.guice.GuiceBundle.run(GuiceBundle.java:101)
	at io.dropwizard.setup.Bootstrap.run(Bootstrap.java:199)
	at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:58)
	at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:98)
	at io.dropwizard.cli.Cli.run(Cli.java:78)

This seems to be because the GuiceStatsTracker references the ContinuousStopwatch by route in Google Guice directly, a route that existed on the Google Guice Version 5.0.0-BETA-1.

However, from what I can see version 5.4.0 of dropwizard-guicey seems to be using Google Guice Version 5.0.1. As shown here.

The problem is that Google Guice Version 5.0.1 no longer contains ContinuousStopwatch at that route, or seemingly even at all.
Am I missing something here? Perhaps a work around I can use to disable this logger, or no longer reference this class?

A few other Version info:
Java - 17
Maven - 3.6.3

@xvik
Copy link
Owner

xvik commented Nov 1, 2021

Hi! You must be using modules instead of classpath. The class ContinuousStopwatch is still in place (you can look yourself inside guice jar), but it's not exposed in MANIFEST.MF:

Export-Package: com.google.inject;version="1.4",com.google.inject.bind
 er;version="1.4",com.google.inject.matcher;version="1.4",com.google.i
 nject.multibindings;version="1.4",com.google.inject.name;version="1.4
 ",com.google.inject.spi;version="1.4",com.google.inject.util;version=
 "1.4"

There is nothing you can do with it, I guess, except switch to the good old classpath. I may be wrong here, as I did not try jdk17 myself yet, but from what I read there should not be much difference with jdk16.

I can replace the class reference in code by class string name (not pretty, but should workaround that exact case), but I need to check that it is the only problem with modules (ideally add tests for it). This might take time as I have never dealt with modules before.

If you or anyone else could tell me anything else useful regarding proper modules support (hints, suggestions, known problems, etc.) I would be happy to hear.

@xvik xvik closed this as completed in 5786ae9 Dec 19, 2021
@xvik
Copy link
Owner

xvik commented Dec 19, 2021

I think I was wrong, and you're using OSGi (Export-Package record, mentioned above, is related to OSGi) and not java modules (OSGi behavior would be exactly as you described).

If you are indeed using OSGi, the fix will help but I assume you will also have to disable guice modules analysis: .option(GuiceyOptions.AnalyzeModules, false) because this logic is also using internal guice classes.

If you'll face other issues, please show me the way to reproduce (sample project or a way to write unit test) because I never worked with OSGi (I don't mind fixing such issues but don't want to lose time learning it).

A new guicey version (bugfix) is released.

And, for completeness, regarding JMPS: I tried to set up a sample application as a module but failed because dropwizard itself is not compatible (there are several split packages (some of them could be easily resolved, others already discussed for upcoming dw 2.1)). Overall, I step down on modules for now until someone shows me the way to properly configure application as a module.

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

No branches or pull requests

2 participants