-->
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.  [ 3 posts ] 
Author Message
 Post subject: why i am getting Unable to configure EntityManagerFactory?
PostPosted: Fri Oct 01, 2010 8:13 am 
Newbie

Joined: Fri Oct 01, 2010 8:02 am
Posts: 2
why i am getting Unable to configure EntityManagerFactory? what is the problem in my persistence.xml(which is place in META-INF folder?

<?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" version="1.0">
<persistence-unit name="jpa">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>Student</class>
<properties>
<property name="hibernate.connection.url" value="jdbc:mysql:///test"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.password" value="test"/>
<property name="hibernate.connection.username" value="test"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>

---------- RUN ----------
62 [main] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.5.5-Final
3031 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.5.5-Final
4172 [main] INFO org.hibernate.cfg.Environment - loaded properties from resource hibernate.properties: {hibernate.connection.username=test, hibernate.connection.password=****, hibernate.connection.pool_size=10, hibernate.connection.url=jdbc:mysql:///test, hibernate.bytecode.use_reflection_optimizer=false, hibernate.connection.driver_class=com.mysql.jdbc.Driver}
4766 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
6094 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
16627 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
17861 [main] INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.5.5-Final
Exception ==> javax.persistence.PersistenceException: [PersistenceUnit: jpa] Unable to configure EntityManagerFactory
Normal Termination
Output completed (2 min 0 sec consumed).

my class pathe ientry is like below
C:\hibjars\antlr-2.7.4.jar;
C:\hibjars\c3p0-0.8.5.jar;
C:\hibjars\commons-collections-2.1.1.jar;
C:\hibjars\dom4j-1.5.2.jar;
C:\hibjars\hibernate3.jar;
C:\hibjars\asm-1.5.3.jar;
C:\hibjars\cglib-2.1.3.jar;
C:\hibjars\commons-logging-1.1.1.jar;
C:\hibjars\ehcache-1.1.jar;
C:\hibjars\jta.jar;
C:\hibjars\mysql-connector-java-3.1.6-bin.jar;
C:\hibjars\persistence-api-1.0.jar;
c:\hibjars\hibernate-entitymanager.jar;
C:\hibjars\hibernate-jpa-2.0-api-1.0.0.Final.jar;
C:\hibjars\slf4j-api-1.5.8.jar;
C:\hibjars\slf4j-simple-1.5.6.jar;
C:\hibjars\log4j.jar;
C:\hibjars\hibernate-annotations.jar;
C:\hibjars\hibernate-commons-annotations.jar;
c:\hibjars\javassist-3.9.0.GA.jar


Top
 Profile  
 
 Post subject: Re: why i am getting Unable to configure EntityManagerFactory?
PostPosted: Fri Oct 01, 2010 9:31 am 
Newbie

Joined: Fri Oct 01, 2010 9:21 am
Posts: 2
hi

Firstly, you can press "Ctrl+Shift+T" and then type the EntityManagerFactory in the textfield sitting in the pop-up dialog box. If you find it, that is a good news indicating you have already loaded the correct jar file.

So, you can then take a reference of my one.

I post it below.

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

   <!-- Datasource and Connection Pool Configuration -->
   <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
      destroy-method="close">
      <property name="driverClass">
         <value>com.mysql.jdbc.Driver</value>
      </property>
      <property name="jdbcUrl">
         <value>jdbc:mysql://localhost:3306/aip?useUnicode=true&amp;characterEncoding=utf8&amp;autoReconnect=true&amp;autoReconnectForPools=true</value>
      </property>
      <property name="user">
      <value>XinGuan</value>
      </property>
      <property name="password">
      <value>52230365</value>
      </property>
      
      <property name="maxPoolSize">
      <value>40</value>
      </property>
      <property name="minPoolSize">
      <value>1</value>
      </property>
      <property name="initialPoolSize">
      <value>1</value>
      </property>
      <property name="maxIdleTime">
      <value>20</value>
      </property>
   </bean>
   
   
   <!-- SessionFactory Configuration -->
   <bean id="mySessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="mappingResources">
         <list>
            <value>com/cn/pojo/Order.hbm.xml</value>
            <value>com/cn/pojo/Customer.hbm.xml</value>
            <value>com/cn/pojo/Product.hbm.xml</value>      
            <value>com/cn/pojo/OrderProduct.hbm.xml</value>         
         </list>
      </property>      
      
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">
               org.hibernate.dialect.MySQLDialect
            </prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="current_session_context_class">thread</prop>
            <prop key="hibernate.cache.provider_class">
               org.hibernate.cache.EhCacheProvider
            </prop>
            <prop key="connection.pool_size">10</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
         </props>
      </property>   
      
      <property name="dataSource">
         <ref bean="dataSource"/>
      </property>
   </bean>
   


Hope it helps.


Top
 Profile  
 
 Post subject: Re: why i am getting Unable to configure EntityManagerFactory?
PostPosted: Sat Oct 02, 2010 8:54 am 
Newbie

Joined: Fri Oct 01, 2010 8:02 am
Posts: 2
davidhe1127 wrote:
hi

Firstly, you can press "Ctrl+Shift+T" and then type the EntityManagerFactory in the textfield sitting in the pop-up dialog box. If you find it, that is a good news indicating you have already loaded the correct jar file.

So, you can then take a reference of my one.

I post it below.

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

   <!-- Datasource and Connection Pool Configuration -->
   <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
      destroy-method="close">
      <property name="driverClass">
         <value>com.mysql.jdbc.Driver</value>
      </property>
      <property name="jdbcUrl">
         <value>jdbc:mysql://localhost:3306/aip?useUnicode=true&amp;characterEncoding=utf8&amp;autoReconnect=true&amp;autoReconnectForPools=true</value>
      </property>
      <property name="user">
      <value>XinGuan</value>
      </property>
      <property name="password">
      <value>52230365</value>
      </property>
      
      <property name="maxPoolSize">
      <value>40</value>
      </property>
      <property name="minPoolSize">
      <value>1</value>
      </property>
      <property name="initialPoolSize">
      <value>1</value>
      </property>
      <property name="maxIdleTime">
      <value>20</value>
      </property>
   </bean>
   
   
   <!-- SessionFactory Configuration -->
   <bean id="mySessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="mappingResources">
         <list>
            <value>com/cn/pojo/Order.hbm.xml</value>
            <value>com/cn/pojo/Customer.hbm.xml</value>
            <value>com/cn/pojo/Product.hbm.xml</value>      
            <value>com/cn/pojo/OrderProduct.hbm.xml</value>         
         </list>
      </property>      
      
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">
               org.hibernate.dialect.MySQLDialect
            </prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="current_session_context_class">thread</prop>
            <prop key="hibernate.cache.provider_class">
               org.hibernate.cache.EhCacheProvider
            </prop>
            <prop key="connection.pool_size">10</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
         </props>
      </property>   
      
      <property name="dataSource">
         <ref bean="dataSource"/>
      </property>
   </bean>
   


Hope it helps.



Sorry David,
I dint get u ....

couple of things i want know
1)is its problem of multiple jars loaded?
2)is its problem of persistance.xml issue?
3)How many files need apart from (pojo class,jpaclient.java and persistance.xml)?

thanks in advance
hibernaterobot


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.