DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Testcase Required Testcase Required
Assignee: Unassigned
Reporter: Chris Colman
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
DataNucleus Store RDBMS

Metadata class cast error when using datastore-identity/sequence strategy with Oracle

Created: 27/Mar/13 05:14 AM   Updated: 06/Apr/13 10:00 AM   Resolved: 27/Mar/13 09:24 AM
Component/s: None
Affects Version/s: 3.2.0.m4
Fix Version/s: None

Oracle XE

 Description  « Hide
I encouter the following exception when setting up a class to use 'sequence' stategy for datastore identity.

    <class name="ms" detachable="true" persistence-modifier="persistence-capable" table="SS_GB_MESSAGE">
<datastore-identity strategy="sequence" sequence="ms"/>
        <inheritance strategy="new-table">
            <discriminator strategy="value-map" indexed="true" value="356572764">
                <column name="classid" jdbc-type="INTEGER" />
        <version strategy="version-number" column="VERSION" />
        <field name="n1" indexed="true">
        <field name="n2">
        <field name="n3">

        <field name="bits" persistence-modifier="persistent" mapped-by="master">
            <collection element-type="com.acme.Part"/>
        <field name="store" persistence-modifier="persistent">

<sequence name="messageSeq" datastore-sequence="SS_GB_MSGSEQ"/>

java.lang.ClassCastException: org.datanucleus.metadata.ClassMetaData cannot be cast to org.datanucleus.metadata.PackageMetaData
at org.datanucleus.api.jdo.metadata.JDOMetaDataHandler.startElement(
3 at
at javax.xml.parsers.SAXParser.parse(
at javax.xml.parsers.SAXParser.parse(
at org.datanucleus.metadata.xml.MetaDataParser.parseMetaDataStream(
at org.datanucleus.metadata.xml.MetaDataParser.parseMetaDataURL(
at org.datanucleus.api.jdo.metadata.JDOMetaDataManager.parseFile(
at org.datanucleus.api.jdo.metadata.JDOMetaDataManager.loadXMLMetaDataForClass(
at org.datanucleus.api.jdo.metadata.JDOMetaDataManager.getMetaDataForClassInternal(
at org.datanucleus.metadata.MetaDataManager.getMetaDataForClass(
at org.datanucleus.enhancer.RuntimeEnhancer.enhance(
at org.datanucleus.enhancer.DataNucleusClassFileTransformer.transform(
at sun.instrument.TransformerManager.transform(
at sun.instrument.InstrumentationImpl.transform(
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(
at java.lang.ClassLoader.defineClass(
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(

Sort Order: Ascending order - Click to sort in descending order
Chris Colman added a comment - 27/Mar/13 05:35 AM
I got it to work by removing the <sequence> element. It worked but it gives this warning on startup:

[ValueGeneration] Field com.acme.MyClass (datastore id) has been specified to use sequence SS_GB_MSGSEQ but there is no <sequence> specified in the MetaData. Falling back to use a sequence in the datastore with this name directly.

NOTE: the 'name' attribute in the above was actually 'ms' not 'messageSeq' as it says above.

Andy Jefferson added a comment - 27/Mar/13 09:24 AM
Since when has JDO DTD/XSD accepted <sequence> at <class> level?

Chris Colman added a comment - 27/Mar/13 09:34 AM
The sequence sample metadata on this page:


<class name="myclass" ... >
    <datastore-identity strategy="sequence" sequence="yourseq"/>
    <sequence name="yourseq" datastore-sequence="YOUR_SEQUENCE_NAME"/>

Isn't that showing it at class level?

Andy Jefferson added a comment - 27/Mar/13 02:40 PM
So the doc *was* wrong. The XSD and DTD have always been public, and the code has always matched those. Obviously users could contribute docs too.

Chris Colman added a comment - 28/Mar/13 12:05 AM
Just one more tweak ;) ...

The updated sequence metadata sample is not valid because according to the XSD 'strategy' is a required attribute:

    <xs:attributeGroup name="attlist.sequence">
        <xs:attribute name="name" use="required"/>
        <xs:attribute name="datastore-sequence"/>
        <xs:attribute name="factory-class"/>
        <xs:attribute name="strategy" use="required">
                <xs:restriction base="xs:token">
                    <xs:enumeration value="nontransactional"/>
                    <xs:enumeration value="contiguous"/>
                    <xs:enumeration value="noncontiguous"/>
        <xs:attribute name="initial-value" default="1"/>
        <xs:attribute name="allocation-size" default="50"/>

Perhaps the sample metadata could be changed to:

<sequence name="yourseq" datastore-sequence="YOUR_SEQUENCE_NAME" ... />
<class name="myclass" ... >
    <datastore-identity strategy="sequence" sequence="yourseq"/>

i.e. add '...' to the sequence element to indicate that it's an incomplete example or perhaps we could just add the attribute: strategy="contiguous" to make it a complete, valid example.