Getting EOGenericRecord when I don't want it...
Getting EOGenericRecord when I don't want it...
- Subject: Getting EOGenericRecord when I don't want it...
- From: "Pierce T. Wetter III" <email@hidden>
- Date: Wed, 5 Dec 2007 10:52:19 -0700
Problem:
TestNG isn't working for me because even though I can access the
class via Class.forName(), the bowels of WebObjects can't. I'm not
enough of a java head to know why, so I'm asking for help.
In Detail:
So I'm trying to get started with TestNG. (TestNG is a better
version of JUnit)
So I've written a bunch of unit tests, and figured out what I had to
do to get everything up and running. What I've found so far:
0. TestNG is much better then JUnit for writing tests. Their book
is excellent as well.
1. TestNG insists on kvetching about anything it doesn't
understand in the command line items. So where I was defining a bunch
of properties on the command line, I had to move them to -
Dproperty=foo lines against the Java VM.
2. You have to put build/foo.framework/Resources/Java in your
classpath for every single Framework you include or NSBundle won't
find them and load them.
3. As Chuck Hill has pointed out, you need to setup your working
directory as build/FrameworkUnderTest.framework/Resources/Java .
Except, I'm having a problem that anything fetched from the
database is coming back as EOGenericRecord instead of the correct
class. I'm guessing this has something to do with something not being
bootstrapped correctly in EOF under TestNG. Near as I can tell though,
the classes are there:
EOEntity uent = EOUtilities.entityNamed(ec, "User");
EOClassDescription ucd = uent.classDescriptionForInstances();
try
{
NSLog.out.appendln("Verified class " +
Class.forName(uent.className()));
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
Prints out the appropriate thing. But:
NSLog.out.appendln("Verified2 class " +
uent._concreteClassForDeferredFault());
Prints out:
[2007-12-05 10:42:33 MST] <main> Class
'com.paceap.businesslogic.server.User' not found for Entity 'User',
using EOGenericRecord instead
Verified2 class class com.webobjects.eocontrol.EOGenericRecord
Which is kind of weird, because the relevant code in EOEntity calls
this routine in _NSUtilties which calls Class.forName() (thank you
jadclipse). So then I added:
NSLog.out.appendln("Verified3 class " +
_NSUtilities._classWithFullySpecifiedName(uent.className()));
Which throws:
[2007-12-05 10:46:42 MST] <main> java.lang.ClassNotFoundException:
com.paceap.businesslogic.server.User
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
So MY code can find the class, but WebObjects can't. Perhaps
java.security.AccessController.doPrivileged is the problem, but ok,
how do I bypass that?
Pierce
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden