Home > Enterprise >  [Guice/MissingImplementation]: No implementation for ViewLoader was bound
[Guice/MissingImplementation]: No implementation for ViewLoader was bound

Time:07-02

I am getting this error when running gradle run :

1) [Guice/MissingImplementation]: No implementation for ViewLoader was bound.

Requested by:
1  : ModuleManager.<init>(ModuleManager.java:105)
      \_ for 3rd parameter
     at AppInitializer.moduleManager(AppInitializer.java:37)
      \_ for field moduleManager
     while locating AppInitializer

Learn more:

this is a partion of ModuleManager.java where the bug is

  @Inject
  public ModuleManager(
      AuthService authService,
      MetaModuleRepository modules,
      ViewLoader viewLoader,
      ModelLoader modelLoader,
      I18nLoader i18nLoader,
      DataLoader dataLoader,
      DemoLoader demoLoader) {
    this.authService = authService;
    this.modules = modules;
    this.viewLoader = viewLoader;
    this.dataLoader = dataLoader;
    this.demoLoader = demoLoader;
    metaLoaders = ImmutableList.of(modelLoader, viewLoader, i18nLoader);
  }

and this is a portion of viewloader.java :


public abstract class ViewLoader extends AbstractParallelLoader {

  private static final Logger LOG = LoggerFactory.getLogger(ViewLoader.class);

  @Inject private ObjectMapper objectMapper;

  @Inject private MetaViewRepository views;

  @Inject private MetaSelectRepository selects;

  @Inject private MetaActionRepository actions;

  @Inject private MetaMenuRepository menus;

  @Inject private MetaActionMenuRepository actionMenus;

  @Inject private GroupRepository groups;

  @Inject private XMLViews.FinalViewGenerator finalViewGenerator;

  private final Set<String> viewsToGenerate = ConcurrentHashMap.newKeySet();
  private final Map<String, List<String>> viewsToMigrate = new ConcurrentHashMap<>();
  private final Map<String, List<Consumer<Group>>> groupsToCreate = new ConcurrentHashMap<>();

I hope this is enough as a source, I can't post all the code. I don't know what the error means.

CodePudding user response:

ViewLoader is an abstract class. Guice simply says that you need to provide something it can instanciate. Guice can't instantiate abstract class. So provide a binding with a concrete implementation:

class MyViewLoader extends ViewLoader {
  // Implement abstract methods.
}

Then bind the implementation in your module:

  @Override public void configure() {
    bind(ViewLoader.class).to(MyViewLoader.class);
  }
  • Related