Re: Getting EOGenericRecord when I don't want it...
Re: Getting EOGenericRecord when I don't want it...
- Subject: Re: Getting EOGenericRecord when I don't want it...
- From: Chuck Hill <email@hidden>
- Date: Wed, 5 Dec 2007 10:08:37 -0800
On Dec 5, 2007, at 9:52 AM, Pierce T. Wetter III wrote:
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?
I'd guess that it is a problem with NSBundle finding the classes in
it. Try logging out the various things that NSBundle will tell you.
And do that before the above code and see if just calling those
methods makes a difference. Calling NSBundle.mainBundle() might be
enough. I recall having to call NSBundle.allBundles() in some long
ago version before that method was deprecated.
In desperation, you could try WOApplication.primeApplication()
Chuck
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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