DefaultConfig: No implementation for java.nio.file.Path

Greetings, n00b incoming :wink:

I just wanted to start with a simple plugin, using a coonfig file. So I’ve created a plugin, running without errors,
read the documentations, added

@Inject @DefaultConfig(sharedRoot = false) private Path configDir;

and stumbled over this error:

1) No implementation for java.nio.file.Path annotated with org.spongepowered.api.service.config.DefaultConfig(sharedRoot=false) was bound. while locating java.nio.file.Path annotated with @org.spongepowered.api.service.config.DefaultConfig(sharedRoot=false) for field at ...Plugin.configDir(BoosentialsPlugin.java:31) at org.spongepowered.common.guice.SpongePluginGuiceModule.configure(SpongePluginGuiceModule.java:63)

Found a similar topic without a helpful answer :frowning:

Once a bukkit developer, I’m quite new to this injection-stuff. My thought was, that this injection would simply create a Path that I could use in my config initialization routine.

I’ve also used this in my GamePreInitializationEvent:

Path potentialFile = getConfigDir(); ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setFile(potentialFile.toFile()).build(); ConfigurationNode rootNode = loader.createEmptyNode(ConfigurationOptions.defaults());

but I guesss that wasn’t the required implementation.

So, what am I missing?

Thanks in advance

Make sure to update whichever Sponge implementation you use to the newest version.

1 Like

*sigh*
Yep, used build 840, works fine with 907… thanks for the quick reply

Just wondering if you have the same issue when injecting Path, ConfigurationLoader or File types?

It’s surely not the wrong Inject class import, right? I’m just wondering because i once wasn’t sure if i have to use
import com.google.inject.Inject or
import javax.inject.Inject ^^ ??

Guice supports both.

1 Like

just to satisfy your curiosity: yes, same problem for Path
and I have used import com.google.inject.Inject like mentioned in the docs, but as already mentioned

Anyway, solved, thanks again :slight_smile:

Had this same issue today.
Spent an hour debugging just to find I forgot @DefaultConfig(sharedRoot = false) above the Path variable.

Posting this info in case anyone else runs into the same issue.

1 Like