I'm using Weblogic 10MP1, JDK 1.5, and OpenJPA 1.2.1. I've constructed an EAR file which wraps my WAR file, which contains my domain classes and my persistence.xml file.
I've specified the "prefer-application-packages" element in my weblogic-application.xml file, to take "org.apache.openjpa.*" from my jars, not from WebLogic. I started up WebLogic with a "-javaagent" parameter pointing to the "openjpa-1.2.1.jar" file. I saw the following in the console: -------------- Caused by: <1.0.0 fatal user error> org.apache.openjpa.util.MetaDataException: MetaDataFactory could not be configured (conf.newMetaDataFactoryInstance() returned null). This might mean that no configuration properties were found. Ensure that you have a META-INF/persistence.xml file, that it is available in your classpath, or that the properties file you are using for configuration is available. If you are using Ant, please see the <properties> or <propertiesFile> attributes of the task's nested <config> element. This can also occur if your OpenJPA distribution jars are corrupt, or if your security policy is overly strict. at org.apache.openjpa.meta.MetaDataRepository.initializeMetaDataFactory(Met aDataRepository.java:1496) at org.apache.openjpa.meta.MetaDataRepository.endConfiguration(MetaDataRepo sitory.java:1489) at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurati ons.java:450) at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurati ons.java:375) at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:102 ) at kodo.conf.CachingMetaDataRepositoryPlugin.instantiate(CachingMetaDataRep ositoryPlugin.java:29) at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:79) at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryIn stance(OpenJPAConfigurationImpl.java:833) at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryIn stance(OpenJPAConfigurationImpl.java:828) at org.apache.openjpa.conf.OpenJPAConfigurationImpl.instantiateAll(OpenJPAC onfigurationImpl.java:1414) at org.apache.openjpa.enhance.PCEnhancerAgent.premain(PCEnhancerAgent.java: 65) -------------- I'll show the structure of my EAR/WAR and where the persistence.xml file is, but there's a clue in this stack trace that really bothers me. One of the entries refers to "kodo", which is WebLogic's older JPA implementation, which corresponds to OpenJPA 1.0.0. I've looked at some of the source files in OpenJPA 1.2.1 that are referenced in this stack trace, and it's clear those line numbers don't correspond to the 1.2.1 source. So, somehow WebLogic is ignoring my "prefer-application-packages" element. Despite that feeling, I also note that this error occurs as a result of the "javaagent" processing, which explicitly specifies the openjpa-1.2.1.jar, before it even loads my application. This is also odd, because it's implying that it couldn't find the "persistence.xml" file for my application, but it's clear it got this error before it even tried to load my application. So, concerning my EAR structure, at the root of the EAR is my WAR file, and my "persistence.xml" file is in "WEB-INF/classes/META-INF" in the WAR. The following is my simple persistence.xml file (with some things elided): <?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="myunitname" transaction-type="JTA"> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provid er> <jta-data-source>myjtadatasource</jta-data-source> <mapping-file>pathtomappingfile</mapping-file> <properties> <property name="openjpa.Log" value="DefaultLevel=TRACE"/> </properties> </persistence-unit> </persistence>