Question

i'm working on a WebApp, written in Java running on TomEE. As persistence layer i'm using Hibernate. Persistence.xml is configured, The entityManager is instantiated by TomEE using @PersistenceContext(name = "persistentUnitJndi", unitName = "docTracingPU") in a @Stateless(name = "utenteFacade", mappedName = IUtente.MAPPED_NAME) EJB.

It seems to work fine, but all queries returns an empty result (empty list). The DB is PostrgeSQL, i tried 8.4 and also 9.2 but the result is always the same.

I put on the logging on the postrges (postgresql.conf) where i read only Could not receive data from client: Unknown winsock error 10061.

I tried switching off antivirus and/or firewall....nothing changes.

What to do?

EDIT:

I tried the same project on a Win8.1 machine. Here i get user lacks privilege or object not found

Was it helpful?

Solution

I found:

  • hibernate.cfg.xml is not neede
  • only persistence.xml and tomee.xml are required

I give you my example:

<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="docTracingPU" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>java:comp/env/jdbc/docTracing</jta-data-source>
    <non-jta-data-source>java:comp/env/jdbc/docTracing</non-jta-data-source>

    <class>com.emaborsa.doctracing.core.persistentobject.UtentePO</class>

    <properties>
        <property name="hibernate.hbm2ddl.auto" value="validate" />
         <property name="hibernate.transaction.flush_before_completion" value="true"/>
         <property name="hibernate.transaction.auto_close_session" value="true"/>
        <property name="hibernate.transaction.manager_lookup_class" value="org.apache.openejb.hibernate.TransactionManagerLookup" />
         <property name="hibernate.transaction.flush_before_completion" value="true"/>
         <property name="hibernate.transaction.auto_close_session" value="true"/>

        <!-- Print SQL to stdout. -->
        <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.format_sql" value="true" />
    </properties>
</persistence-unit>

 <?xml version="1.0" encoding="UTF-8"?> 
     <tomee> 
        <Resource  id="docTracingPU" type="DataSource">
           JdbcDriver org.postgresql.Driver
           JdbcUrl jdbc:postgresql://127.0.0.1:5432/myDb
           UserName ****
           Password ****
           JtaManaged false
          TestWhileIdle true
          InitialSize 5
          </Resource> 
        <Resource id="docTracingPU" type="DataSource">
           JdbcDriver org.postgresql.Driver
           JdbcUrl jdbc:postgresql://127.0.0.1:5432/myDb
           UserName *****
           Password *****
           JtaManaged true
          TestWhileIdle true
          InitialSize 5
     </Resource> 
 </tomee>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top