Note that there are some explanatory texts on larger screens.

plurals
  1. POProviding EntityManager by an @ConversationScoped method
    primarykey
    data
    text
    <p>I tried to run the simple JEE6 application generated by maven archetype groupId: org.fluttercode.knappsack , artifactID: jee6-sandbox-archetype in JBoss7. (went through this <a href="http://javathreads.de/2011/05/tutorial-mit-java-ee-6-unter-eclipse-helios-und-mit-maven-unterstuetzung-starten/" rel="nofollow">turial</a>, sorry, in German)</p> <p>However, when calling the welcome JSF, I get the following error message:</p> <pre><code>org.jboss.weld.exceptions.IllegalProductException: WELD-000053 Producers cannot declare passivating scope and return a non-serializable class: [method] @Produces @DataRepository @ConversationScoped public org.rap.jee6project.bean.DataRepositoryProducer.getEntityManager() org.jboss.weld.bean.AbstractProducerBean.checkReturnValue(AbstractProducerBean.java:264) org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:362) org.jboss.weld.context.AbstractContext.get(AbstractContext.java:122) </code></pre> <p>Indeed, the DataRepositoyProducer class which is supposed to return an EntityManager instance, is defined an annotated as follws:</p> <pre><code>@Stateless public class DataRepositoryProducer { private EntityManager entityManager; @Produces @DataRepository @ConversationScoped public EntityManager getEntityManager() { return entityManager; } @PersistenceContext public void setEntityManager(EntityManager entityManager) { this.entityManager = entityManager; } } </code></pre> <p>If I use @RequestScoped, the application runs as promised. I wonder why other people who went through this tutorial didn't experience this problem? And how to fix it properly (using @RequestScoped means that the bean is recreated for each user request, right?, which I expect to be not very efficient) </p> <p>The official JEE6 Tutorial says: "<em>Beans that use session, application, or conversation scope must be serializable, but beans that use request scope do not have to be serializable</em>" . However, that does not seem to be the problem here, since the server is not comlaining about the bean not serializable but the product of the producer bean.</p>
    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