[jboss-user] [JBoss Seam] - Re-working EJB Extended Context To Use SMPC - Need Help

curtney do-not-reply at jboss.com
Sat Oct 6 14:18:48 EDT 2007


I have a read number of posts that indicates it is possible to have the following architecture listed below, however, putting @Name on the abstract class throws an IllegalArgumentException. If I remove @Name annotation from the abstract class, then my entityManager is null; it does not get injected.

@Name("genericdao");
  | public abstract MyBase <T, ID extends Serializable> implements mybaseInterface <T, ID> {
  | 
  | @In 
  | protected EntityManager entityManager;
  | }
  | 
  | 
  | @Stateless
  | @TransactionAttribute (TransactionAttributeType.REQUIRED)
  | @Name ("bean1")
  | public class Bean1 extends MyBase <Entity, ID> implements Bean1Interface {
  | 
  | //do some dao acess here
  | }
  | 
  | @Stateful
  | @Name ("bean2")
  | public class Bean2 implements Bean2Interface {
  | 
  | //I have commented this in and out, does not make a difference.
  | @In private EntityManager entityManager;
  | 
  | @In
  | Bean1 bean1
  | 
  | //use bean1 to do dao stuff, persist, remove, refresh, etc.
  | 
  | }

component.xml has the following:
<persistence:managed-persistence-context name="entityManager" auto-create="true"
  |       persistence-unit-jndi-name="java:/myEntityManagerFactory"/>

persistence.xml has the following:
....
  | <persistence-unit name="myDatabase">
  |   <provider>org.hibernate.ejb.HibernatePersistence</provider>
  |   <jta-data-source>java:/DefaultDS</jta-data-source>
  |   <jar-file>../my-common.jar</jar-file>
  |  <jar-file>../my-party.jar</jar-file>
  |   <jar-file>../my-security.jar</jar-file>
  |    ......
  |   <properties>
  |    .....
  |    <property name="jboss.entity.manager.factory.jndi.name" value="java:/myEntityManagerFactory"/>
  | ....
  | </persistence-unit>
  | ....
I am trying to re-work my EJB style extended persistence context to use SMPC. Where
 I had  @PersistenceContext to inject entityManager and @EJB to inject the beans. However swithching to @In to inject entityManager and my beans does not work.

Please help, I have being reading old posts all knight long, and unable to get this to work. I am sure I am missing something obvious.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4092277#4092277

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4092277



More information about the jboss-user mailing list