Heiko, Thanks for following up so quickly. I put together a quick test and wasn't able to produce the same result. I was just about to type up an email asking for more info. I'm glad to hear you were able to work around the issue with a simple change.
I agree that having the exception surfaced from OpenJPA, if possible, would be more helpful. If you can supply a simple test to show the problem we could certainly look into propagating the exception. Filing a JIRA[1] would be the best route. That way, you can attach the test directly to the JIRA and keep and eye out for a fix. -Jeremy [1] https://issues.apache.org/jira/browse/OPENJPA On Wed, Sep 29, 2010 at 1:09 AM, <[email protected]> wrote: > Hello Jeremy, > > thank you for your investigations. I might have come up with a reason for > this problem. I tried to simply load the class TypeMapping during the > maven integration test exactly before the openJPA test begun. It did not > load, but an ExceptionInInitializer was thrown. Though openJPA was in its > final decision right as the class was 'bad' cause it was not loadable. > > However, the really interesting thing is why in the maven test phase the > static initializer failed and thus the class did not load. Within the > static initializer we load an xml-file via > > Thread.currentThread().getContextClassLoader().getResourceAsStream( > "/TypeMapping.xml") > > As this seems to work well inside the application server, it does not work > when maven's integration phase is running. The xml file is not found. > Without the leading slash it works for both, the application server AND > maven's integration phase. > > To summarize: > > 1) openJPA does not cause this the problem > 2) the actual cause WHY the class is bad for meta data is hidden and leads > to difficult-to-find problems. If the stack trace contained the > ExceptionInInitializer-Exception, this mail would have never been written > ;-) > 3) Maybe providing the causing exception in future versions of openJPA > (although I'm stuck at openJPA 1.0.4 right now) would be an improvement. > > Best regards, and thank you again for your short reply. > > Heiko > > [email protected] schrieb am 28.09.2010 16:14:10: > > > Hi Heiko, > > > > Odd problem, indeed. I'll setup a similar environment and let you know > if I > > have any suggestions. Which version of maven are you using and which > OS? > > > > -Jeremy > > > > On Tue, Sep 28, 2010 at 5:10 AM, Heiko Kopp > <[email protected]>wrote: > > > > > > > > Hello, > > > > > > I've encountered a problem when using openJPA inside mavens > integration > > > test > > > phase. Alot of my entities respectively their members have been > annotated > > > with @Factory and @Externalizer to automatically convert database > datatypes > > > into schema relevent enumerations. An example for this is: > > > > > > @Entity > > > @Table(name = "PARTNER", schema = "PART") > > > public class Partner > > > { > > > .... > > > > > > @Column(name = "I_SCHL_WERTBEZ") > > > @Externalizer(TypeMapping.MARSHAL_SALUTATION_INDIVIDUAL) > > > @Factory(TypeMapping.UNMARSHAL_SALUTATION_INDIVIDUAL) > > > private SalutationIndividualEnum salutationIndividual; > > > > > > ... > > > } > > > > > > The Externalizer- and Factory-Methods have been extracted into a > separate > > > class called 'TypeMapping'. In this class we additionally have the > > > following > > > string constants as used above: > > > > > > public static final String MARSHAL_SALUTATION_INDIVIDUAL > > > = > > > > > > "com.mbbank.partner.pas.common.system.typemapping.TypeMapping. > > marshalSalutationIndividual"; > > > > > > public static final String UNMARSHAL_SALUTATION_INDIVIDUAL > > > = > > > > > > "com.mbbank.partner.pas.common.system.typemapping.TypeMapping. > > unmarshalSalutationIndividual"; > > > > > > These strings referr to the actuall methods. > > > > > > The TypeMapping-class is located in a different package than the > entity > > > class. And this seems to be a problem during test test phase in maven. > > > While > > > the code works perfectly in the application server, it fails in the > maven > > > test phase with the following exception: > > > > > > <openjpa-1.0.4-SNAPSHOT-r420667:809016 fatal user error> > > > org.apache.openjpa.persistence.ArgumentException: Der Klassenname > > > "com.mbbank.partner.pas.common.system.typemapping.TypeMapping", der in > der > > > Metadatenerweiterung im Feld > > > > > > "com.mbbank.partner.pas.common.system.database.model.Person. > > salutationIndividual" > > > verwendet wird, ist nicht gültig. > > > at org.apache.openjpa.meta.JavaTypes.classForName(JavaTypes.java:227) > > > at > > > org.apache.openjpa.meta.JavaTypes.classForName(JavaTypes.java:194) > > > at > > > org.apache.openjpa.meta.JavaTypes.classForName(JavaTypes.java:185) > > > at > > > > org.apache.openjpa.meta.FieldMetaData.findMethod(FieldMetaData.java:1533) > > > at > > > > > > org.apache.openjpa.meta.FieldMetaData. > > getExternalizerMethod(FieldMetaData.java:1465) > > > at > > > org.apache.openjpa.meta.FieldMetaData.resolve(FieldMetaData.java:1640) > > > at > > > > org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:400) > > > at > > > > org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1688) > > > at > > > org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1623) > > > at > > > > > > org.apache.openjpa.meta.MetaDataRepository. > > processBuffer(MetaDataRepository.java:675) > > > at > > > > > > org.apache.openjpa.meta.MetaDataRepository. > > resolveMeta(MetaDataRepository.java:574) > > > at > > > > > > org.apache.openjpa.meta.MetaDataRepository. > > resolve(MetaDataRepository.java:499) > > > at > > > > > > org.apache.openjpa.meta.MetaDataRepository. > > getMetaData(MetaDataRepository.java:301) > > > at > > > org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1060) > > > at > > > > > > org.apache.openjpa.kernel.DelegatingBroker. > > newObjectId(DelegatingBroker.java:252) > > > at > > > > > > org.apache.openjpa.persistence.EntityManagerImpl. > > find(EntityManagerImpl.java:347) > > > > > > The string is localized into German, the original one is referred to > as > > > 'bad-class'. It's English representation is: > > > > > > bad-class: The class name "{0}" used in a metadata extension on field > "{1}" > > > is not valid. > > > > > > As both class files are present in the same module and even during the > test > > > phase, I've actually no clue on how to fix this issue. It can be > fixed, > > > when > > > I put the static methods in the same package/class as the annotated > field, > > > but that is no solutation for us as it will duplicate a lot of code. > > > > > > Has anyone an idea why this appends and what can be done to prevent > it? > > > > > > Thank you very much. > > > > > > As seen in the stack trace above, I'm using openJPA 1.0.4-<something>, > > > which > > > is part of the Websphere Application Server 6.1.0.29. > > > > > > Best regards, > > > > > > Heiko > > > -- > > > View this message in context: > > > http://openjpa.208410.n2.nabble.com/Externalizer-not-working- > > during-maven-test-phase-tp5578748p5578748.html > > > Sent from the OpenJPA Users mailing list archive at Nabble.com. > > > > > > If you are not the intended addressee, please inform us immediately that > you have received this e-mail in error, and delete it. We thank you for your > cooperation.
