Loading of model manually doesnąt work for me due to the reason I cannot
understand.
For example, I have two frameworks, one of which (second) is listed in the
Properties/Java Build Path of another (first).
When I try to load the missing model of the second framework for running
unit test of the first one I get the following exception:
java.lang.NoClassDefFoundError at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141) at
com.webobjects.foundation._NSUtilities._classWithPartialName(_NSUtilities.ja
va:307) at
com.webobjects.foundation._NSUtilities.classWithName(_NSUtilities.java:291)
at
com.webobjects.eoaccess.EOModel._setEntityForEntityNameClassName(EOModel.jav
a:1242) at
com.webobjects.eoaccess.EOModel._addFakeEntityWithPropertyList(EOModel.java:
1280) at
com.webobjects.eoaccess.EOModel._initWithTableOfContentsPropertyListPathURL(
EOModel.java:1092) at
com.webobjects.eoaccess.EOModel.<init>(EOModel.java:802) at
com.webobjects.eoaccess.EOModelGroup.addModelWithPathURL(EOModelGroup.java:4
98) at dm.inmega.tests.CustomerTest.setUp(CustomerTest.java:24) at
er.testrunner.ERXTestCase.runBare(ERXTestCase.java:93) at
junit.framework.TestResult$1.protect(TestResult.java:106) at
junit.framework.TestResult.runProtected(TestResult.java:124) at
junit.framework.TestResult.run(TestResult.java:109) at
junit.framework.TestCase.run(TestCase.java:118) at
junit.framework.TestSuite.runTest(TestSuite.java:208) at
junit.framework.TestSuite.run(TestSuite.java:203) at
junit.framework.TestSuite.runTest(TestSuite.java:208) at
junit.framework.TestSuite.run(TestSuite.java:203) at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3T
estReference.java:128) at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:3
8) at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java:460) at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java:673) at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
java:386) at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner
.java:196)
on 8/3/06 8:44 PM, Ian McDougall at imcdougal..pple.com wrote:
> This is a problem inside of eclipse, but does not occur if you try
> running unit tests in, say, ant.
>
> to combat this problem, we load the model manually with code similar to:
>
> EOModelGroup mg = EOModelGroup.defaultGroup();
> if (mg.models().count() == 0) {
> System.out.println("No models in EOModelGroup.
> Attempting to load ");
> String modelPath = System.getProperty("eomodel.path");
> if (modelPath != null) {
> mg.addModelWithPathURL(new URL("file://" + modelPath));
> }
> }
>
> The issue has something to do with the main bundle getting lost when
> run as a JUnit test.
>
> Does anyone know how to specify the main bundle, or another way of
> fixing this problem?
>
>
>
> _ _
> Ian
>
> On Aug 3, 2006, at 5:01 AM, Denis Frolov wrote:
>
>> > Hi,
>> >
>> > I have two projects in Eclipse: MyProject and
>> > MyProjectBusinessLogic. MyProjectBusinessLogic is specified in
>> > Projects tab of Java Build Path section in MyProject's Properties.
>> >
>> > I have one unit test extending ERXTestCasa with the following code:
>> >
>> > public void setUp() throws Exception {
>> > super.setUp();
>> > WOApplication.primeApplication(null, NSBundle.mainBundle
>> > ().bundlePathURL(), null);
>> > }
>> >
>> > public void testCustomerValidates() {
>> > Customer customer = (Customer)
>> > EOUtilities.createAndInsertInstance(editingContext(), "Customer");
>> > assertValidates(false, customer);
>> > }
>> >
>> > Customer is an entity of model in MyProjectBusinessLogic
>> >
>> > When I run the unit test via Eclipse Junit launcher I get the
>> > following error and exception:
>> >
>> > ERROR (ERXEntityClassDescription.java:321) - Entity Customer not
>> > found in the default model group!
>> >
>> > java.lang.NullPointerException at
>> > er.extensions.ERXEntityClassDescription
>> > $Factory.registerDescriptionForEntity
>> > (ERXEntityClassDescription.java:516) at
>> > er.extensions.ERXEntityClassDescription
>> > $Factory.classDescriptionNeededForEntityName
>> > (ERXEntityClassDescription.java:322) at
>> > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
>> > sun.reflect.NativeMethodAccessorImpl.invoke
>> > (NativeMethodAccessorImpl.java:39) at
>> > sun.reflect.DelegatingMethodAccessorImpl.invoke
>> > (DelegatingMethodAccessorImpl.java:25) at
>> > java.lang.reflect.Method.invoke(Method.java:324) at
>> > com.webobjects.foundation.NSSelector._safeInvokeMethod
>> > (NSSelector.java:120) at
>> > com.webobjects.foundation.NSNotificationCenter$_Entry.invokeMethod
>> > (NSNotificationCenter.java:601) at
>> > com.webobjects.foundation.NSNotificationCenter.postNotification
>> > (NSNotificationCenter.java:545) at
>> > com.webobjects.foundation.NSNotificationCenter.postNotification
>> > (NSNotificationCenter.java:559) at
>> > com.webobjects.eocontrol.EOClassDescription.classDescriptionForEntityN
>> > ame(EOClassDescription.java:297) at
>> > com.webobjects.eoaccess.EOUtilities.createAndInsertInstance
>> > (EOUtilities.java:814) at
>> > dm.inmega.tests.SimpleTest.testCustomerValidates(SimpleTest.java:
>> > 30) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>> > Method) at sun.reflect.NativeMethodAccessorImpl.invoke
>> > (NativeMethodAccessorImpl.java:39) at
>> > sun.reflect.DelegatingMethodAccessorImpl.invoke
>> > (DelegatingMethodAccessorImpl.java:25) at
>> > java.lang.reflect.Method.invoke(Method.java:324) at
>> > junit.framework.TestCase.runTest(TestCase.java:154) at
>> > er.testrunner.ERXTestCase.runBare(ERXTestCase.java:95) at
>> > junit.framework.TestResult$1.protect(TestResult.java:106) at
>> > junit.framework.TestResult.runProtected(TestResult.java:124) at
>> > junit.framework.TestResult.run(TestResult.java:109) at
>> > junit.framework.TestCase.run(TestCase.java:118) at
>> > junit.framework.TestSuite.runTest(TestSuite.java:208) at
>> > junit.framework.TestSuite.run(TestSuite.java:203) at
>> > org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run
>> > (JUnit3TestReference.java:128) at
>> > org.eclipse.jdt.internal.junit.runner.TestExecution.run
>> > (TestExecution.java:38) at
>> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
>> > (RemoteTestRunner.java:460) at
>> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
>> > (RemoteTestRunner.java:673) at
>> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
>> > (RemoteTestRunner.java:386) at
>> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
>> > (RemoteTestRunner.java:196) If I load the model manually by calling:
>> >
>> > EOModelGroup.defaultGroup().addModelWithPathURL(new File
>> > (pathToModel).toURL());
>> >
>> > I get the same error and another exception:
>> >
>> > ERROR (ERXEntityClassDescription.java:321) - Entity Customer not
>> > found in the default model group! at java.lang.Class.forName0
>> > (Native Method) at java.lang.Class.forName(Class.java:141) at
>> > com.webobjects.foundation._NSUtilities._classWithPartialName
>> > (_NSUtilities.java:307) at
>> > com.webobjects.foundation._NSUtilities.classWithName
>> > (_NSUtilities.java:291) at
>> > com.webobjects.eoaccess.EOModel._setEntityForEntityNameClassName
>> > (EOModel.java:1242) at
>> > com.webobjects.eoaccess.EOModel._addFakeEntityWithPropertyList
>> > (EOModel.java:1280) at
>> > com.webobjects.eoaccess.EOModel._initWithTableOfContentsPropertyListPa
>> > thURL(EOModel.java:1092) at
>> > com.webobjects.eoaccess.EOModel.<init>(EOModel.java:802) at
>> > com.webobjects.eoaccess.EOModelGroup.addModelWithPathURL
>> > (EOModelGroup.java:498) at
>> > dm.inmega.tests.SimpleTest.testCustomerValidates(SimpleTest.java:
>> > 32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>> > Method) at sun.reflect.NativeMethodAccessorImpl.invoke
>> > (NativeMethodAccessorImpl.java:39) at
>> > sun.reflect.DelegatingMethodAccessorImpl.invoke
>> > (DelegatingMethodAccessorImpl.java:25) at
>> > java.lang.reflect.Method.invoke(Method.java:324) at
>> > junit.framework.TestCase.runTest(TestCase.java:154) at
>> > er.testrunner.ERXTestCase.runBare(ERXTestCase.java:95) at
>> > junit.framework.TestResult$1.protect(TestResult.java:106) at
>> > junit.framework.TestResult.runProtected(TestResult.java:124) at
>> > junit.framework.TestResult.run(TestResult.java:109) at
>> > junit.framework.TestCase.run(TestCase.java:118) at
>> > junit.framework.TestSuite.runTest(TestSuite.java:208) at
>> > junit.framework.TestSuite.run(TestSuite.java:203) at
>> > org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run
>> > (JUnit3TestReference.java:128) at
>> > org.eclipse.jdt.internal.junit.runner.TestExecution.run
>> > (TestExecution.java:38) at
>> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
>> > (RemoteTestRunner.java:460) at
>> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
>> > (RemoteTestRunner.java:673) at
>> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
>> > (RemoteTestRunner.java:386) at
>> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
>> > (RemoteTestRunner.java:196) Caused by:
>> > java.lang.ClassCastException at dm.inmega.Administrator.<clinit>
>> > (Administrator.java:34) ... 28 more
>> >
>> > Administrator is also an entity in MyProjectBusinessLogic and line
>> > 34 is:
>> >
>> > public static AdministratorClazz clazz = (AdministratorClazz)
>> > EOEnterpriseObjectClazz.clazzForEntityNamed("Administrator"); Is
>> > there a solution to this problem other that removing
>> > MyProjectBusinessLogic from Projects in Java Build Path of
>> > MyProject? There should be since to my mind this setup is pretty
>> > common.
>> >
>> > ---
>> > Denis Frolov
>> > Media Agency Design Maximum
>> >
>> > Tel: +7 863 2648211
>> > Fax: +7 863 2645229
>> > Web: http://www.designmaximum.com
>> >
>
>
--- Denis Frolov Media Agency Design MaximumTel: +7 863 2648211 Fax: +7 863 2645229 Web: http://www.designmaximum.com
This archive was generated by hypermail 2.0.0 : Mon Aug 07 2006 - 09:43:35 EDT