I'm starting slow with a couple of domain classes, each with a couple of
basic attributes, and each with a single OneToMany collection, one
referencing the other, and the second referencing the same entity.

I'm trying to have a mix of annotations and XML metadata, by only using
"logical" annotations, and the XML specifies what would have been done
with the physical annotations.

When I run the enhancer task, I get a NoSuchFieldException on the first
"basic" element.  The "name" value is the property name in the class.

Included here are the relevant excerpts of my entity classes,
persistence.xml, and orm.xml file.  I removed the getters/setters from
the classes and the package/imports.  I replaced a couple of unimportant
strings in the persistence.xml and orm.xml with "<<...>>>" wrappers.

At the end I have my build output, showing the NoSuchFieldException.
I've marked line 14 in the orm.xml file.

Is there anything obviously wrong here?

@Entity
public class Catalog {
    @Id private String  id;
    @Basic private String displayName;
    @Basic private Date creationDate;
    @OneToMany private Set<Category>   rootCategories;
}

@Entity
public class Category {
    @Id private String  id;
    @Basic private String  displayName;
    @Basic private Date    creationDate;
    @OneToMany private Set<Category>   childCategories;
}

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence"; 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence

 
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd";>
    <persistence-unit name="<<unitname>>" transaction-type="JTA">
 
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provid
er>
        <jta-data-source>jdbc/catalog</jta-data-source>
        <mapping-file><<filepath>>/domain/orm.xml</mapping-file>
        <properties>
            <property name="openjpa.Log" value="DefaultLevel=TRACE"/>
        </properties>
    </persistence-unit>
</persistence>

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd";
    version="1.0">
    <description><<applicationname>></description>
    <package><<packagepath>>.domain</package>
    <entity name="Catalog" class="<<packagepath>>.domain.Catalog">
        <table name="<<tablename>>"/>
        <attributes>
            <id name="id">
                <column name="CATALOG_ID"/>
            </id>
            <basic name="displayName"> <!-- This is line 14 -->
                <column name="DISPLAY_NAME"/>
            </basic>
            <basic name="creationDate">
                <column name="CREATION_DATE"/>
            </basic>
            <one-to-many name="rootCategories" target-entity="Category">
            </one-to-many>
        </attributes>
    </entity>
    <entity name="Category" class="<<packagepath>>.domain.Category">
        <table name="<<tablename>>"/>
        <attributes>
            <id name="id">
                <column name="CATEGORY_ID"/>
            </id>
            <basic name="displayName">
                <column name="DISPLAY_NAME"/>
            </basic>
            <basic name="creationDate">
                <column name="CREATION_DATE"/>
            </basic>
            <one-to-many name="childCategories"
target-entity="Category">
            </one-to-many>
        </attributes>
    </entity>
</entity-mappings>

0  dynamicContent  TRACE  [main] openjpa.Runtime - Setting the following
properties from "file:<<filepath>>/src/META-INF/persistence.xml" into
configuration: {openjpa.Log=DefaultLevel=TRACE,
openjpa.MetaDataFactory=jpa(Resources=<<filepath>>/domain/orm.xml),
javax.persistence.provider=org.apache.openjpa.persistence.PersistencePro
viderImpl, openjpa.ConnectionFactoryMode=managed,
openjpa.TransactionMode=managed,
openjpa.ConnectionFactoryName=jdbc/catalog, openjpa.Id=dynamicContent}
16  dynamicContent  TRACE  [main] openjpa.Runtime - No cache marshaller
found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
110  dynamicContent  TRACE  [main] openjpa.Runtime - No cache marshaller
found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
125  dynamicContent  TRACE  [main] openjpa.Tool - Enhancer running on
type "class <<packagepath>>.domain.Catalog".
188  dynamicContent  TRACE  [main] openjpa.MetaData - Loading metadata
for "class <<packagepath>>.domain.Catalog" under mode "[META][QUERY]".
188  dynamicContent  TRACE  [main] openjpa.MetaData - Scanning resource
"<<filepath>>/domain/orm.xml" for persistent types.
188  dynamicContent  TRACE  [main] openjpa.MetaData - Scan of
"<<filepath>>/domain/orm.xml" found persistent types
[Ljava.lang.String;@19eda2c.
188  dynamicContent  TRACE  [main] openjpa.MetaData - Mapping resource
location "file:<<filepath>>/domain/orm.xml" to persistent types
"[<<packagepath>>.domain.Catalog, <<packagepath>>.domain.Category]".
188  dynamicContent  TRACE  [main] openjpa.MetaData - Scanning resource
"META-INF/orm.xml" for persistent types.
188  dynamicContent  TRACE  [main] openjpa.MetaData -
parsePersistentTypeNames() found [<<packagepath>>.domain.Catalog,
<<packagepath>>.domain.Category].
188  dynamicContent  TRACE  [main] openjpa.MetaData - Found 2 classes
with metadata in 0 milliseconds.
204  dynamicContent  TRACE  [main] openjpa.MetaData - Parsing resource
"file:<<filepath>>/domain/orm.xml".
266  dynamicContent  TRACE  [main] openjpa.MetaData - Parsing class
"<<packagepath>>.domain.Catalog".
282  dynamicContent  TRACE  [main] openjpa.MetaData - Generating default
metadata for type "<<packagepath>>.domain.Catalog".
282  dynamicContent  TRACE  [main] openjpa.MetaData - Using reflection
for metadata generation.
297  dynamicContent  TRACE  [main] openjpa.MetaData - Parsing class
"<<packagepath>>.domain.Catalog".
329  dynamicContent  TRACE  [main] openjpa.MetaData - An exception
occurred while parsing file:<<filepath>>/domain/orm.xml at location
Line: 14, C: 39. This exception has been translated to a SAXException,
and will be re-thrown. The original exception is being logged along with
this message.
java.lang.NoSuchFieldException: displayName
        at java.lang.Class.getDeclaredField(Class.java:1854)
        at
org.apache.openjpa.lib.util.J2DoPrivHelper$6.run(J2DoPrivHelper.java:253
)
        at java.security.AccessController.doPrivileged(Native Method)
        at
org.apache.openjpa.persistence.XMLPersistenceMetaDataParser.parseField(X
MLPersistenceMetaDataParser.java:1120)
        at
org.apache.openjpa.persistence.XMLPersistenceMetaDataParser.startStrateg
y(XMLPersistenceMetaDataParser.java:1205)
        at
org.apache.openjpa.persistence.XMLPersistenceMetaDataParser.startClassEl
ement(XMLPersistenceMetaDataParser.java:624)
        at
org.apache.openjpa.lib.meta.CFMetaDataParser.startElement(CFMetaDataPars
er.java:111)
        at
org.apache.openjpa.lib.meta.XMLMetaDataParser.startElement(XMLMetaDataPa
rser.java:432)

Reply via email to