ClassCastException: EnhancementNucleusContextImpl --> PersistenceNucleusContext


Christopher Mosher <cmosher01@...>
 

Andy,
Thank you for investigating so quickly. And thanks for all your work on Datanucleus.
Regards,
Chris Mosher

On Sat, Apr 7, 2018, 02:41 Andy <andy@...> wrote:
Thx for the report.
See https://github.com/datanucleus/datanucleus-api-jdo/issues/68
Seems like when this CDI handling code was copied across from the JPA plugin it wasn't copied exactly, so was applying at enhancement and at runtime, when only runtime makes any sense.


Andy
 

Thx for the report.
See https://github.com/datanucleus/datanucleus-api-jdo/issues/68
Seems like when this CDI handling code was copied across from the JPA plugin it wasn't copied exactly, so was applying at enhancement and at runtime, when only runtime makes any sense.


cmosher01@...
 

I'm trying to use the Ant task to enhance a class having a field with a custom converter attached, and I'm getting the following class-cast exception. Any ideas what might be causing it, or how to work around it?
I'd be glad to create a minimized test-case if needed.

[ant:enhance] 21:06:42.254 [main] DEBUG DataNucleus.Enhancer - Enhancing classes
[ant:enhance] 21:06:42.255 [main] DEBUG DataNucleus.MetaData - MetaData Management : Loading Metadata for metadata files "[/home/user/dev/github_cmosher01/Genealdb/build/resources/main/META-INF/package.jdo]" ...
[ant:enhance] 21:06:42.259 [main] DEBUG DataNucleus.MetaData - Parsing MetaData file "file:/home/user/dev/github_cmosher01/Genealdb/build/resources/main/META-INF/package.jdo" using handler "jdo" (validation="false")
[ant:enhance] 21:06:42.275 [main] ERROR DataNucleus.MetaData - An error occurred while parsing <"field"> nested within "org.datanucleus.metadata.ClassMetaData@3c9bfddc [nu.mine.mosher.genealdb.model.Day], modifier=persistence-capable, members.size=0" for URI "http://xmlns.jcp.org/xml/ns/jdo/jdo"
[ant:enhance] java.lang.ClassCastException: org.datanucleus.enhancer.EnhancementNucleusContextImpl cannot be cast to org.datanucleus.PersistenceNucleusContext
[ant:enhance]   at org.datanucleus.api.jdo.metadata.JDOMetaDataHandler.newFieldObject(JDOMetaDataHandler.java:300) ~[datanucleus-api-jdo-5.1.5.jar:?]
[ant:enhance]   at org.datanucleus.api.jdo.metadata.JDOMetaDataHandler.startElement(JDOMetaDataHandler.java:677) [datanucleus-api-jdo-5.1.5.jar:?]
[ant:enhance]   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509) [?:?]
[ant:enhance]   at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:183) [?:?]
[ant:enhance]   at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:351) [?:?]
[ant:enhance]   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2706) [?:?]
[ant:enhance]   at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:601) [?:?]
[ant:enhance]   at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112) [?:?]
[ant:enhance]   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:531) [?:?]
[ant:enhance]   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:885) [?:?]
[ant:enhance]   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:821) [?:?]
[ant:enhance]   at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) [?:?]
[ant:enhance]   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213) [?:?]
[ant:enhance]   at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:639) [?:?]
[ant:enhance]   at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:323) [?:?]
[ant:enhance]   at javax.xml.parsers.SAXParser.parse(SAXParser.java:196) [?:?]
[ant:enhance]   at org.datanucleus.metadata.xml.MetaDataParser.parseMetaDataStream(MetaDataParser.java:290) [datanucleus-core-5.1.8.jar:?]
[ant:enhance]   at org.datanucleus.metadata.xml.MetaDataParser.parseMetaDataURL(MetaDataParser.java:190) [datanucleus-core-5.1.8.jar:?]
[ant:enhance]   at org.datanucleus.api.jdo.metadata.JDOMetaDataManager.parseFile(JDOMetaDataManager.java:253) [datanucleus-api-jdo-5.1.5.jar:?]
[ant:enhance]   at org.datanucleus.metadata.MetaDataManagerImpl.loadFiles(MetaDataManagerImpl.java:1425) [datanucleus-core-5.1.8.jar:?]
[ant:enhance]   at org.datanucleus.metadata.MetaDataManagerImpl.loadMetadataFiles(MetaDataManagerImpl.java:527) [datanucleus-core-5.1.8.jar:?]
[ant:enhance]   at org.datanucleus.enhancer.DataNucleusEnhancer.getFileMetadataForInput(DataNucleusEnhancer.java:732) [datanucleus-core-5.1.8.jar:?]
[ant:enhance]   at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:501) [datanucleus-core-5.1.8.jar:?]
[ant:enhance]   at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1157) [datanucleus-core-5.1.8.jar:?]

Thank you,
Chris Mosher