You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by GESCONSULTOR - Óscar Bou <o....@gesconsultor.com> on 2013/06/26 16:43:16 UTC

DataNucleus enhancer problem?

While executing JUnit tests with the new "integtests" classes I receive the following exception (same happening from the Eclipse Junit installation and from "Maven tests"). I'm not sure if it's a problem of the DataNucleus Enhancer or Isis:



java.lang.RuntimeException: java.lang.ClassCastException: java.lang.String cannot be cast to javax.jdo.spi.PersistenceCapable
	at org.apache.isis.core.integtestsupport.IsisSystemForTest.setUpSystem(IsisSystemForTest.java:258)
	at integtests.com.xms.framework.continuity.domain.model.AbstractContinuityTest$IsisSystemForTestRule$1.initialValue(AbstractContinuityTest.java:282)
	at integtests.com.xms.framework.continuity.domain.model.AbstractContinuityTest$IsisSystemForTestRule$1.initialValue(AbstractContinuityTest.java:1)
	at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:141)
	at java.lang.ThreadLocal.get(ThreadLocal.java:131)
	at integtests.com.xms.framework.continuity.domain.model.AbstractContinuityTest$IsisSystemForTestRule.getIsisSystemForTest(AbstractContinuityTest.java:288)
	at integtests.com.xms.framework.continuity.domain.model.AbstractContinuityTest$IsisSystemForTestRule.apply(AbstractContinuityTest.java:294)
	at org.junit.runners.BlockJUnit4ClassRunner.withMethodRules(BlockJUnit4ClassRunner.java:349)
	at org.junit.runners.BlockJUnit4ClassRunner.withRules(BlockJUnit4ClassRunner.java:339)
	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:256)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to javax.jdo.spi.PersistenceCapable
	at org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryProcessorAbstract.loadAdapters(PersistenceQueryProcessorAbstract.java:82)
	at org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindUsingApplibQueryProcessor.process(PersistenceQueryFindUsingApplibQueryProcessor.java:67)
	at org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindUsingApplibQueryProcessor.process(PersistenceQueryFindUsingApplibQueryProcessor.java:39)
	at org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.processPersistenceQuery(DataNucleusObjectStore.java:541)
	at org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.loadInstancesAndAdapt(DataNucleusObjectStore.java:536)
	at org.apache.isis.core.runtime.system.persistence.PersistenceSession$1.execute(PersistenceSession.java:433)
	at org.apache.isis.core.runtime.system.persistence.PersistenceSession$1.execute(PersistenceSession.java:430)
	at org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.executeWithinTransaction(IsisTransactionManager.java:220)
	at org.apache.isis.core.runtime.system.persistence.PersistenceSession.getInstancesFromPersistenceLayer(PersistenceSession.java:430)
	at org.apache.isis.core.runtime.system.persistence.PersistenceSession.getInstances(PersistenceSession.java:426)
	at org.apache.isis.core.runtime.system.persistence.PersistenceSession.findInstances(PersistenceSession.java:363)
	at org.apache.isis.core.runtime.system.persistence.PersistenceSession.findInstances(PersistenceSession.java:358)
	at org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession$8.firstMatchingQuery(RuntimeContextFromSession.java:260)
	at org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault.firstMatch(DomainObjectContainerDefault.java:391)
	at org.apache.isis.applib.AbstractContainedObject.firstMatch(AbstractContainedObject.java:155)
	at com.xms.framework.risk.domain.model.continuity.BusinessContinuityManagementSystems.businessContinuityManagementSystem(BusinessContinuityManagementSystems.java:22)
	at com.xms.framework.risk.domain.model.continuity.BusinessProcessesBCMInformation.createTransientBIA(BusinessProcessesBCMInformation.java:72)
	at com.xms.framework.risk.domain.model.continuity.BusinessProcessesBCMInformation.createTransientBusinessProcessBCMInformation(BusinessProcessesBCMInformation.java:91)
	at com.xms.framework.risk.domain.model.continuity.BusinessProcessesBCMInformation.createPersistentBusinessProcessBCMInformation(BusinessProcessesBCMInformation.java:103)
	at com.xms.framework.risk.domain.model.continuity.BusinessProcessesBCMInformation.businessContinuityInformation(BusinessProcessesBCMInformation.java:51)
	at com.xms.framework.risk.domain.model.continuity.BusinessProcessesBCMInformation.businessContinuityInformation(BusinessProcessesBCMInformation.java:27)
	at com.xms.framework.continuity.fixtures.BCMFixture.installBCMFixture(BCMFixture.java:36)
	at com.xms.framework.continuity.fixtures.BCMFixture.install(BCMFixture.java:27)
	at org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate.installFixture(FixturesInstallerDelegate.java:213)
	at org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate.installFixtureInTransaction(FixturesInstallerDelegate.java:175)
	at org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate.installFixtures(FixturesInstallerDelegate.java:162)
	at org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate.installFixtures(FixturesInstallerDelegate.java:142)
	at org.apache.isis.core.integtestsupport.IsisSystemForTest.wireAndInstallFixtures(IsisSystemForTest.java:292)
	at org.apache.isis.core.integtestsupport.IsisSystemForTest.setUpSystem(IsisSystemForTest.java:283)
	at org.apache.isis.core.integtestsupport.IsisSystemForTest.setUpSystem(IsisSystemForTest.java:256)
	... 24 more


Also, it's curious, because the exception is on the "frameworkSynchronizer.postLoadProcessingFor((PersistenceCapable) pojo, CalledFrom.OS_QUERY);"  line of code:

    protected List<ObjectAdapter> loadAdapters(
            final ObjectSpecification specification, final List<?> pojos) {
        final List<ObjectAdapter> adapters = Lists.newArrayList();
        for (final Object pojo : pojos) {
        	// ought not to be necessary, however for some queries it seems that the 
        	// lifecycle listener is not called
	    	frameworkSynchronizer.postLoadProcessingFor((PersistenceCapable) pojo, CalledFrom.OS_QUERY);
            ObjectAdapter adapter = getAdapterManager().getAdapterFor(pojo);
            Assert.assertNotNull(adapter);
            adapters.add(adapter);
        }
        return adapters;
    }

The pojo is a reference to a Domain Entity class that has the @PersistenceCapable annotation. And the "original" Java exception message is:

ClassCastException: Cannot cast "com.xms.framework.risk.domain.model.continuity.BusinessContinuityManagementSystem" to javax.jdo.spi.PersistenceCapable	


Despite that, the following message is on "ex"  when returning to executeWithinTransaction (on the  "} catch (final RuntimeException ex) {" block):

java.lang.ClassCastException: java.lang.String cannot be cast to javax.jdo.spi.PersistenceCapable





Re: DataNucleus enhancer problem?

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Hi Oscar,
I think there are two issues here.

1. the fundamental issue looks like the enhancer didn't run correctly at
some point; this would explain the underlying exception of not being able
to cast your com.xms.framework.risk.domain.model.continuity.
BusinessContinuityManagementSystem to javax.jdo.spi.PersistenceCapable.

2. it looks like in Isis we somehow don't catch that exception
appropriately, and end up throwing something rather misleading in its place.

If this is still an issue for you, contact me offline; I think I need to
see it to try to help resolve it.  (If we do that, I'll post any findings
back here on the ML).

Thanks
Dan



On 26 June 2013 15:43, GESCONSULTOR - Óscar Bou <o....@gesconsultor.com>wrote:

>
> While executing JUnit tests with the new "integtests" classes I receive
> the following exception (same happening from the Eclipse Junit installation
> and from "Maven tests"). I'm not sure if it's a problem of the DataNucleus
> Enhancer or Isis:
>
>
>
> java.lang.RuntimeException: java.lang.ClassCastException: java.lang.String
> cannot be cast to javax.jdo.spi.PersistenceCapable
>         at
> org.apache.isis.core.integtestsupport.IsisSystemForTest.setUpSystem(IsisSystemForTest.java:258)
>         at
> integtests.com.xms.framework.continuity.domain.model.AbstractContinuityTest$IsisSystemForTestRule$1.initialValue(AbstractContinuityTest.java:282)
>         at
> integtests.com.xms.framework.continuity.domain.model.AbstractContinuityTest$IsisSystemForTestRule$1.initialValue(AbstractContinuityTest.java:1)
>         at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:141)
>         at java.lang.ThreadLocal.get(ThreadLocal.java:131)
>         at
> integtests.com.xms.framework.continuity.domain.model.AbstractContinuityTest$IsisSystemForTestRule.getIsisSystemForTest(AbstractContinuityTest.java:288)
>         at
> integtests.com.xms.framework.continuity.domain.model.AbstractContinuityTest$IsisSystemForTestRule.apply(AbstractContinuityTest.java:294)
>         at
> org.junit.runners.BlockJUnit4ClassRunner.withMethodRules(BlockJUnit4ClassRunner.java:349)
>         at
> org.junit.runners.BlockJUnit4ClassRunner.withRules(BlockJUnit4ClassRunner.java:339)
>         at
> org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:256)
>         at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
>         at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
>         at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
>         at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
>         at
> org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
>         at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
>         at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
>         at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
>         at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
>         at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
>         at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> Caused by: java.lang.ClassCastException: java.lang.String cannot be cast
> to javax.jdo.spi.PersistenceCapable
>         at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryProcessorAbstract.loadAdapters(PersistenceQueryProcessorAbstract.java:82)
>         at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindUsingApplibQueryProcessor.process(PersistenceQueryFindUsingApplibQueryProcessor.java:67)
>         at
> org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindUsingApplibQueryProcessor.process(PersistenceQueryFindUsingApplibQueryProcessor.java:39)
>         at
> org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.processPersistenceQuery(DataNucleusObjectStore.java:541)
>         at
> org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.loadInstancesAndAdapt(DataNucleusObjectStore.java:536)
>         at
> org.apache.isis.core.runtime.system.persistence.PersistenceSession$1.execute(PersistenceSession.java:433)
>         at
> org.apache.isis.core.runtime.system.persistence.PersistenceSession$1.execute(PersistenceSession.java:430)
>         at
> org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.executeWithinTransaction(IsisTransactionManager.java:220)
>         at
> org.apache.isis.core.runtime.system.persistence.PersistenceSession.getInstancesFromPersistenceLayer(PersistenceSession.java:430)
>         at
> org.apache.isis.core.runtime.system.persistence.PersistenceSession.getInstances(PersistenceSession.java:426)
>         at
> org.apache.isis.core.runtime.system.persistence.PersistenceSession.findInstances(PersistenceSession.java:363)
>         at
> org.apache.isis.core.runtime.system.persistence.PersistenceSession.findInstances(PersistenceSession.java:358)
>         at
> org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession$8.firstMatchingQuery(RuntimeContextFromSession.java:260)
>         at
> org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault.firstMatch(DomainObjectContainerDefault.java:391)
>         at
> org.apache.isis.applib.AbstractContainedObject.firstMatch(AbstractContainedObject.java:155)
>         at
> com.xms.framework.risk.domain.model.continuity.BusinessContinuityManagementSystems.businessContinuityManagementSystem(BusinessContinuityManagementSystems.java:22)
>         at
> com.xms.framework.risk.domain.model.continuity.BusinessProcessesBCMInformation.createTransientBIA(BusinessProcessesBCMInformation.java:72)
>         at
> com.xms.framework.risk.domain.model.continuity.BusinessProcessesBCMInformation.createTransientBusinessProcessBCMInformation(BusinessProcessesBCMInformation.java:91)
>         at
> com.xms.framework.risk.domain.model.continuity.BusinessProcessesBCMInformation.createPersistentBusinessProcessBCMInformation(BusinessProcessesBCMInformation.java:103)
>         at
> com.xms.framework.risk.domain.model.continuity.BusinessProcessesBCMInformation.businessContinuityInformation(BusinessProcessesBCMInformation.java:51)
>         at
> com.xms.framework.risk.domain.model.continuity.BusinessProcessesBCMInformation.businessContinuityInformation(BusinessProcessesBCMInformation.java:27)
>         at
> com.xms.framework.continuity.fixtures.BCMFixture.installBCMFixture(BCMFixture.java:36)
>         at
> com.xms.framework.continuity.fixtures.BCMFixture.install(BCMFixture.java:27)
>         at
> org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate.installFixture(FixturesInstallerDelegate.java:213)
>         at
> org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate.installFixtureInTransaction(FixturesInstallerDelegate.java:175)
>         at
> org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate.installFixtures(FixturesInstallerDelegate.java:162)
>         at
> org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate.installFixtures(FixturesInstallerDelegate.java:142)
>         at
> org.apache.isis.core.integtestsupport.IsisSystemForTest.wireAndInstallFixtures(IsisSystemForTest.java:292)
>         at
> org.apache.isis.core.integtestsupport.IsisSystemForTest.setUpSystem(IsisSystemForTest.java:283)
>         at
> org.apache.isis.core.integtestsupport.IsisSystemForTest.setUpSystem(IsisSystemForTest.java:256)
>         ... 24 more
>
>
> Also, it's curious, because the exception is on the
> "frameworkSynchronizer.postLoadProcessingFor((PersistenceCapable) pojo,
> CalledFrom.OS_QUERY);"  line of code:
>
>     protected List<ObjectAdapter> loadAdapters(
>             final ObjectSpecification specification, final List<?> pojos) {
>         final List<ObjectAdapter> adapters = Lists.newArrayList();
>         for (final Object pojo : pojos) {
>                 // ought not to be necessary, however for some queries it
> seems that the
>                 // lifecycle listener is not called
>
> frameworkSynchronizer.postLoadProcessingFor((PersistenceCapable) pojo,
> CalledFrom.OS_QUERY);
>             ObjectAdapter adapter =
> getAdapterManager().getAdapterFor(pojo);
>             Assert.assertNotNull(adapter);
>             adapters.add(adapter);
>         }
>         return adapters;
>     }
>
> The pojo is a reference to a Domain Entity class that has the
> @PersistenceCapable annotation. And the "original" Java exception message
> is:
>
> ClassCastException: Cannot cast
> "com.xms.framework.risk.domain.model.continuity.BusinessContinuityManagementSystem"
> to javax.jdo.spi.PersistenceCapable
>
>
> Despite that, the following message is on "ex"  when returning to
> executeWithinTransaction (on the  "} catch (final RuntimeException ex) {"
> block):
>
> java.lang.ClassCastException: java.lang.String cannot be cast to
> javax.jdo.spi.PersistenceCapable
>
>
>
>
>