Thank you for your feedback Richard.<div><br></div><div>I tried your proposal and it breaks something else because the annotated class is used everywhere to convert the POJO, and on the log I can find this line:</div><div>

<br></div><div><div>10:45:46,485 INFO  [javax.enterprise.resource.webcontainer.jsf.renderkit] (http--127.0.0.1-8080-2) WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.</div><div>sourceId=create:accountBeanAccountGroupsSelect[severity=(ERROR 2), summary=(create:accountBeanAccountGroupsSelect: Validation Error: Value is not valid), detail=(create:accountBeanAccountGroupsSelect: Validation Error: Value is not valid)]</div>

</div><div><br></div><div>Regarding the solution I proposed, I agree that generated code must be simple, but I really can&#39;t figure another way to inject an extended persistence context inside a client object.</div><div>

<br></div><div>In case we factor out the converter and write an util class with a factory that hide that complexity.</div><div><br></div><div>What do you think ?</div><div><br></div><div><br><br><div class="gmail_quote">
2012/8/6 Richard Kennard <span dir="ltr">&lt;<a href="mailto:richard@kennardconsulting.com" target="_blank">richard@kennardconsulting.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Luca,<br>
<br>
Thanks for your time and help debugging this. I think we need to proceed with caution.<br>
<br>
We&#39;re basically talking about hacks to work around bugs in the app server/shortcomings in the EE spec. The problem is these hacks are going to get<br>
re-generated for every domain entity (potentially dozens of times). It&#39;s critical we try to keep our generated code as clean as possible. In particular, we<br>
must keep the &#39;semantic complexity&#39; low.<br>
<br>
The solution you&#39;re suggesting (injecting a SessionContext, taking EJBObject using getBusinessInterface etc) sounds like a lot of &#39;semantic complexity&#39; for<br>
new users to understand?<br>
<br>
It&#39;s really important we try to find the cleanest approach. We tried/rejected a lot of variations when developing the current code. Here&#39;s one that&#39;s not<br>
quite as nice as the current one, but may work properly across TomEE/Weblogic/JBoss. Could you try it for me?<br>
<br>
1. Remove all references in the generated Facelets code to: converter=&quot;#{foo.converter}&quot;<br>
2. Remove the &#39;getConverter()&#39; method inside each xxxBean and replace with a static inner class that looks like:<br>
<br>
     @FacesConverter( forClass = xxx.class )<br>
     public static class xxxConverter<br>
         implements Converter {<br>
<br>
         @Override<br>
         public Object getAsObject( FacesContext context, UIComponent component, String value ) {<br>
<br>
             // EntityManager injection not reliable on all platforms<br>
<br>
             xxx entity = new xxx();<br>
             entity.setId( Long.valueOf( value ) );<br>
             return entity;<br>
         }<br>
<br>
         @Override<br>
         public String getAsString( FacesContext context, UIComponent component, Object value ) {<br>
<br>
             ...<br>
         }<br>
     }<br>
<br>
Here&#39;s a complete example:<br>
<br>
<a href="https://github.com/metawidget/metawidget/blob/master/integration-tests/faces/forge/src/main/java/com/test/view/PersonBean.java" target="_blank">https://github.com/metawidget/metawidget/blob/master/integration-tests/faces/forge/src/main/java/com/test/view/PersonBean.java</a><br>


<br>
Regards,<br>
<br>
Richard.<br>
<div><div class="h5"><br>
On 3/08/2012 9:17 PM, Luca Masini wrote:<br>
&gt; The fact is that we have an extended persistente unit bound to the stateful ejb, so can&#39;t be injected or looked up.<br>
&gt;<br>
&gt; I&#39;ve found a solution working on my three target App Server (TomEE, Weblogic, JBoss).<br>
&gt;<br>
&gt; Inject a SessionContext and take the EJBObject using the getBusinessInterface method.<br>
&gt;<br>
&gt; For some strange reason SessionContext and his Ejb have different lifecycle so we need to take it before it is returned to the jsf client.<br>
&gt;<br>
&gt; This way it works.<br>
&gt;<br>
&gt; Il giorno venerdė 3 agosto 2012, Richard Kennard ha scritto:<br>
&gt;<br>
&gt;     Yes, you could try that. The history to this decision was:<br>
&gt;<br>
&gt;     1. The Converter needs to use an EntityManager to load the entity<br>
&gt;     2. For some reason you cannot (yet) inject EntityManagers into FacesConverters<br>
&gt;<br>
&gt;     So I made the Converter an inner class of the xxxBean, so that it could access the bean&#39;s EntityManager. However there would be other approaches, such as<br>
&gt;     looking up the EntityManager via JNDI or something.<br>
&gt;<br>
&gt;     Regards,<br>
&gt;<br>
&gt;     Richard.<br>
&gt;<br>
&gt;     On 3/08/2012 8:15 PM, Thomas Frühbeck wrote:<br>
&gt;     &gt; Did you think of separating Converter and backing bean implementation?<br>
&gt;     &gt; AFAIK the backing bean _provides_ a converter e.g.: #{xxxxxBean.converter} but should not implement Converter itself?<br>
&gt;     &gt;<br>
&gt;     &gt; Thomas<br>
&gt;     &gt;<br>
&gt;     &gt; Am 03.08.2012 11:13, schrieb Luca Masini:<br>
&gt;     &gt;&gt; I&#39;m going crazy to let the generated faces scaffolding run on both WLS and JBoss.<br>
&gt;     &gt;&gt;<br>
&gt;     &gt;&gt; Infact if I let the Bean implements the Converter interface then WLS works but JBoss complaints about missing method, it&#39;s like that the implemented<br>
&gt;     &gt;&gt; interface is the Local interface for the bean and no other method is found but those in the Converter interface itself.<br>
&gt;     &gt;&gt;<br>
&gt;     &gt;&gt; So I remove the interface and everything work without the getConverter method, getAsObject and getAsString are method of the now interface bean.<br>
&gt;     &gt;&gt;<br>
&gt;     &gt;&gt; On the counter side WLS is unable to call methods from the EL into faces files that are not part of the Converter interface.<br>
&gt;     &gt;&gt;<br>
&gt;     &gt;&gt; So I&#39;m in a deadlock. I&#39;m unable to let it works on both the Java EE 6 server. I&#39;m sure that a solution exist, but whichi ?<br>
&gt;     &gt;&gt;<br>
&gt;     &gt;&gt; --<br>
&gt;     &gt;&gt; ****************************************<br>
&gt;     &gt;&gt; <a href="http://www.lucamasini.net" target="_blank">http://www.lucamasini.net</a><br>
&gt;     &gt;&gt; <a href="http://twitter.com/lmasini" target="_blank">http://twitter.com/lmasini</a><br>
&gt;     &gt;&gt; <a href="http://www.linkedin.com/pub/luca-masini/7/10/2b9" target="_blank">http://www.linkedin.com/pub/luca-masini/7/10/2b9</a><br>
&gt;     &gt;&gt; ****************************************<br>
&gt;     &gt;&gt;<br>
&gt;     &gt;&gt;<br>
&gt;     &gt;&gt; _______________________________________________<br>
&gt;     &gt;&gt; forge-dev mailing list<br>
</div></div>&gt;     &gt;&gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a> &lt;javascript:;&gt;<br>
<div class="im">&gt;     &gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt; _______________________________________________<br>
&gt;     &gt; forge-dev mailing list<br>
</div>&gt;     &gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a> &lt;javascript:;&gt;<br>
<div class="im">&gt;     &gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;<br>
&gt;     _______________________________________________<br>
&gt;     forge-dev mailing list<br>
</div>&gt;     <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a> &lt;javascript:;&gt;<br>
<div class="im HOEnZb">&gt;     <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; ****************************************<br>
&gt; <a href="http://www.lucamasini.net" target="_blank">http://www.lucamasini.net</a><br>
&gt; <a href="http://twitter.com/lmasini" target="_blank">http://twitter.com/lmasini</a><br>
&gt; <a href="http://www.linkedin.com/pub/luca-masini/7/10/2b9" target="_blank">http://www.linkedin.com/pub/luca-masini/7/10/2b9</a><br>
&gt; ****************************************<br>
&gt;<br>
&gt;<br>
</div><div class="HOEnZb"><div class="h5">&gt; _______________________________________________<br>
&gt; forge-dev mailing list<br>
&gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
<br>
_______________________________________________<br>
forge-dev mailing list<br>
<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>****************************************<br><a href="http://www.lucamasini.net">http://www.lucamasini.net</a><br><a href="http://twitter.com/lmasini">http://twitter.com/lmasini</a><br>

<a href="http://www.linkedin.com/pub/luca-masini/7/10/2b9">http://www.linkedin.com/pub/luca-masini/7/10/2b9</a><br>****************************************<br>
</div>