Note that there are some explanatory texts on larger screens.

plurals
  1. POSeam 2.2 with jboss 5 non ejb can't inject entityManager
    primarykey
    data
    text
    <p>ETA an explanation of what this is supposed to do. An employee has to keep track of 2 weeks worth of activities.</p> <p>Each week(tqiActivitySheetActionBean) contains 7 days (tqiDayActionBean).</p> <p>Each day contains tasks for that day(tqiTasks)</p> <p>Tasks are displayed one week at a time(so the employee can switch between this week and last week).</p> <p>What I did was use an enum to iterate over the week - creates a dataTable of tqiActivitySheetActionBeans and iterate over those in a nested dataTable.</p> <p>The employee needs to be able to add, delete and edit tasks for each day in place(in the dataTable). I wrapped the tqiTasks in the tqiDayActionBean to group them.</p> <p>I posted this over at the Seam website, but I'm not getting any bites, I've tried everything I know and some stuff I don't to get this working, but so far no joy. There's configuration information for Jboss 5 using EJB's, Jboss 4 without. I have an exploded WAR using Jboss 5 and Seam 2.2.0, and no EJB's. I cannot inject an entityManager into my action POJOs. I tried removing the persistence-unit-ref-name reference from web.xml, added and removed </p> <pre><code>&lt;transaction:entity-transaction /&gt; &lt;transaction:ejb-transaction /&gt; </code></pre> <p>tags from components.xml (with and without entity-manager="#{entityManager}") . The app won't load when I use either of these. Used the default values and hardcoded them one at a time. I still can't get this to work. I'm currently using this configuration:</p> <p>persistence.xml:</p> <pre><code>&lt;persistence-unit name="myEmployee" transaction-type="JTA"&gt; &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt; &lt;jta-data-source&gt;java:/myEmployeeDatasource&lt;/jta-data-source&gt; &lt;properties&gt; &lt;property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/&gt; &lt;property name="hibernate.hbm2ddl.auto" value="validate"/&gt; &lt;property name="hibernate.show_sql" value="true"/&gt; &lt;property name="hibernate.format_sql" value="true"/&gt; &lt;property name="hibernate.default_schema" value="MY_PROD"/&gt; &lt;!-- Only relevant if Seam is loading the persistence unit (Java SE bootstrap) --&gt; &lt;property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/&gt; &lt;!-- this binds emf to jndi under java namespace - but only for jboss prior to 5.0 - I shouldn't need this. --&gt; &lt;property name="jboss.entity.manager.factory.jndi.name" value="java:/EntityManagerFactories/myEmployee"/&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; </code></pre> <p>components.xml:</p> <pre><code>&lt;persistence:managed-persistence-context name="entityManager" persistence-unit-jndi-name="java:/EntityManagerFactories/myEmployee" auto-create="true"/&gt; </code></pre> <p>This deploys and starts correctly, but entityManager is still null. </p> <p>I have a bunch of EntityHome classes in the same package, these can use an entityManager with no problem. All the docs I've looked at state that I should be able to inject an entityManager, I've followed the configuration info from the Seam docs page, the Seam in Action book and the Seam wiki for JBoss 5 (<a href="http://code.google.com/p/seaminaction/wiki/DeployingToJBossAS5" rel="nofollow">Seam wiki</a>)</p> <p>I've set breakpoints in the ManagedPersistence class - where it looks like I have an entityManager right up to the time I want to use it, added @Transactional annotations to the class and method. Still nothing. I can get an EM using </p> <pre><code>(EntityManager)Component.getInstance("entityManager") </code></pre> <p>But then I have no transactional access to the underlying entityBean and end up with hibernate LazyInitializationExceptions. I've been using Seam for almost a year now and I have yet to get this to work. Up til now using the Component method has worked, but There must be something fundamentally wrong with our setup that I cannot get injection to work. I'd appreciate any help.</p> <p>ETA code for user classes.</p> <p>The entity class is TQITask. TQIDayActionBean class is supposed to handle the CRUD for a group of TQITasks for one day, TQIActivitySheetActionBean handles the TQIDayActionBeans for one week.</p> <p>entity bean:</p> <pre><code>@Entity @Table(name = "TQI_TASK") @Name("tqitask") public class TqiTask implements java.io.Serializable { static Logger log = Logger.getLogger(TqiTask.class); private Integer sysid; private TqiActivitySubtype tqiActivitySubtype; private TqiActivityType tqiActivityType; // ... more fields, getters and setters </code></pre> <p>dayActionBean(a days tasks):</p> <pre><code>@Name("tQIDayActionBean") @Transactional(TransactionPropagationType.REQUIRED) //this is latest attempt @Scope(ScopeType.CONVERSATION) public class TQIDayActionBean implements Serializable { static Logger log = Logger.getLogger(TQIDayActionBean.class); @In(required=true) EntityManager entityManager; //this doesn't work either @DataModel("tqiTasksForOneDay") @Out(required = false) private List&lt;TqiTask&gt; tqiTasksForOneDay; // .... more stuff // method that should get an entityManager /** * tasks are children of tqiActivitySheet, info we need is in tqiActivitySheetV, so use peopleSoftIdSelected and weekSelected.weekSysid * to get the tqiActivitySheet sysid needed to load the right tasks * TODO for now lets just get it straight from the db */ @SuppressWarnings("unchecked") @Begin(flushMode=FlushModeType.MANUAL) public void generateTasksForDayOfWeek() { log.debug("date to search for: " + this.tqiTaskDate); this.tqiTasksForOneDay = this.entityManager.createQuery("SELECT t from TqiTask t where t.workDate = ?1 AND t.activitySheetSysid = ?2 order by t.sysid") .setParameter(1, this.tqiTaskDate).setParameter(2, this.activitySheetSysid).getResultList(); } getter/setters etc ... </code></pre> <p>activitySheetActionBean(a week's dayActionBeans):</p> <pre><code>/** * handle the activity sheet weekly code generation here */ @Name("tqiActivitySheetActionBean") public class TQIActivitySheetActionBean implements Serializable{ static Logger log = Logger.getLogger(TQIActivitySheetActionBean.class); // tried it here first // @In // EntityManager entityManager; @Out(value="tqiDayActionBeansForTheWeek", required=false) List&lt;TQIDayActionBean&gt; tqiDayActionBeansForTheWeek; // List&lt;DaysOfTheWeek&gt; daysOfTheWeekEnum; private BigDecimal currentlySelectedWeekActivitySheetSysid; @PostConstruct public void init(){ log.debug("calling init"); this.tqiDayActionBeansForTheWeek = new ArrayList&lt;TQIDayActionBean&gt;(); this.updateDataWhenWeekChanges(); } getters/setters more stuff .... </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload