db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig Russell (JIRA)" <j...@apache.org>
Subject [jira] Commented: (JDO-327) JPOX fails to create new instance of PC class via pm.newInstance(PCInterface)
Date Sun, 30 Apr 2006 07:25:38 GMT
    [ http://issues.apache.org/jira/browse/JDO-327?page=comments#action_12377148 ] 

Craig Russell commented on JDO-327:
-----------------------------------

Running tests with the uploaded jars, I found that the instances of persistent interfaces
are not being cleaned up during localTearDown.

This is due to JPOX not finding instances in the database using Extent or Query. Instances
can only be found using getObjectById. The tearDown method cleans up the instances using deletePersistent
of the result of a query where the candidates are an Extent.

1. getExtent(ICompany.class) returns an Extent which when iterated, has no elements.
2. pm.newQuery(ICompany.class).execute() returns a Collection which when iterated, has no
elements.
3. pm.newQuery().setCandidates(pm.getExtent(ICompany.class).execute() returns a Collection
which when iterated, has no elements.
4. the target class stored in the oid for persistent instances is incorrect. This must be
the interface, not the implementation's persistent class. 
<spec section=12.6.6>
For interfaces and classes that use a SingleFieldIdentity as the object-id class, if the 
returned instance is subsequently made persistent, the target class stored in the object-id

instance is the parameter of the newInstance method that created it. 
</spec>

All of these symptoms might have the same root cause. The discriminator stored in the table
doesn't match the value of the discriminator assumed for the persistent interface. The best
solution is probably to store the interface name as the discriminator value and the name of
the target class in the object id.

Please see JDO-377 for some debugging tests for this issue.

> JPOX fails to create new instance of PC class via pm.newInstance(PCInterface)
> -----------------------------------------------------------------------------
>
>          Key: JDO-327
>          URL: http://issues.apache.org/jira/browse/JDO-327
>      Project: JDO
>         Type: Bug

>   Components: tck20
>     Versions: JDO 2 rc1
>     Reporter: Craig Russell
>     Assignee: Erik Bengtson
>      Fix For: JDO 2 final
>  Attachments: jpox-1.1.0.jar, jpox-enhancer-1.1.0.jar
>
> This is a new test for persistent interfaces. JPOX fails while obtaining metadata for
the persistent interface IAddress.
> IAddress newAddress() {
>     return (IAddress)pm.newInstance(IAddress.class);
> }
> maven -o -Djdo.tck.cfglist=companyPMInterface.conf runtck.jdori
>     [java] RUN CompletenessTest.test       ERROR
>     [java] Description: Completeness test with standard mapping, basic testdata with
all relationships and embedded objects.
>     [java] Time: 009
>     [java] There was 1 error:
>     [java] 1) test(org.apache.jdo.tck.mapping.CompletenessTest)org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'root' defined in class path resource [org/apache/jdo/tck/pc/company/companyAllRelationships.xml]:
Can't resolve reference to bean 'company1' while setting property 'constructor argument with
index 0[0]'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'company1' defined in class path resource [org/apache/jdo/tck/pc/company/companyAllRelationships.xml]:
Can't resolve reference to bean 'addr1' while setting property 'constructor argument with
index 3'; nested exception is org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'addr1' defined in class path resource [org/apache/jdo/tck/pc/company/companyAllRelationships.xml]:
Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException:
Factory method [public org.apache.jdo.tck.pc.company.IAddress org.apache.jdo.tck.pc.company.CompanyFactoryAbstractImpl.newAddress(long,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)]
threw exception; nested exception is javax.jdo.JDOException: Cannot read the JDO Meta-Data
file "<input stream> java.lang.ClassCastException: org.jpox.metadata.EmbeddedMetaData"
>     [java] org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'company1' defined in class path resource [org/apache/jdo/tck/pc/company/companyAllRelationships.xml]:
Can't resolve reference to bean 'addr1' while setting property 'constructor argument with
index 3'; nested exception is org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'addr1' defined in class path resource [org/apache/jdo/tck/pc/company/companyAllRelationships.xml]:
Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException:
Factory method [public org.apache.jdo.tck.pc.company.IAddress org.apache.jdo.tck.pc.company.CompanyFactoryAbstractImpl.newAddress(long,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)]
threw exception; nested exception is javax.jdo.JDOException: Cannot read the JDO Meta-Data
file "<input stream> java.lang.ClassCastException: org.jpox.metadata.EmbeddedMetaData"
>     [java] org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'addr1' defined in class path resource [org/apache/jdo/tck/pc/company/companyAllRelationships.xml]:
Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException:
Factory method [public org.apache.jdo.tck.pc.company.IAddress org.apache.jdo.tck.pc.company.CompanyFactoryAbstractImpl.newAddress(long,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)]
threw exception; nested exception is javax.jdo.JDOException: Cannot read the JDO Meta-Data
file "<input stream> java.lang.ClassCastException: org.jpox.metadata.EmbeddedMetaData"
>     [java] org.springframework.beans.factory.BeanDefinitionStoreException: Factory method
[public org.apache.jdo.tck.pc.company.IAddress org.apache.jdo.tck.pc.company.CompanyFactoryAbstractImpl.newAddress(long,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)]
threw exception; nested exception is javax.jdo.JDOException: Cannot read the JDO Meta-Data
file "<input stream> java.lang.ClassCastException: org.jpox.metadata.EmbeddedMetaData"
>     [java] javax.jdo.JDOException: Cannot read the JDO Meta-Data file "<input stream>
java.lang.ClassCastException: org.jpox.metadata.EmbeddedMetaData"
>     [java]      at org.jpox.metadata.MetaDataParser.parseMetaDataStream(MetaDataParser.java:174)
>     [java]      at org.jpox.metadata.MetaDataParser.parseMetaData(MetaDataParser.java:107)
>     [java]      at org.jpox.metadata.MetaDataManager.parseFile(MetaDataManager.java:1131)
>     [java]      at org.jpox.metadata.MetaDataManager.loadMetaDataForClass(MetaDataManager.java:1319)
>     [java]      at org.jpox.metadata.MetaDataManager.addORMDataToClass(MetaDataManager.java:644)
>     [java]      at org.jpox.metadata.ClassMetaData.populate(ClassMetaData.java:429)
>     [java]      at org.jpox.metadata.MetaDataManager.populateClassesInFile(MetaDataManager.java:1211)
>     [java]      at org.jpox.metadata.MetaDataManager.loadMetaDataForClass(MetaDataManager.java:1325)
>     [java]      at org.jpox.metadata.MetaDataManager.getMetaDataForClassOrInterface(MetaDataManager.java:503)
>     [java]      at org.jpox.metadata.MetaDataManager.getMetaDataForInterface(MetaDataManager.java:392)
>     [java]      at org.jpox.AbstractPersistenceManager.newInstance(AbstractPersistenceManager.java:2250)
>     [java]      at org.apache.jdo.tck.pc.company.CompanyFactoryPMInterface.newAddress(CompanyFactoryPMInterface.java:38)
>     [java]      at org.apache.jdo.tck.pc.company.CompanyFactoryAbstractImpl.newAddress(CompanyFactoryAbstractImpl.java:46)
>     [java]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     [java]      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>     [java]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>     [java]      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:102)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:573)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:325)
>     [java]      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
>     [java]      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
>     [java]      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
>     [java]      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveConstructorArguments(AbstractAutowireCapableBeanFactory.java:705)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:486)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:325)
>     [java]      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
>     [java]      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
>     [java]      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
>     [java]      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
>     [java]      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:193)
>     [java]      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveConstructorArguments(AbstractAutowireCapableBeanFactory.java:705)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:611)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:329)
>     [java]      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
>     [java]      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
>     [java]      at org.apache.jdo.tck.pc.company.CompanyModelReader.getRootList(CompanyModelReader.java:101)
>     [java]      at org.apache.jdo.tck.mapping.CompletenessTest.localSetUp(CompletenessTest.java:95)
>     [java]      at org.apache.jdo.tck.JDO_Test.setUp(JDO_Test.java:187)
>     [java]      at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:203)
>     [java]      at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:120)
>     [java]      at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:95)
>     [java] NestedThrowablesStackTrace:
>     [java] java.lang.ClassCastException: org.jpox.metadata.EmbeddedMetaData
>     [java]      at org.jpox.metadata.MetaDataParser.startElement(MetaDataParser.java:466)
>     [java]      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533)
>     [java]      at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:220)
>     [java]      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:872)
>     [java]      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
>     [java]      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
>     [java]      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
>     [java]      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
>     [java]      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
>     [java]      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
>     [java]      at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
>     [java]      at javax.xml.parsers.SAXParser.parse(SAXParser.java:176)
>     [java]      at org.jpox.metadata.MetaDataParser.parseMetaDataStream(MetaDataParser.java:162)
>     [java]      at org.jpox.metadata.MetaDataParser.parseMetaData(MetaDataParser.java:107)
>     [java]      at org.jpox.metadata.MetaDataManager.parseFile(MetaDataManager.java:1131)
>     [java]      at org.jpox.metadata.MetaDataManager.loadMetaDataForClass(MetaDataManager.java:1319)
>     [java]      at org.jpox.metadata.MetaDataManager.addORMDataToClass(MetaDataManager.java:644)
>     [java]      at org.jpox.metadata.ClassMetaData.populate(ClassMetaData.java:429)
>     [java]      at org.jpox.metadata.MetaDataManager.populateClassesInFile(MetaDataManager.java:1211)
>     [java]      at org.jpox.metadata.MetaDataManager.loadMetaDataForClass(MetaDataManager.java:1325)
>     [java]      at org.jpox.metadata.MetaDataManager.getMetaDataForClassOrInterface(MetaDataManager.java:503)
>     [java]      at org.jpox.metadata.MetaDataManager.getMetaDataForInterface(MetaDataManager.java:392)
>     [java]      at org.jpox.AbstractPersistenceManager.newInstance(AbstractPersistenceManager.java:2250)
>     [java]      at org.apache.jdo.tck.pc.company.CompanyFactoryPMInterface.newAddress(CompanyFactoryPMInterface.java:38)
>     [java]      at org.apache.jdo.tck.pc.company.CompanyFactoryAbstractImpl.newAddress(CompanyFactoryAbstractImpl.java:46)
>     [java]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     [java]      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>     [java]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>     [java]      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:102)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:573)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:325)
>     [java]      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
>     [java]      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
>     [java]      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
>     [java]      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveConstructorArguments(AbstractAutowireCapableBeanFactory.java:705)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:486)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:325)
>     [java]      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
>     [java]      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
>     [java]      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
>     [java]      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
>     [java]      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:193)
>     [java]      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveConstructorArguments(AbstractAutowireCapableBeanFactory.java:705)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:611)
>     [java]      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:329)
>     [java]      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
>     [java]      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
>     [java]      at org.apache.jdo.tck.pc.company.CompanyModelReader.getRootList(CompanyModelReader.java:101)
>     [java]      at org.apache.jdo.tck.mapping.CompletenessTest.localSetUp(CompletenessTest.java:95)
>     [java]      at org.apache.jdo.tck.JDO_Test.setUp(JDO_Test.java:187)
>     [java]      at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:203)
>     [java]      at org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:120)
>     [java]      at org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:95)
>     [java] FAILURES!!!

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message