Questions tagged [guice]

Guice is a lightweight dependency injection framework for Java.

Filter by
Sorted by
Tagged with
0 votes
1 answer
30 views

ByteBuddy Proxy instance Guice Injection Error

I have a service where Guice handles the dependency injection for the service. I have a use case where for one the beans being injected via Guice I have to mock/proxy one of the method calls for that ...
Vegan Vegeta's user avatar
0 votes
0 answers
27 views

JAX-RS: Multiple ExceptionMappers handling the same Exception

We have two version of APIs in a monolith architecture. Each one of them has a GenericExceptionHandler which extends JAX-RS's ExceptionMapper. Once I bind the ExceptionMappers as providers for the ...
Ștefan Jiroveanu's user avatar
0 votes
0 answers
21 views

Guice bindings on config changes

I am using cfg4j library for reflecting the changes in the beans on changes in the config files (auto-reload/refresh) public ConfigurationProvider getConfigurationProvider() { ...
Paul Schimmer's user avatar
0 votes
2 answers
28 views

Mockito replaced already mocked objects with new ones after calling openMocks for InjectMocks annotated object

I have this weird situation that Mockito is replacing already mocked objects with new ones after calling openMocks() for @InjectMocks annotated object. Here is my setup: @RunWith(MockitoJUnitRunner....
user1589188's user avatar
  • 5,410
-1 votes
0 answers
20 views

Why I have zip file closed error with log4j log appender, guice and guava (guava is relocated) when I use minecraft plugin?

I have relocated guava and included it into fat jar. Guice is located in external jar where guava is relocated too. Main jar is java minecraft plugin in paper core 1.16.5 server. https://paste.gg/p/...
Cororo's user avatar
  • 1
0 votes
1 answer
29 views

Scala Play 2.8 - SwaggerPluggin Failing - com.google.inject.CreationException: Unable to create injector

I am using jackson module(com.fasterxml.jackson.module:jackson-module-scala_2.13:$jacksonVersion) 2.13.1 with play version 2.8.20. However getting this error: controllers.SoftwareListControllerSpec &...
Shivam Sahil's user avatar
  • 4,266
0 votes
1 answer
35 views

Guice multibinding with named binding

I have a bunch of Processor. Some are of the same object type but have different configuration. I want to create a set of processor but choose which processor should go in which set. If there a way to ...
Belphegor21's user avatar
-1 votes
1 answer
62 views

Initialized static variable becomes null

I have a simple class like so: class MyClass { private static SomeClass object = null; public void init(Someclass injectedObject) { object = injectedObject; } } I init this class in my ...
ritratt's user avatar
  • 1,751
0 votes
0 answers
47 views

bindActorFactory...] not starting up the actor at Play Framework application startup

I have an Akka Actor named MyActorin in my Scala Play Framework application. I am binding this actor in a module named MyModule class MyActor @Inject() (system: ActorSystem) extends Actor with ...
Prakhar Singh's user avatar
0 votes
2 answers
49 views

How to inject singleton class in another class with constructor parameters in scala and create it's objects just the constructor?

I have a singleton class: @Singleton class Inject_Class_A @Inject()( wsClient: WSClient, )(implicit executionContext: ExecutionContext) { // ... ...
Abhinav's user avatar
0 votes
0 answers
14 views

How to get a Provider from an Element of type Binding in Guice?

Binding interface contains a method getProvider() that should do the conversion to a Provider. However most of implementations are based on BindingImpl that allows for getting a Provider only when an ...
czerny's user avatar
  • 15.5k
1 vote
1 answer
69 views

Vaadin 24 with Embedded Jetty and Google Guice

I need to use Vaadin framework in an application that already uses Google Guice as DI together with an embedded Jetty as webserver. The main issue is that Vaadin components must use some services ...
Sergey Stepin's user avatar
1 vote
1 answer
30 views

How to use java guice when an injectable has its own dependencies

I'm trying to figure out how Guice works and is struggling to find examples/tutorials for the specific scenarios I have. Lets say I have the following classes: ClassA with injected ClassB ClassB ...
WitHeld's user avatar
  • 317
1 vote
1 answer
82 views

[Guice/MissingImplementation]: No implementation was bound

I am trying to implement a simple app using Guice for DI. The app has an interface Shape : public interface Shape { void draw(); } that is implemented by a class Rectangle. public class Rectangle ...
halfwind22's user avatar
0 votes
1 answer
49 views

Reconfiguring (or resetting) singleton services in Guice

I have a legacy code that I decided to refactor using Google Guice. In my project, I have a service called AccessVerifier which looks like this: @Singleton public class AccessVerifier { ...
Jovan Perovic's user avatar
0 votes
1 answer
24 views

Google Guice - Singleton with param

I started using google guice and trying to create an singleton object. Not sure how to pass the parameter required by getClient(...) and create an object using @Inject annotation. Any help is ...
Raj's user avatar
  • 33
0 votes
1 answer
34 views

How do I refactor this code with if/else for Update/Delete event and the class is injected using Guice

I'm trying to refactor one of the classes we have which is very long. The class is a listener which has only two events Update and Delete. We started with just this public class DocumentListener ...
toy's user avatar
  • 11.8k
0 votes
1 answer
21 views

Implement Strategy pattern with Guice DI

I am very new in Guice DI. I am trying to implement a Strategy pattern with Guice. But I am confused on, How to inject different types of Strategy Implementations in the Context class through Guice DI....
Arpan Das's user avatar
  • 1,007
1 vote
4 answers
152 views

Can you use alternative dependency injection frameworks with Helidon MP?

I'm getting started with Helidon MP and for the most part its pretty sweet. I'm not a huge fan of the CDI system as I have extensive experience with Guice in past projects. I've been trying to figure ...
slayton's user avatar
  • 20.2k
0 votes
0 answers
9 views

Running a REST service on a different port as part of same server

I have application server using guice for dependency injection and jaxrs for REST. public final class MyWebServer { public void start() { ... } public static void main(String[] args) { /...
Paul Schimmer's user avatar
0 votes
0 answers
53 views

Register custom annotation in Java

I’m working on a project using only the Javalin framework and google Guice inject. I’m having a hard time recording a custom annotation in the project to be used by any class I created a custom ...
Ger's user avatar
  • 639
0 votes
1 answer
142 views

Lombok inject named provider into arg constructor

Using Lombok and Guice, I want to inject two different named providers from two different instances of calling code. Set up is currently: @RequiredArgsConstructor(onConstructor = @__(@Inject)) class ...
ikmckenz's user avatar
4 votes
1 answer
98 views

Modify embedded Apache James Classloader to allow for custom hooks in same project

I am attempting to run my own custom in-memory James assembly inside of a Quarkus web application. I've been following along with the example here and gotten the server to run. One of the issues I'm ...
TheFunk's user avatar
  • 991
0 votes
1 answer
52 views

With what to replace com.sun.jersey.guice.spi.container.servlet.GuiceContainer in Jersey version 2?

I have a Java web application using Google Guice as a framework which is currently on Java 8, and I need to upgrade it to Java 17. I am currently replacing all old classes from com.sun.jersey version ...
Lia's user avatar
  • 15
1 vote
1 answer
132 views

Force loading a class before HikariCP initiates a connection in Play Framework with Guice

I have a use case where I need to enforce one of my application class (a singleton service) is loaded before HikariCP initializes and creates connection to the database. As HikariCP is initialized &...
Gaël J's user avatar
  • 12.3k
0 votes
0 answers
43 views

Receiving "Unable to create injector [Guice/MissingImplementation]: No implementation for Producer<String, String> was bound."

Im trying to bind a producer in a java aplication on the following code on my appModule: protected void configure() { try { Environment environment = environment(); ...
Pedro Ventura's user avatar
0 votes
0 answers
28 views

Shared injections in Guice

I am using Guice in java. For some modules I have noticed that I have parameters which are repeated in every provider in my module. This can become very verbose if I have several of them per provider ...
eshalev's user avatar
  • 3,053
0 votes
0 answers
29 views

How do I update Swing component after GUI is initialised to avoid NPE in Java Swing?

While developing a Swing application I encounter a problem I cannot deal on my own. I'm trying to adhere to Model-Viewer-Presenter pattern. Please have in mind I may misread how to make use of this ...
menteith's user avatar
  • 616
2 votes
1 answer
123 views

Guice and MVP pattern: decouple the view from the presenter

I'm writing an application in Swing and I'd like to make use of Model–view–presenter pattern. I found a sample application using this pattern and then I alter it to make use of Guice to do dependency ...
menteith's user avatar
  • 616
1 vote
0 answers
225 views

Guice throwing NoSuchMethodError

I am using Guice version 5.1.0 for my project (jdk version 17) Error Message: java.lang.NoSuchMethodError: 'java.lang.ClassLoader com.google.inject.internal.BytecodeGen.getClassLoader(java.lang.Class)'...
Hancy's user avatar
  • 21
0 votes
0 answers
20 views

Guice how to make a property dynamique?

I have this interface classes: public interface Query { String getQuery(); } Query Builder implements Query public class QueryBuilder implements Query { private String query; private ...
Nikodev's user avatar
  • 13
0 votes
1 answer
111 views

Got error "No implementation for play.cache.SyncCacheApi was bound" when using guice and pac4j

Here is the code I ran: package org.example; import com.google.inject.*; import org.pac4j.core.context.session.SessionStore; import org.pac4j.play.store.PlayCacheSessionStore; import org.pac4j.play....
al2co33's user avatar
1 vote
0 answers
107 views

Not able to inject an instance of ObjectMapper using guice injector in java application

My Module class is like below : public class JacksonModule extends AbstractModule { @Provides @Singleton @Named("dynamicWidgetDeserializer") public static ObjectMapper ...
ASHOK KUMAR's user avatar
0 votes
1 answer
54 views

Method annotated with @Singleton and @Provides getting called multiple times

We hava library which uses Guice DI framework. As of now we were integrating with library by installing it's binding like this. public class Service { public static void main(String[] args) { ...
siddhartha kumar verma's user avatar
0 votes
0 answers
15 views

Guice named binding to selectively provide an instance

I am trying to provide a dummy client/config based on some conditions and I can think of implementing as shown below. I added 'if' statement in the provider to provide a different implementation of ...
codereviewanskquestions's user avatar
0 votes
0 answers
102 views

Is there a way to pass Dropwizard configuration from application to Guice Module?

I am creating a Dropwizard application. I am using Guice for dependency injection as following. public class NexusServiceApplication extends Application<NexusServiceConfiguration> { public ...
Kuldeep Yadav's user avatar
0 votes
1 answer
58 views

Scala Play-Framework inject SttpBackend[Future, Any] with an `@Named` annotation

Setup I have the following setup to proxy a request to a server providing images for an application class ModuleDependencies extends SimpleModule((_, conf) => { ... val httpClient: ...
epsilonhalbe's user avatar
  • 15.7k
0 votes
0 answers
147 views

java.lang.ClassCastException: class com.google.inject.servlet.GuiceFilter cannot be cast to class jakarta.servlet.Filter

i have to deplot my project on tomcat while doing getting this error in Tomacat localhost log getting this error 24-Apr-2023 12:46:55.936 SEVERE [main] org.apache.catalina.core.StandardContext....
shri tiwari's user avatar
0 votes
1 answer
67 views

Initialising a JavaFX application Screen Management Service using Guice for Dependency Injection

I have a JavaFX application, and throughout the application the active 'screen' is changed by calling a loadScene method on a ScreenService. This ScreenService should be injected as a Singleton via ...
NicholasG04's user avatar
0 votes
1 answer
61 views

How can I better organize my java classes to use delegation, without the tedium?

I have a Java project where one overwhelmingly large class had been split up into smaller classes, entirely because of readability reasons. Guice dependency injection is used. public interface ...
mdong's user avatar
  • 355
0 votes
1 answer
114 views

Java: Apache James In-Memory Mail Server Fails to Start?

I am attempting to embed a memory only instance of Apache James in a Java application but running into an error. I'm following the example here: GitHub Sample Project Apache James Website The error I ...
TheFunk's user avatar
  • 991
0 votes
1 answer
97 views

Using Guice as a dependency injection library in ZIO App

We are working on migrating our Play! application to ZIO. As a first step, we are checking if we can use the Google Guice as a dependency injection library in ZIO, so that changes could be minimal. It ...
Swapan Pramanick's user avatar
0 votes
0 answers
25 views

Overriding ProjectDependenciesResolver and Default Implementation Invoking in Maven Extension

I want to override the ProjectDependenciesResolver class. This usually calls the default implementation in the DefaultProjectDependenciesResolver class. Attempt 1 import org.apache.maven.project.*; ...
Yair's user avatar
  • 1
1 vote
0 answers
157 views

Cucumber tests with Guice DI not able to find Named annotations

I've been trying to add integration tests using Cucumber-Guice verion 7.11. I have the following directory setup src/main/kotlin/ \_ com.mypackage.tests \_ api/ApiGatewayHttpClient.kt \_ ...
Sleepinator's user avatar
0 votes
1 answer
28 views

How values from one HTTP get request are used as @QueryParams in another get request in Google Guice?

I am having problem with understanding how exactly multiple HTTP get requests work together. Let's say I have a GET request which returns a collection of CustomObjects according to a given id. class ...
user avatar
2 votes
0 answers
205 views

How do you setup and execute a MavenExecutionRequest with Maven Core v4.0.0?

I want to build a Maven project using the Maven Core (version 4.0.0-alpha-5) library. All I want right now is a working proof-of-concept to run the install phase. However, I have not been able to ...
Cardinal System's user avatar
0 votes
1 answer
40 views

Don't want provider to create new instance each time while using Google Guice Dependency Injection

I.m new to Google Guice Dependency Injection. I'm implementing (Provider), but it's making new instance each time. I want it to use same instance of StudentRepository Class which it was created first ...
Zaryab Ali's user avatar
1 vote
0 answers
89 views

Add Guice to POM causes java.lang.NoSuchMethodError: 'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap

I try to use Guice to Dependency Injction but when I add dependency to POM compiler returs java.lang.NoSuchMethodError: 'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap I ...
Krato's user avatar
  • 13
0 votes
0 answers
37 views

Retrieving implementing class from child package

I have 3 packages with a dependency graph as follows InterfacePkg -> AuthPkg -> ServicePkg |_______________________^ InterfacePkg Will contain annotation definitions and Api resources ...
Oue's user avatar
  • 23
0 votes
1 answer
618 views

[Guice/ErrorInCustomProvider]: NoSuchMethodError: 'void ConstructorConstructor.<init>(Map)' at GsonModule.provideGson(GsonModule.java:99)

I have a Spring Boot project which uses jClouds and has 2 classes as shown below: @Configuration public class S3Config { @Value("${amazon.s3.access-key}") private String accessKey; @...
gkhand's user avatar
  • 13

1
2 3 4 5
65