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

How to use guice beans #140

Closed
wzhongyuan opened this issue Dec 28, 2020 · 4 comments
Closed

How to use guice beans #140

wzhongyuan opened this issue Dec 28, 2020 · 4 comments

Comments

@wzhongyuan
Copy link

seems if i added guice bundle in my application, i cannot use DynamicFeature correctly

mokies/ratelimitj#48

@xvik
Copy link
Owner

xvik commented Dec 28, 2020

It looks like jetty (9.4.33) regression appeared with dropwizard 2.0.15. To fix this just update to 2.0.16 or 2.0.17 (which brings fixed jetty).

For reference: https://github.com/eclipse/jetty.project/issues/5555

Also, this is not guicey:

guiceBundle = GuiceBundle.<KrylovMasterConfiguration>newBuilder()
        .addModule(new ConfigModule())
        .addModule(new ResourceModule())
        .addModule(new CoreServiceModule())
        .addModule(new AuthModule())
        // .addModule(new CommonModule()) // Needed for workflow and workspace, do not remove
        //.addModule(new ZookeeperClientModule()) //Needed for workflow and workspace, do not remove
        .addModule(new DefaultServerModule())
        .addModule(new DefaultWorkspaceModule())
        .addModule(new ExtensionModule())
        .addModule(new RateLimitModule())
        //.enableAutoConfig(getClass().getPackage().getName())  // disable this to prevent accidental registration.
        .setConfigClass(KrylovMasterConfiguration.class)
        .build();

Most likely, you are using dropwizard-guice (or dropwizard-guicier) here

@wzhongyuan
Copy link
Author

@xvik Thanks, is it same as #40 ?

@wzhongyuan
Copy link
Author

@xvik I am working on a legacy system, it may be not that easy to upgrade the version, is there any other solution ?
below is the version info

 <dropwizard.version>1.3.5</dropwizard.version>
    <dropwizard-guice.version>1.3.5.0</dropwizard-guice.version>

@xvik
Copy link
Owner

xvik commented Dec 29, 2020

I was trying to say that you're using a different library dropwizard-guice and not dropwizard-guicey (confusing names, I know). The library has been deprecated in favor of dropwizard-guicier, which is also seems to be abandoned now, but anyway it may fit your current needs.

Or you can migrate to dropwizard-guicey (version 4.2.2 will work for dropwizard 1.3).

The configuration above would change to:

guiceBundle = GuiceBundle.builder()
        .modules(
                new ConfigModule(),
                new ResourceModule(),
                new CoreServiceModule(),
                new AuthModule(),
                //new CommonModule(), // Needed for workflow and workspace, do not remove
                //new ZookeeperClientModule(), //Needed for workflow and workspace, do not remove
                new DefaultServerModule(),
                new DefaultWorkspaceModule(),
                new ExtensionModule(),
                new RateLimitModule())
      //.enableAutoConfig(getClass().getPackage().getName())  // disable this to prevent accidental registration.
      .build();

But it would be better to enable auto-configuration so guicey could register extensions for you. This guicey version can't register them directly from guice declarations (feature available only in newer versions).

@xvik xvik closed this as completed Feb 2, 2021
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