On May 14, 2008, at 8:32 AM, JimOR wrote:



David Blevins wrote:

One way to verify would be to split your test case into two classes;
the TestCase subclass which would do nothing more than setup OpenEJB
via the InitialContext and have a test method that delegated to your
second class which actually did test. The idea being the second class
which references the entity classes wouldn't get loaded until after
the first class has run and setup the dynamic enhancer.

Let us know if that's the case as we can probably document this kind
of OpenJPA specific testing technique.
-David



I had the same thought initially and refactored my test classes to extend an abstract parent with a @BeforeClass annotation that sets my InitialContext. Then I setup lazy bean instantiation in a parent @Before method, and moved
all @Entity references inside methods annotated with @Test.

Perhaps the parent test class level @Stateful bean references (which
reference @Entities) are the culprit?

Could be. The bean classes themselves wouldn't be the issue but likely the entity types are listed in the business interface method signatures. There definitely should be some way to swizzle things around so the issue is avoided.

One tricky way might be to put static initializers with "i'm being loaded" system.out statements in a few classes. That may be ineffective if the classes are loaded with initialization off -- Class.forName("foo", false, classLoader) -- but it's worth a quick try.

-David

Reply via email to