2013-04-30 67 views
2

我在嘗試使用openjpa做一個簡單示例時遇到了以上異常。這裏我使用了一個自定義的持久性提供者類。以下是我的persistence.xml文件。我經歷了以前的類似線程,但無法找到適合我的配置的解決方案。OpenJPA:必須在ConnectionDriverName屬性中指定JDBC驅動程序或DataSource類名稱

的persistence.xml

<?xml version="1.0" encoding="UTF-8"?> 
<persistence 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" 
      version="1.0"> 
    <persistence-unit name="juddiDatabase" transaction-type="RESOURCE_LOCAL"> 
     <provider>org.juddi.test.persistance.JUDDIPersistenceProviderImpl</provider> 
     <mapping-file>META-INF/orm.xml</mapping-file> 
     <!-- entity classes --> 
     <class>org.apache.juddi.model.Address</class> 
     <class>org.apache.juddi.model.AddressLine</class> 
     <class>org.apache.juddi.model.AuthToken</class> 
     <class>org.apache.juddi.model.BindingCategoryBag</class> 
     <class>org.apache.juddi.model.BindingDescr</class> 
     <class>org.apache.juddi.model.BindingTemplate</class> 
     <class>org.apache.juddi.model.BusinessCategoryBag</class> 
     <class>org.apache.juddi.model.BusinessDescr</class> 
     <class>org.apache.juddi.model.BusinessEntity</class> 
     <class>org.apache.juddi.model.BusinessIdentifier</class> 
     <class>org.apache.juddi.model.BusinessName</class> 
     <class>org.apache.juddi.model.BusinessService</class> 
     <class>org.apache.juddi.model.CategoryBag</class> 
     <class>org.apache.juddi.model.Clerk</class> 
     <class>org.apache.juddi.model.ClientSubscriptionInfo</class> 
     <class>org.apache.juddi.model.Contact</class> 
     <class>org.apache.juddi.model.ContactDescr</class> 
     <class>org.apache.juddi.model.DiscoveryUrl</class> 
     <class>org.apache.juddi.model.Email</class> 
     <class>org.apache.juddi.model.InstanceDetailsDescr</class> 
     <class>org.apache.juddi.model.InstanceDetailsDocDescr</class> 
     <class>org.apache.juddi.model.KeyedReference</class> 
     <class>org.apache.juddi.model.KeyedReferenceGroup</class> 
     <class>org.apache.juddi.model.Node</class> 
     <class>org.apache.juddi.model.OverviewDoc</class> 
     <class>org.apache.juddi.model.OverviewDocDescr</class> 
     <class>org.apache.juddi.model.PersonName</class> 
     <class>org.apache.juddi.model.Phone</class> 
     <class>org.apache.juddi.model.Publisher</class> 
     <class>org.apache.juddi.model.PublisherAssertion</class> 
     <class>org.apache.juddi.model.PublisherAssertionId</class> 
     <class>org.apache.juddi.model.ServiceCategoryBag</class> 
     <class>org.apache.juddi.model.ServiceDescr</class> 
     <class>org.apache.juddi.model.ServiceName</class> 
     <class>org.apache.juddi.model.ServiceProjection</class> 
     <class>org.apache.juddi.model.ServiceProjectionId</class> 
     <class>org.apache.juddi.model.Subscription</class> 
     <class>org.apache.juddi.model.SubscriptionChunkToken</class> 
     <class>org.apache.juddi.model.SubscriptionMatch</class> 
     <class>org.apache.juddi.model.Tmodel</class> 
     <class>org.apache.juddi.model.TmodelCategoryBag</class> 
     <class>org.apache.juddi.model.TmodelDescr</class> 
     <class>org.apache.juddi.model.TmodelIdentifier</class> 
     <class>org.apache.juddi.model.TmodelInstanceInfo</class> 
     <class>org.apache.juddi.model.TmodelInstanceInfoDescr</class> 
     <class>org.apache.juddi.model.TransferToken</class> 
     <class>org.apache.juddi.model.TransferTokenKey</class> 
     <class>org.apache.juddi.model.UddiEntity</class> 
     <class>org.apache.juddi.model.UddiEntityPublisher</class> 

     <properties> 
      <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/> 
      <property name="openjpa.Log" value="DefaultLevel=ERROR, Tool=ERROR"/> 
      <property name="openjpa.jdbc.UpdateManager" value="operation-order"/> 
      <property name="openjpa.RuntimeUnenhancedClasses" value="warn"/> 

      <!-- h2 connection properties --> 
      <property name="openjpa.ConnectionDriverName" value="org.h2.Driver"/> 
      <property name="openjpa.ConnectionURL" value="jdbc:h2:repository/database/juddiv3"/> 
      <property name="openjpa.ConnectionUserName" value="test"/> 
      <property name="openjpa.ConnectionPassword" value="test"/> 

      <!-- mysql connection properties 
      <property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/juddi"/> 
      <property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver"/> 
      <property name="openjpa.ConnectionUserName" value="juddiv3"/> 
      <property name="openjpa.ConnectionPassword" value=""/> 
      --> 
      <property name="openjpa.Compatibility" value="CheckDatabaseForCascadePersistToDetachedEntity=true"/> 
     </properties> 
    </persistence-unit> 
</persistence> 

而且我收到以下錯誤

org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property. Available properties in configuration are "[email protected]". 
at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72) 
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844) 
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602) 
at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510) 
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518) 
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:443) 
at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:104) 
at org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepositoryValue.java:68) 
at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83) 
at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:968) 
at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:959) 
at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:638) 
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:203) 
at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156) 
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227) 
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154) 
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60) 
at org.apache.juddi.config.PersistenceManager.getEntityManager(PersistenceManager.java:45) 
at org.apache.juddi.config.AppConfig.getPersistentConfiguration(AppConfig.java:109) 
at org.apache.juddi.config.AppConfig.loadConfiguration(AppConfig.java:95) 
at org.apache.juddi.config.AppConfig.<init>(AppConfig.java:62) 
at org.apache.juddi.config.AppConfig.getInstance(AppConfig.java:183) 
at org.apache.juddi.config.AppConfig.getConfiguration(AppConfig.java:205) 
at org.apache.juddi.Registry.start(Registry.java:55) 
+2

請,請設置openjpa.RuntimeUnenhancedClasses =警告。該屬性因非常好的原因而被禁用,您將遇到已知的錯誤。我建議獲取-javaagent或buildtime增強器設置。 – Rick 2013-04-30 13:05:45

+0

另外,還有沒有顯示的其他鏈接原因? – Rick 2013-04-30 13:07:42

+0

No..all被提及..在哪裏放openjpa.RuntimeUnenhancedClasses =警告?它有什麼用處。它會解決我的問題嗎?也沒有得到什麼你的意思是「我建議獲得-javaagent或buildtime增強器設置」 – 2013-04-30 17:44:50

回答

1

persistence.xml配置文件你有多個數據源的描述(MySQL和H2)。刪除其中一個,然後重試。

+0

MySQL連接屬性被註釋掉 Rick 2013-04-30 13:08:15

+0

是的,它被註釋掉了。 – 2013-04-30 17:39:26

相關問題