Not illegal, just worthless.<br><br><br><div class="gmail_quote">On Wed, Apr 18, 2012 at 5:34 PM, Jason Porter <span dir="ltr">&lt;<a href="mailto:lightguard.jp@gmail.com">lightguard.jp@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

No, the problem is, as it exists today, this is not legal. You&#39;ll actually get a transaction scoped EM, which causes all sorts of confusion because there&#39;s also no transactions going on so your EM is actually closed the first time it&#39;s used. No warning, no exception just head smashing.<br>


<br>
Sent from my iPhone<br>
<div class="HOEnZb"><div class="h5"><br>
On Apr 18, 2012, at 9:30, &quot;Lincoln Baxter, III&quot; &lt;<a href="mailto:lbaxter@redhat.com">lbaxter@redhat.com</a>&gt; wrote:<br>
<br>
&gt; I&#39;m guessing the problem lies in the fact that the bean doing the<br>
&gt; producing is not itself scoped?<br>
&gt;<br>
&gt; On Wed 18 Apr 2012 11:25:06 AM EDT, Adam Bien wrote:<br>
&gt;&gt; The code above should work for Java EE 7 and CDI 1.1.<br>
&gt;&gt; The @RequestScoped @Produces below is not that reasonable, but @SessionScoped should work in CDI 1.1.<br>
&gt;&gt;<br>
&gt;&gt; On 18.04.2012, at 00:37, Jason Porter wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; I don&#39;t know where this should fail, but it needs to fail somewhere, and if CDI isn&#39;t it, I trust there are people on this list the other EGs will listen to because too many of them ignore the users list, because you know, they&#39;re the &quot;experts&quot;.<br>


&gt;&gt;&gt;<br>
&gt;&gt;&gt; public class EmProducer() {<br>
&gt;&gt;&gt;     @PersistenceContext(type = PersistenceContextType.EXTENDED)<br>
&gt;&gt;&gt;     EntityManager em;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;     @Produces @RequestScoped<br>
&gt;&gt;&gt;     public EntityManager getEntityManager() {<br>
&gt;&gt;&gt;         return em;<br>
&gt;&gt;&gt;     }<br>
&gt;&gt;&gt; }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; That should be a deployment exception stating it isn&#39;t valid (the @PersistenceContext injection).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; --<br>
&gt;&gt;&gt; Jason Porter<br>
&gt;&gt;&gt; <a href="http://lightguard-jp.blogspot.com" target="_blank">http://lightguard-jp.blogspot.com</a><br>
&gt;&gt;&gt; <a href="http://twitter.com/lightguardjp" target="_blank">http://twitter.com/lightguardjp</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Software Engineer<br>
&gt;&gt;&gt; Open Source Advocate<br>
&gt;&gt;&gt; Author of Seam Catch - Next Generation Java Exception Handling<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; PGP key id: 926CCFF5<br>
&gt;&gt;&gt; PGP key available at: <a href="http://keyserver.net" target="_blank">keyserver.net</a>, <a href="http://pgp.mit.edu" target="_blank">pgp.mit.edu</a><br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; cdi-dev mailing list<br>
&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;<br>
&gt; --<br>
&gt; ---<br>
&gt; Lincoln Baxter, III<br>
&gt; <a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>
&gt; &quot;Simpler is better.&quot;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; cdi-dev mailing list<br>
&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
<br>
_______________________________________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.suntriprecords.com">http://www.suntriprecords.com</a><br><br>