FAQ
Hey all, hope you aren't tired of me yet

This in a nutshell is the problem:
ClassLoader parent = getClass().getClassLoader();
GroovyClassLoader loader = new GroovyClassLoader(parent);
loader.parseClass(new
File("C:\\tutorial\\src\\main\\java\\org\\example\\cayenne\\persistent\\Store.groovy"));

loader.loadClass("main.java.org.example.cayenne.persistent.Store");

System.out.println(Class.forName("main.java.org.example.cayenne.persistent.Store",
true, loader).toString());

DataDomain dd =
Configuration.getSharedConfiguration().getDomain();
ObjectContext context = dd.createDataContext();

Error:
java.lang.ClassNotFoundException: class
main.java.org.example.cayenne.persistent.Store
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at
main.java.org.example.cayenne.ut.CayenneUnitTest.testBuild(CayenneUnitTest.java:128)

At this point the "Store" object (which is compiled at runtime through
Groovy) does not exist in any context that teh DataContext can find it, the
DataContext is looking for it in Class.forName, but that is looking in the
default ClassLoader. This "Store" object does not exist in that context, it
is in its own ClassLoader (GroovyClassLoader). So how do I tell the system
to load the object from this GroovyClassLoader?? I know this is the issue
because if I take that Store object, make it a Java class, compile it, and
run the same test it works fine.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 4 | next ›
Discussion Overview
groupuser @
categoriescayenne
postedNov 3, '10 at 7:29p
activeNov 4, '10 at 2:06p
posts4
users2
websitecayenne.apache.org

2 users in discussion

Caden whitaker: 3 posts Andrus Adamchik: 1 post

People

Translate

site design / logo © 2022 Grokbase