You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Gerald Wiltse <je...@gmail.com> on 2016/04/19 04:01:55 UTC

Classloader Won't Load Some Classes

I have a bunch of classes in different packages called "Datasources" which
are all very similar. They extend an abstract base class, they have quite a
few dependencies and implement some traits.  They also use
@InheritConstructors annotation.

I am unable to load any of them using newInstance() :

import com.gsi.monitor.loader.CustomLoader
URLClassLoader loader = CustomLoader.getCustomLoader("master")
Datasource dsi =
loader.loadClass("com.gsi.monitor.updater.global.Datasource").newInstance()
dsi.run()
println dsi.output

Error:    unable to resolve class Datasource


What I find interesting, is that several other classes load as expected,
and that the error is "unable to resolve".   The other classes I've tested
are simpler classes, so I'm wondering what it is about the "Datasource"
classes that us causing them to fail.  Could it be the annotations, or
dependencies, etc?

Note: These are running inside the script engine of Logicmonitor monitoring
platform.   It has groovy-all-2.3.0 library.

Any ideas?



Gerald R. Wiltse
jerrywiltse@gmail.com

Re: Classloader Won't Load Some Classes

Posted by Gerald Wiltse <je...@gmail.com>.
Please disregard.

It seems my problem was related to defining line 3 above as "Datasource
dsi" instead of "def dsi" .  The reasons seem obvious.  I thought i tried
that as one of many steps, but perhaps had another problem at that time.

It's working now.

Gerald R. Wiltse
jerrywiltse@gmail.com


On Mon, Apr 18, 2016 at 10:01 PM, Gerald Wiltse <je...@gmail.com>
wrote:

> I have a bunch of classes in different packages called "Datasources" which
> are all very similar. They extend an abstract base class, they have quite a
> few dependencies and implement some traits.  They also use
> @InheritConstructors annotation.
>
> I am unable to load any of them using newInstance() :
>
> import com.gsi.monitor.loader.CustomLoader
> URLClassLoader loader = CustomLoader.getCustomLoader("master")
> Datasource dsi =
> loader.loadClass("com.gsi.monitor.updater.global.Datasource").newInstance()
> dsi.run()
> println dsi.output
>
> Error:    unable to resolve class Datasource
>
>
> What I find interesting, is that several other classes load as expected,
> and that the error is "unable to resolve".   The other classes I've tested
> are simpler classes, so I'm wondering what it is about the "Datasource"
> classes that us causing them to fail.  Could it be the annotations, or
> dependencies, etc?
>
> Note: These are running inside the script engine of Logicmonitor
> monitoring platform.   It has groovy-all-2.3.0 library.
>
> Any ideas?
>
>
>
> Gerald R. Wiltse
> jerrywiltse@gmail.com
>
>