users@glassfish.java.net

Re: Dependency Injection is not working

From: <glassfish_at_javadesktop.org>
Date: Mon, 01 Mar 2010 03:05:21 PST

But the injected values are null.

My persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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="example-ejbPU" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>jdbc/example</jta-data-source>
    <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
      <property name="hibernate.archive.autodetection" value="class"/>
      <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
      <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup"/>
      <property name="hibernate.hbm2ddl.auto" value="update"/>
    </properties>
  </persistence-unit>
</persistence>

I can get a working EntityManager by using this code:

this.emf = Persistence.createEntityManagerFactory("example-ejbPU");
this.em = this.emf.createEntityManager();

But this seems not to be Container-managed.
[Message sent by forum member 'homer86' (baltasar86_at_web.de)]

http://forums.java.net/jive/thread.jspa?messageID=389338