Skip to content

Commit 588fb96

Browse files
committed
[2.8.6] Unable to create Guice injector at startup
- Fixed for Guice, Spring and Weld fix jooby-project#1799
1 parent f3aac33 commit 588fb96

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

modules/jooby-guice/src/main/java/io/jooby/di/JoobyModule.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ private void configureResources(ServiceRegistry registry) {
6767

6868
/*package*/ void configureEnv(Environment env) {
6969
Config config = env.getConfig();
70-
bind(Config.class).toInstance(config);
71-
bind(Environment.class).toInstance(env);
7270

7371
// configuration properties
7472
for (Map.Entry<String, ConfigValue> entry : config.entrySet()) {

modules/jooby-spring/src/main/java/io/jooby/di/SpringModule.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,10 @@ public SpringModule noMvcRoutes() {
139139
ServiceRegistry registry = application.getServices();
140140
for (Map.Entry<ServiceKey<?>, Provider<?>> entry : registry.entrySet()) {
141141
ServiceKey key = entry.getKey();
142-
Provider provider = entry.getValue();
143-
applicationContext.registerBean(key.getName(), key.getType(), () -> provider.get());
142+
if (!ignoreEntry(key.getType())) {
143+
Provider provider = entry.getValue();
144+
applicationContext.registerBean(key.getName(), key.getType(), () -> provider.get());
145+
}
144146
}
145147

146148
application.onStop(applicationContext);
@@ -163,4 +165,8 @@ public SpringModule noMvcRoutes() {
163165
}
164166
}
165167
}
168+
169+
private boolean ignoreEntry(Class type) {
170+
return type == Environment.class || type == Config.class;
171+
}
166172
}

modules/jooby-weld/src/main/java/io/jooby/di/JoobyExtension.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ public void configureEnv(@Observes AfterBeanDiscovery abd, BeanManager bm) {
8989
Environment environment = app.getEnvironment();
9090
Config config = environment.getConfig();
9191

92-
registerSingleton(abd, bm, Config.class, null, config);
93-
registerSingleton(abd, bm, Environment.class, null, environment);
94-
9592
for (Map.Entry<String, ConfigValue> configEntry : config.entrySet()) {
9693
final String configKey = configEntry.getKey();
9794
final Object configValue = configEntry.getValue().unwrapped();

0 commit comments

Comments
 (0)