-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Configuring datasource using JPA, Hibernate, Spring
PostPosted: Tue Dec 06, 2011 2:37 am 
Newbie

Joined: Thu Jun 14, 2007 5:28 pm
Posts: 7
I have the following persistence.xml and profile-db.xml. Getting an error while reading the profile-db.xml. Is some thing wrong or am i missing some of the basics. You help is really appreciated...

Persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/persistence">

<persistence-unit name="dBManager11" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/dataSource-LAB</jta-data-source>
<mapping-file>profile-db.xml</mapping-file>
</persistence-unit>

</persistence>


profile-db.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/b ... -beans.xsd">

<bean id="dataSource-LAB" destroy-method="close"
class="org.apache.commons.dbcp.BasicDataSource">

<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />
<property name="hibernate.connection.url"
value="..." />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.connection.username" value="..." />
<property name="hibernate.connection.password" value="..." />

<property name="initialSize" value="1" />
<property name="maxActive" value="20" />
<property name="maxWait" value="300000" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<property name="testWhileIdle" value="true" />
<property name="timeBetweenEvictionRunsMillis" value="30000" />
<property name="validationQuery" value="SELECT sysdate from dual" />
</bean>

<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource-LAB"/>
<property name="persistenceUnitName" value="dBManager11" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
</bean>
</property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>

</beans>


Exception:
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: dBManager11] Error while reading JPA XML file: profile-db.xml
at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:1205)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1004)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:282)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:366)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at com.att.scld.grm.userprofiledao.utils.GRMUtils.<clinit>(GRMUtils.java:32)
... 40 more
Caused by: org.hibernate.InvalidMappingException: Unable to read XML
at org.hibernate.util.xml.MappingReader.readMappingDocument(MappingReader.java:101)
at org.hibernate.cfg.Configuration.add(Configuration.java:513)
at org.hibernate.cfg.Configuration.add(Configuration.java:509)
at org.hibernate.cfg.Configuration.add(Configuration.java:716)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:801)
at org.hibernate.cfg.AnnotationConfiguration.addResource(AnnotationConfiguration.java:152)
at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:1192)
... 47 more
Caused by: org.dom4j.DocumentException: null Nested exception: null
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.util.xml.MappingReader.readMappingDocument(MappingReader.java:75)
... 53 more


Top
 Profile  
 
 Post subject: Re: Configuring datasource using JPA, Hibernate, Spring
PostPosted: Tue Dec 06, 2011 3:09 pm 
Newbie

Joined: Mon Jun 21, 2010 9:03 am
Posts: 7
Hi!

The mapping file you are referencing in the Persistence.xml is a spring file and not a jpa mapping file.

See the errormessage:
Exception:
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: dBManager11] Error while reading JPA XML file: profile-db.xml

Insert in the persistence.xml file the annotated entities if you are using annotation based mechanism with the class element o r refrence a correct jpa mapping file.

e.g. for a valid jpa file just google or have a look at http://jdevelopment.nl/put-named-queries-jpa/

Best regards.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.