openejb-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@gmail.com>
Subject Re: tomee ejb annotation not injecting
Date Sat, 11 Aug 2012 02:03:59 GMT

On Aug 10, 2012, at 6:48 PM, Louis Bros wrote:

> @onyii5119
> 
> I've just tested this:
> 
> tomee.xml:
> <Resource id="My Test Datasource" type="DataSource">
>  JdbcDriver org.apache.derby.jdbc.EmbeddedDriver
>  JdbcUrl jdbc:derby:/opt/databases/test_db;create=true
>  JtaManaged true
> </Resource>
> 
> persistence.xml:
> <persistence-unit name="test" transaction-type="JTA">
> 	<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> 	<jta-data-source>My Test Datasource</jta-data-source>
> 	<exclude-unlisted-classes>false</exclude-unlisted-classes>
> 	<properties>
> 		<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
> 	</properties>
> </persistence-unit>
> 
> HelloEJB:
> @PersistenceContext(unitName = "test")
> private EntityManager em;
> 
> It's working for me.

Did you mean to say "It isn't working for me?" (I forget the "not" in sentences all the time)

If it isn't working, make sure you have annotated the EJB as well.  Something like


@Stateless
public class HelloEJB {
    @PersistenceContext(unitName = "test")
    private EntityManager em;
}

If the bean has been properly deployed you should see this in the log output:

INFO - Created Ejb(deployment-id=HelloEJB, ejb-name=HelloEJB, container=Default Stateless
Container)


-David


Mime
View raw message