openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dain Sundstrom <d...@iq80.com>
Subject NoSuchFieldException
Date Tue, 13 Feb 2007 00:00:38 GMT
I have this scenario in my CMP2JPA tool where I have to generate  
subclasses of CMP1 beans.  When the user has an "unknown" primary key  
or more commonly, when they use the same ejb class for multiple  
deployments, I have to generate a sub class to either add an extra  
field, or to differentiate two usages of the same class.  So say I  
have the class "foo.TestBean", like this:

package foo;
public class TestBeanEJB implements EntityBean {
     public Integer KEY_ID;
     public String NAME;
}

I generate a sub class like this:

package openejb.foo;
public class TestBeanEJB implements foo.TestBeanEJB {
}

The entity mappings I use look like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"  
version="1.0">
     <entity name="TestBean" class="openejb.foo.TestBean">
         <table name="TEST"/>
         <attributes>
             <id name="KEY_ID">
                 <column name="ID"/>
             </id>
             <basic name="NAME">
                 <column name="NAME"/>
             </basic>
         </attributes>
     </entity>
</entity-mappings>

That all seems good, but when I deploy my bean I get the following  
exception:

INFO   [Thread-10] openjpa.MetaData - Parsing package  
"openejb.foo.TestBean".
TRACE  [Thread-10] openjpa.MetaData - An exception occurred while  
parsing jar:file:/tmp/OpenEJB_Generated_1334.jar!/META-INF/openejb- 
cmp-generated-orm.xml at location Line: 7, C: 31. 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: KEY_ID
     at java.lang.Class.getDeclaredField(Class.java:1854)
     at  
org.apache.openjpa.persistence.XMLPersistenceMetaDataParser.parseField 
(XMLPersistenceMetaDataParser.java:1079)
     at  
org.apache.openjpa.persistence.XMLPersistenceMetaDataParser.startId 
(XMLPersistenceMetaDataParser.java:877)
     at  
org.apache.openjpa.persistence.XMLPersistenceMetaDataParser.startClassEl 
ement(XMLPersistenceMetaDataParser.java:543)
     at org.apache.openjpa.lib.meta.CFMetaDataParser.startElement 
(CFMetaDataParser.java:105)
     at org.apache.openjpa.lib.meta.XMLMetaDataParser.startElement 
(XMLMetaDataParser.java:426)
     at org.apache.xerces.parsers.AbstractSAXParser.startElement 
(Unknown Source)
     at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement 
(Unknown Source)
     at  
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement 
(Unknown Source)
     at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl 
$FragmentContentDispatcher.dispatch(Unknown Source)
     at  
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument 
(Unknown Source)
     at org.apache.xerces.parsers.XML11Configuration.parse(Unknown  
Source)
     at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
     at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
     at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown  
Source)
     at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
     at org.apache.openjpa.lib.meta.XMLMetaDataParser.parseNewResource 
(XMLMetaDataParser.java:370)
     at org.apache.openjpa.lib.meta.XMLMetaDataParser.parse 
(XMLMetaDataParser.java:312)
     at org.apache.openjpa.lib.meta.XMLMetaDataParser.parse 
(XMLMetaDataParser.java:289)
     at org.apache.openjpa.lib.meta.XMLMetaDataParser.parse 
(XMLMetaDataParser.java:263)
     at  
org.apache.openjpa.persistence.PersistenceMetaDataFactory.parseXML 
(PersistenceMetaDataFactory.java:229)
     at org.apache.openjpa.persistence.PersistenceMetaDataFactory.load 
(PersistenceMetaDataFactory.java:180)
     at org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal 
(MetaDataRepository.java:412)
     at org.apache.openjpa.meta.MetaDataRepository.getMetaData 
(MetaDataRepository.java:270)
     at org.apache.openjpa.enhance.PCEnhancer.<init>(PCEnhancer.java: 
187)
     at org.apache.openjpa.enhance.PCClassFileTransformer.transform 
(PCClassFileTransformer.java:124)
     at org.apache.openjpa.persistence.PersistenceProviderImpl 
$ClassTransformerImpl.transform(PersistenceProviderImpl.java:140)
     at org.apache.openejb.persistence.PersistenceUnitInfoImpl 
$PersistenceClassFileTransformer.transform 
(PersistenceUnitInfoImpl.java:259)

Note: the exception should at least tell us which class had the  
problem :)

Is there some magic flag for JPA that, I can use to make it look in  
the super class fields persistent fields?

-dain


Mime
View raw message