openjpa error while using eclipselink - java

I am getting the below error , when I test my application on oracle cloud. I am using Eclipse link but the below error is indicating openjpa.
<openjpa-1.1.1-SNAPSHOT-r422266:1445923 fatal user error> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.
at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:776)
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:553)
at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1250)
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:505)
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:430)
at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103)
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:843)
at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:834)
at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:638)
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:183)
at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:199)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:152)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
this is my persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
<persistence-unit name="viamd" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>weblogic.jdbc.jts.viamd</jta-data-source>
<class>com.intiqua.viamd.model.datamanipulation.DataAccountingUnitBean</class>
<class>com.intiqua.viamd.model.datamanipulation.DataActionsBean</class>
<class>com.intiqua.viamd.model.datamanipulation.DataActionsRoleBean</class>
<class>com.intiqua.viamd.model.datamanipulation.DataAddressBean</class>
<class>com.intiqua.viamd.model.datamanipulation.DataAdmitOrderMatrixBean</class>
<class>com.intiqua.viamd.model.datamanipulation.DataAgeGroupBean</class>
<class>com.intiqua.viamd.model.datamanipulation.DataAgeGroupBrandBean</class>
<class>com.intiqua.viamd.model.datamanipulation.DataAOMatrixHospAssocBean</class>
<properties>
<property name="eclipselink.logging.level" value="FINEST"/>
<property name="eclipselink.logging.level.cache" value="FINEST" />
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.logging.level.sql" value="FINE"/>
<property name="eclipselink.logging.timestamp" value="true"/>
<property name="eclipselink.logging.session" value="true"/>
<property name="eclipselink.logging.exceptions" value="true"/>
<property name="eclipselink.logging.thread" value="true"/>
</properties>
</persistence-unit>
</persistence>
I am getting error while executing the below line of code:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("viamd");
EntityManager em = emf.createEntityManager();

Related

javax.persistence.PersistenceException: No Persistence provider for EntityManager named

Hello I am new in Java Web and I have a problem that I get this communicate
javax.persistence.PersistenceException: No Persistence provider for EntityManager named NaszSerwisPU
Here is my 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="NaszSerwisPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>User</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value="passsword"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/naszserwis"/>
<property name="hibernate.max_fetch_depth" value="3"/>
</properties>
</persistence-unit>
</persistence>
I try to call:
public String logIn() {
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("NaszSerwisPU");
EntityManager mgr = entityManagerFactory.createEntityManager();
User us = new User();
us.setLogin("admin");
us.setPassword("admin");
mgr.persist(us);
return "/main.xhtml";
}
I don`t know why i get this communicate.
I use NetBeans
UPDATE:
I had removed hibernate.cfg.xml and changed
<provider>org.hibernate.ejb.HibernatePersistenceProvider></provider>
to:
<provider>org.hibernate.jpa.HibernatePersistenceProvider></provider>
but problem still exist, communicate of error is the same.
You do not need hibernate.cfg.xml if you use JPA and persistence.xml
I believe you should write
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
Make sure that persistence.xml file is in the right location.
See this Persistence.xml where to put in eclipse project

OpenJPA: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property

I am getting above exception when trying to do a simple example using openjpa. Here I am using a custom persistance provider class. Following is my persistence.xml file. I went through the previous similar threads but couldn't find a proper solution with my configurations.
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>
And I am getting the following error
org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property. Available properties in configuration are "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl#442ce698".
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)
in your persistence.xml config file you have several datasource descriptions (MySQL and H2). Delete one of them and try again.

JPA removes MySql triggers

Because my persistence.xml uses drop-and-create-tables:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
<persistence-unit name="USENETPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>net.bounceme.dur.usenet.model.NewsgroupsArticles</class>
<class>net.bounceme.dur.usenet.model.Article</class>
<class>net.bounceme.dur.usenet.model.Newsgroup</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/nntp"/>
<property name="javax.persistence.jdbc.password" value="password"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.user" value="java"/>
<property name="toplink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
</properties>
</persistence-unit>
</persistence>
My triggers get removed each run. Where can I put the triggers so that they're not removed?
You should use a SessionCustomizer. And within your persistence properties you should insert a property pointing your SessionCustomizer implementation.
properties.put(PersistenceUnitProperties.SESSION_CUSTOMIZER, MySessionCustomizer.class.getName());
or
<property name="eclipselink.session.customizer" value="foo.bar.MySessionCustomizer" />
and within this session customizer you could load your trigger codes and let it be executed with:
unitOfWork.executeNonSelectingSQL(sql);
A detailed explanation regarding this topic you can find here

Is the file persistence.xml required?

My development environment (IBM RAD 8 + WAS 8) is complaining that my project does not have a persistence.xml file. Still it seems that I can build and run my project. Is that file required and if a add one such file to make my project pass validation, what should be in that file?
The project is a web project that uses session beans and entity beans from other projects and this persistence.xml error is the only error in the project so I'd be glad to get rid of it.
Thanks for any help
Update
I searched my files for persistence.xml and it showed up in src/ and bin/ of the EJB project while the web project with servlets and jsp does not have a persistence.xml, according to my colleague the web project is using the persistence.xml from the EJB project i.e:
<?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="PandoraArendeWeb" transaction-type="JTA">
<jta-data-source>jdbc/Mainframe_TEST_ADBUTV2</jta-data-source>
<class>se.prv.pandora.arendeprocess.entity.PRVNummer</class>
<class>se.prv.pandora.arendeprocess.entity.Ansokan</class>
<class>se.prv.pandora.arendeprocess.entity.NatAnsokan</class>
<class>se.prv.pandora.arendeprocess.entity.PctAnsokan</class>
<class>se.prv.pandora.arendeprocess.entity.ArendePerson</class>
<class>se.prv.pandora.arendeprocess.entity.Nyregistrering</class>
<class>se.prv.pandora.arendeprocess.entity.Anstalld</class>
<class>se.prv.pandora.arendeprocess.entity.Handlaggare</class>
<class>se.prv.pandora.arendeprocess.entity.OrgElement</class>
<class>se.prv.pandora.arendeprocess.entity.FysiskHandlaggare</class>
<class>se.prv.pandora.arendeprocess.entity.AnsvarigHandlaggare</class>
<class>se.prv.pandora.arendeprocess.entity.AnsvarigFysiskHandlaggare</class>
<class>se.prv.pandora.arendeprocess.entity.TeknikOmrade</class>
<class>se.prv.pandora.arendeprocess.entity.Person</class>
<class>se.prv.pandora.arendeprocess.entity.PRVNummerPerson</class>
<class>se.prv.pandora.arendeprocess.entity.Notering</class>
<class>se.prv.pandora.arendeprocess.entity.Lock</class>
<class>se.prv.pandora.arendeprocess.entity.LandKod</class>
<class>se.prv.pandora.arendeprocess.entity.ArbetsMomentLog</class>
<class>se.prv.pandora.arendeprocess.entity.SystemTypDel</class>
<class>se.prv.pandora.arendeprocess.entity.ArbetsMoment</class>
<class>se.prv.pandora.arendeprocess.entity.UnderStatus</class>
<class>se.prv.pandora.arendeprocess.entity.PatPers</class>
<class>se.prv.pandora.arendeprocess.entity.PrvLandP</class>
<class>se.prv.pandora.arendeprocess.entity.PkaPerln</class>
<class>se.prv.pandora.arendeprocess.entity.PctnPerl</class>
<class>se.prv.pandora.arendeprocess.entity.PersonToPatPersKoppl</class>
<class>se.prv.pandora.arendeprocess.entity.PRVNummerPersonKoppl</class>
<class>se.prv.pandora.arendeprocess.entity.Region</class>
<class>se.prv.pandora.arendeprocess.entity.Historik</class>
<class>se.prv.pandora.arendeprocess.entity.Egenskap</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
</persistence-unit>
<!-- <persistence-unit name="PandoraArendeWeb_MSSQL" transaction-type="JTA">
<jta-data-source>jdbc/MSSQL_TEST_XA</jta-data-source>
<class>se.prv.pandora.arendeprocess.entity.PersonSearch</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
</persistence-unit>
-->
</persistence>
persistence.xml files usually contain details related to your database, such as connection strings and their respective user names and passwords including other ORM related information. These details can be placed in other locations so you need not explicitly have one, although having such a file usually makes all persistence related information available in one place which makes looking up certain settings and configurations easier.
This is a sample persistence.xml file:
<?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="<PERSISTENCE UNIT NAME>">
<properties>
<!--
<property name="hibernate.ejb.cfgfile" value="/hibernate.cfg.xml"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
-->
<property name="hibernate.archive.autodetection" value="class, hbm"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.password" value="<PASSWORD>"/>
<property name="hibernate.connection.url" value="jdbc:mysql://<HOST IP ADDRESS>/<DB NAME>"/>
<property name="hibernate.connection.username" value="<USERNAME>"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.c3p0.min_size" value="5"/>
<property name="hibernate.c3p0.max_size" value="20"/>
<property name="hibernate.c3p0.timeout" value="300"/>
<property name="hibernate.c3p0.max_statements" value="50"/>
<property name="hibernate.c3p0.idle_test_period" value="3000"/>
</properties>
</persistence-unit>
</persistence>
The above content was taken from here.
<?xml version="1.0" encoding="UTF-8" ?>
<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_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="AINS" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.tridenthyundai.ains.domainobject.AccessoriesDO</class>
<class>com.tridenthyundai.ains.domainobject.BranchDO</class>
<class>com.tridenthyundai.ains.domainobject.ContactDO</class>
<class>com.tridenthyundai.ains.domainobject.CustomerDO</class>
<class>com.tridenthyundai.ains.domainobject.FinanceDO</class>
<class>com.tridenthyundai.ains.domainobject.InsuranceDO</class>
<class>com.tridenthyundai.ains.domainobject.MessageDO</class>
<class>com.tridenthyundai.ains.domainobject.NotificationDO</class>
<class>com.tridenthyundai.ains.domainobject.ProductDO</class>
<class>com.tridenthyundai.ains.domainobject.ProductPriceDO</class>
<class>com.tridenthyundai.ains.domainobject.ProductSpecDO</class>
<class>com.tridenthyundai.ains.domainobject.ProductVariantDO</class>
<class>com.tridenthyundai.ains.domainobject.PurchaseDO</class>
<class>com.tridenthyundai.ains.domainobject.ServiceCentreDO</class>
<class>com.tridenthyundai.ains.domainobject.ServiceDO</class>
<class>com.tridenthyundai.ains.domainobject.ServiceTypeDO</class>
<class>com.tridenthyundai.ains.domainobject.UserDO</class>
<class>com.tridenthyundai.ains.domainobject.VisitorDO</class>
<!-- shouldn't be valid for java SE per specification, but it works for EclipseLink ... -->
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<!-- For Local Testing -->
<!-- <properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://saptalabs:3306/tridenthyundai" />
<property name="javax.persistence.jdbc.user" value="adminuser" />
<property name="javax.persistence.jdbc.password" value="adminuser" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="eclipselink.cache.shared.default" value="false"/>
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.logging.level" value="SEVERE" />
</properties> -->
<!-- For Production -->
</persistence-unit>
</persistence>
<?xml version="1.0" encoding="UTF-8" ?>
<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_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="saptalabs" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.sapta.hr.domainobject.UserDO</class>
<class>com.sapta.hr.domainobject.EmployeeDO</class>
<class>com.sapta.hr.domainobject.AddressDO</class>
<class>com.sapta.hr.domainobject.EmpDetailDO</class>
<class>com.sapta.hr.domainobject.EmpAccDetailDO</class>
<class>com.sapta.hr.domainobject.ProjectDO</class>
<class>com.sapta.hr.domainobject.CustomerDO</class>
<class>com.sapta.hr.domainobject.EmpAssignmentDO</class>
<class>com.sapta.hr.domainobject.EmpAboutDO</class>
<class>com.sapta.hr.domainobject.EmpAchievementsDO</class>
<class>com.sapta.hr.domainobject.EmpEmploymentHistoryDO</class>
<class>com.sapta.hr.domainobject.EmpSportsDO</class>
<class>com.sapta.hr.domainobject.EmpCulturalsDO</class>
<class>com.sapta.hr.domainobject.EmpEducationDO</class>
<class>com.sapta.hr.domainobject.EmpLanguageKnownDO</class>
<class>com.sapta.hr.domainobject.EmpReferencesDO</class>
<class>com.sapta.hr.domainobject.EmpSkillSetDO</class>
<class>com.sapta.hr.domainobject.EmpFamilyBackgroundDO</class>
<class>com.sapta.hr.domainobject.AssetDO</class>
<class>com.sapta.hr.domainobject.AssetTypeDO</class>
<class>com.sapta.hr.domainobject.EmpCTCDO</class>
<class>com.sapta.hr.domainobject.ExpenseDO</class>
<class>com.sapta.hr.domainobject.ExpTypeDO</class>
<class>com.sapta.hr.domainobject.InvoiceDO</class>
<class>com.sapta.hr.domainobject.PayrollDO</class>
<class>com.sapta.hr.domainobject.ProfessionalTaxDO</class>
<class>com.sapta.hr.domainobject.TDSDO</class>
<class>com.sapta.hr.domainobject.VendorDO</class>
<class>com.sapta.hr.domainobject.BillsDO</class>
<class>com.sapta.hr.domainobject.EmpLoseOfPayDO</class>
<!-- shouldn't be valid for java SE per specification, but it works for
EclipseLink ... -->
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<!-- For Local Testing -->
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/hrportal" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="root" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="eclipselink.cache.shared.default" value="false" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode"
value="database" />
<property name="eclipselink.logging.level" value="SEVERE" />
</properties>
</persistence-unit>
</persistence>

How to define an non-JTA datasource for JPA-Hibernate? org.hibernate.connection.DatasourceConnectionProvider - Could not find datasource:

I am trying to change my web-app's JDBC code to JPA using Hibernate as provider. I am using Eclipse IDE. In that i have defined a MySQL data source. I added it in the persistence.xml.
But, I am getting the below error.
6640 [30289364#qtp-7494106-7] ERROR org.hibernate.connection.DatasourceConnectionProvider - Could not find datasource: tamSql
javax.naming.NameNotFoundException; remaining name 'tamSql'
My persistence.xml looks like,
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
<persistence-unit name="ExpensePersistentUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>tamSql</non-jta-data-source>
<class>com.pricar.JPAInteg.Role</class>
<class>com.pricar.JPAInteg.User</class>
<class>com.pricar.JPAInteg.Userdetail</class>
<class>com.pricar.JPAInteg.Category</class>
<class>com.pricar.JPAInteg.Expens</class>
<class>com.pricar.JPAInteg.Leavetable</class>
<class>com.pricar.JPAInteg.Permissiontoken</class>
<class>com.pricar.JPAInteg.Roletokenassociation</class>
<class>com.pricar.JPAInteg.UserPK</class>
<properties>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/officemgmt"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"></property>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.password" value="1234"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
</properties>
Any Suggestions!!!
Thanks in Advance!
You don't need <non-jta-data-source> when your datasource is configured in <properties>. <non-jta-data-source> is needed when datasource is configured in application server configuration and obtained via JNDI.

Categories

Resources