How to register plugin dependencies in the classpath?

Hi all,

I’m setting up a debugging environment as described in this great article using Eclipse. I added my plugin to the classpath, and everything works fine, except for one thing: I get a java.lang.NoClassDefFoundError after it has done initializing Sponge. It doesn’t find a library my plugin declared in its gradle dependencies (the jersey REST-server, to be more precise).

Full error output:

java.lang.NoClassDefFoundError: org/glassfish/jersey/server/ResourceConfig
	at be.vervaeck.sam.spongerest.RESTServer.<init>(RESTServer.java:18) ~[RESTServer.class:?]
	at be.vervaeck.sam.spongerest.RESTServer.<init>(RESTServer.java:27) ~[RESTServer.class:?]
	at be.vervaeck.sam.spongerest.SpongePlugin.onServerStart(SpongePlugin.java:25) ~[SpongePlugin.class:?]
	at org.spongepowered.common.event.listener.GameStartedServerEventListener_SpongePlugin_onServerStart2.handle(Unknown Source) ~[?:?]
	at org.spongepowered.common.event.RegisteredListener.handle(RegisteredListener.java:86) ~[RegisteredListener.class:?]
	at org.spongepowered.mod.event.SpongeModEventManager.post(SpongeModEventManager.java:238) [SpongeModEventManager.class:?]
	at org.spongepowered.mod.event.SpongeModEventManager.post(SpongeModEventManager.java:282) [SpongeModEventManager.class:?]
	at org.spongepowered.mod.SpongeMod.onStateEvent(SpongeMod.java:184) [SpongeMod.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_74]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_74]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_74]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_74]
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [guava-17.0.jar:?]
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.post(EventBus.java:275) [guava-17.0.jar:?]
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:211) [LoadController.class:?]
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189) [LoadController.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_74]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_74]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_74]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_74]
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [guava-17.0.jar:?]
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [guava-17.0.jar:?]
	at com.google.common.eventbus.EventBus.post(EventBus.java:275) [guava-17.0.jar:?]
	at net.minecraftforge.fml.common.LoadController.onPost(LoadController.java:53) [LoadController.class:?]
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) [LoadController.class:?]
	at net.minecraftforge.fml.common.Loader.serverStarted(Loader.java:800) [Loader.class:?]
	at net.minecraftforge.fml.common.FMLCommonHandler.handleServerStarted(FMLCommonHandler.java:289) [FMLCommonHandler.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:510) [MinecraftServer.class:?]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_74]

Any pointers to how I can make sure that sponge is able to find my plugin’s Gradle dependencies in this setup?

Thanks,
Sam

I’m not too sure on the exact setup you’ve got, but I’m going to guess and say that the dependency is not being “exported” by eclipse.
Right click your project, go to properties -> build path -> order and export -> then select all and apply.

That most definitely looks like something that should be done, and I would have never looked there myself. However, the error is still occurring.

I temporarily fixed it by adding my plugin as a dependency to Forge. Not the best way to do it, but it works for now.

Any ideas why it still doesn’t get exported?

Edit: Could it be a problem with Eclipse itself? For instance, that Eclipse doesn’t add exported dependencies to the classpath of the launch of another project?