Announcement Announcement Module
Collapse
No announcement yet.
Error creating bean 'entityManagerFactory' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error creating bean 'entityManagerFactory'

    Hi,
    I am trying to integrate hibernate with spring. I do not have all the JPA entites generated yet but I am setting up my datasource, persistenceunit and referencing that in applicationcontext.xml
    However, when I start JBoss 5.1 I am seeing that ''entityManagerFactory'' fails to get initialized and I see the below exception in the JBoss console.
    I do see the persistence unit being initalized and bound prior to the below exception.
    Can you tell me where I could be going wrong? Can you please help?
    Thanks
    David

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Invocation of init method failed; nested exceptio
    n is javax.naming.NameNotFoundException: ties-2 not bound
    Here's my ds.xml entry
    Code:
    <datasources>
       
       <local-tx-datasource>
          <jndi-name>ties-2Datasource</jndi-name>
          <use-java-context>true</use-java-context>
          <connection-url>jdbc:oracle:thin:@mydb.mydomain.com:15333:icore</connection-url>
          <driver-class>oracle.jdbc.OracleDriver</driver-class>
          <user-name>ties</user-name>
          <password>tiesdev</password>
       </local-tx-datasource>
        
    </datasources>
    My persistence.xml

    Code:
       <persistence-unit name="ties-2">
          <provider>org.hibernate.ejb.HibernatePersistence</provider>
          <jta-data-source>java:/ties-2Datasource</jta-data-source>
          <!-- The <jar-file> element is necessary if you put the persistence.xml in the WAR and the classes in the JAR -->
    
          <properties>
             <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
    <!--         <property name="hibernate.hbm2ddl.auto" value="validate"/>-->
             <property name="hibernate.show_sql" value="true"/>
             <property name="hibernate.format_sql" value="true"/>
             <property name="jboss.entity.manager.factory.jndi.name" value="java:/ties-2EntityManagerFactory"/>
          </properties>
       </persistence-unit>
        
    </persistence>
    my applicationContext.xml entry
    Code:
    <jee:jndi-lookup id="entityManagerFactory" jndi-name="ties-2"/>

  • #2
    You register something with the (jndi)name ties-2EntityManagerFactory and expect the configuration to retrieve it with the ties-2 name... That is never going to happen (as your exception indicates)..

    Code:
    <property name="jboss.entity.manager.factory.jndi.name" value="java:/ties-2EntityManagerFactory"/>
    Code:
    <jee:jndi-lookup id="entityManagerFactory" jndi-name="ties-2"/>
    Last edited by Marten Deinum; Jan 11th, 2011, 02:18 AM. Reason: Added code, fixed typo.

    Comment

    Working...
    X