-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate and glassfish again.
PostPosted: Wed Jun 10, 2009 7:33 am 
Newbie

Joined: Wed Jun 10, 2009 7:13 am
Posts: 1
I am trying use a hibernate as jpa provider in enterprise project on glassfish. I copied this libs into glassfish_home/libs:
antlr-2.7.6.jar
asm-attrs.jar
asm.jar
cglib.jar
commons-collections-3.1.jar
commons-collections.jar
commons-logging.jar
concurrent.jar
dom4j-1.6.1.jar
dom4j.jar
ehcache.jar
ejb3-persistence.jar
hibernate3.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate-core.jar
hibernate-entitymanager.jar
hibernate.jar
hibernate-search.jar
hibernate-validator.jar
javassist-3.4.GA.jar
javassist.jar
jta-1.1.jar
jta.jar
log4j.jar
lucene-core.jar
slf4j-api-1.5.2.jar
slf4j-api.jar

My persistence.xml :
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for dev profile -->
<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="repo" transaction-type="JTA">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source >jdbc/repoPool</jta-data-source>
      <properties>
         <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
         <property name="hibernate.hbm2ddl.auto" value="auto"/>
         <property name="hibernate.show_sql" value="true"/>
         <property name="hibernate.format_sql" value="true"/>
      </properties>
   </persistence-unit>
   
</persistence>


When i deploy project, a new or updated tables are being created in database. But when i try to execute query entity manager is null;
Code:
....
@PersistenceContext(unitName = "repo")   
private EntityManager em;
....
public List<User> getAll() {
               List<User> result = new LinkedList<User>();
      try {
         String q = "select u from User u";         
         Query query = em.createQuery(q); //!!!!!! throws exception here; em is null
         result = query.getResultList();      
       } catch (NoResultException nre) {
         nre.printStackTrace();
      } catch (RuntimeException re) {
         re.printStackTrace();
      }
                return result;
}


What i am doing wrong?


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

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.