1 2 Previous Next 18 Replies Latest reply on Jul 3, 2007 12:57 PM by asaf sh

    ConvertEntity Seam 2.0 issue

    asaf sh Expert

      Hey,
      Trying to migrate to Seam 2, I've encountered an issue related to the EntityConverter when a JSF component binded to an EJB (that is a seam component) property,

      I have an EJB like:

      @Name("myManager")
      @Interceptors( { org.jboss.seam.ejb.SeamInterceptor.class })
      public class MyManager implements MyManagerLocal {
      private MyEntity myEntity;
      ...
      Accessors for myEntity
      }
      



      And facelets code that looks like:
      <h:selectOneMenu id="sb" value="#{myManager.myEntity}" required="true" >
      <s:selectItems value="#{myEntities}" var="me" label="#{me.displayName}"/>
      <ec:convertEntity/>
      </h:selectOneMenu>
      



      - myEntities is just a query defined in the components.xml file.

      Note that when using convertEntity tag that is binded to a regular POJO it works perfectly, this problem only occurs when I bind a JSF tag (such as the selectOneMenu to an EJB seam component property.

      It worked fine with seam 1.2.x,



      Thanks.

        • 1. Re: ConvertEntity Seam 2.0 issue
          Pete Muir Master

          And the issue is...

          It looks like you are still using an old version of the entity converter - try s:convertEntity, it's much better :)

          • 2. Re: ConvertEntity Seam 2.0 issue
            asaf sh Expert

            Eh, I know, I tracked the changes, not sure if it'll help in my case, but it looks better,

            The problem is that it does not work for me, I use Toplink as JPA and when I use s:convertEntity I get:

            Caused by: java.lang.ClassCastException: oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl cannot be cast to org.hibernate.Session

            I understand that there should be a Seam PersistenceProvider for Toplink in order to make it work but I have no clue how to write one,

            Is it documented? ec:convertEntity works because I modified the code by myself.


            Thanks :)

            Asaf.

            • 3. Re: ConvertEntity Seam 2.0 issue
              Pete Muir Master

              Can you post the whole stack trace for that?

              • 4. Re: ConvertEntity Seam 2.0 issue
                asaf sh Expert

                There you go!

                [#|2007-07-03T15:46:20.187+0300|SEVERE|sun-appserver9.1|facelets.viewhandler|_ThreadID=19;_ThreadName=httpSSLWorkerThread-8181-1;_RequestID=82601fb7-5e30-445d-a507-293f0fb20b53;|Error Rendering View[/targetSystemEdit.xhtml]
                java.lang.RuntimeException: could not proxy delegate
                 at org.jboss.seam.persistence.HibernatePersistenceProvider.proxyDelegate(HibernatePersistenceProvider.java:95)
                 at org.jboss.seam.persistence.EntityManagerProxy.getDelegate(EntityManagerProxy.java:95)
                 at org.jboss.seam.persistence.HibernatePersistenceProvider.getSession(HibernatePersistenceProvider.java:157)
                 at org.jboss.seam.persistence.HibernatePersistenceProvider.getId(HibernatePersistenceProvider.java:114)
                 at org.jboss.seam.framework.EntityIdentifier.<init>(EntityIdentifier.java:15)
                 at org.jboss.seam.ui.converter.EntityConverterStore.put(EntityConverterStore.java:60)
                 at org.jboss.seam.ui.converter.EntityConverter.getAsString(EntityConverter.java:69)
                 at org.jboss.seam.ui.converter.PrioritizableConverter.getAsString(PrioritizableConverter.java:67)
                 at org.jboss.seam.ui.converter.ConverterChain.getAsString(ConverterChain.java:123)
                 at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getFormattedValue(HtmlBasicRenderer.java:469)
                 at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOption(MenuRenderer.java:502)
                 at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:757)
                 at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:811)
                 at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:335)
                 at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:833)
                 at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:190)
                 at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
                 at org.jboss.seam.ui.renderkit.ValidateAllRendererBase.doEncodeChildren(ValidateAllRendererBase.java:33)
                 at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
                 at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
                 at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
                 at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
                 at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:571)
                 at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
                 at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
                 at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
                 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                 at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                 at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:398)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                 at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:87)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:63)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:46)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
                 at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
                 at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:40)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:63)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:140)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:217)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)
                 at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:217)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
                 at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:258)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:189)
                 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
                 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
                 at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:81)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:193)
                 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
                 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
                 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:558)
                 at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1067)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
                 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
                 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
                 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:558)
                 at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1067)
                 at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:255)
                 at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:618)
                 at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:549)
                 at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:790)
                 at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:326)
                 at com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.process(SSLReadTask.java:427)
                 at com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.doTask(SSLReadTask.java:215)
                 at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
                 at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:93)
                Caused by: java.lang.ClassCastException: oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl cannot be cast to org.hibernate.Session
                 at org.jboss.seam.persistence.HibernatePersistenceProvider.proxyDelegate(HibernatePersistenceProvider.java:91)
                 ... 78 more
                |#]
                



                Thanks!

                • 5. Re: ConvertEntity Seam 2.0 issue
                  Pete Muir Master

                  Ok, so you've got hibernate somewhere in the classpath of your app (at runtime) right? Remove it, and you'll drop down to the generic (JPA) PeristenceProvider, which isn't as good (it can only deal with entities which are mapped using JPA annotations) but works just fine otherwise.

                  If you want to write a ToplinkPersistenceProvider (it would be cool to have something like this in the wiki), all you need to do is copy the annotations on HibernatePersistenceProvider (replacing the classDependency with one for the toplink equivalent), and just override those methods from PersistenceProvider which can be better implemented with the underlying EntityManager from Toplink than just the JPA one.

                  • 6. Re: ConvertEntity Seam 2.0 issue
                    asaf sh Expert

                    Hey,

                    I can't remove the hibernate, I wont have support for Hibernate validation annotations... right?

                    Regarding the TopLinkPersistenceProvider, I'll try,

                    There is already a post about that which I started here:
                    http://www.jboss.com/index.html?module=bb&op=viewtopic&t=110319

                    I'll keep the results/problems in that post,


                    Asaf.

                    • 7. Re: ConvertEntity Seam 2.0 issue
                      Pete Muir Master

                      I belive that since Emmanuel split Hibernate Validator out of Hibernate annotations you don't need to run the rest of hibernate to get the validator working (it should work with any JPA impl).

                      http://www.hibernate.org/hib_docs/validator/reference/en/html/validator-checkconstraints.html

                      • 8. Re: ConvertEntity Seam 2.0 issue
                        asaf sh Expert

                        So actually I should remove the hibernate-all from my app's libs and ?

                        Is there a separated jar file for the validators annotations? out of hibernate-all.jar?


                        Thanks.

                        • 9. Re: ConvertEntity Seam 2.0 issue
                          Pete Muir Master

                          Yes, check the hibernate website :)

                          • 10. Re: ConvertEntity Seam 2.0 issue
                            asaf sh Expert

                            Tried,

                            I think that Toplink doesn't live so well with Hibernate libraries aside,
                            I assume Seam makes some usages of Hibernate if it exists automatically,

                            I removed Hibernate-all.jar file from my library and suddenly many problems I had disappeared, so most of the things started to work (including the s:convertEntity tag) and also Seam validators work,

                            Well, I currently get a NoClassDefFoundError, so I assume some more classes are needed in order to work with Seam without Hibernate,


                            following:

                            
                            [#|2007-07-03T17:45:33.718+0300|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=20;_ThreadName=httpSSLWorkerThread-8181-0;_RequestID=edbee662-e430-43ac-b5d3-49f7fd98cf55;|StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
                            java.lang.NoClassDefFoundError: org/hibernate/MappingException
                             at org.jboss.seam.core.Validators.createValidator(Validators.java:100)
                             at org.jboss.seam.core.Validators.getValidator(Validators.java:84)
                             at org.jboss.seam.core.Validators$ValidatingResolver.setValue(Validators.java:177)
                             at org.jboss.el.parser.AstPropertySuffix.setValue(AstPropertySuffix.java:73)
                             at org.jboss.el.parser.AstValue.setValue(AstValue.java:84)
                             at org.jboss.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:249)
                             at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:93)
                             at org.jboss.seam.core.Validators.validate(Validators.java:118)
                             at org.jboss.seam.ui.validator.ModelValidator.validate(ModelValidator.java:35)
                             at javax.faces.component.UIInput.validateValue(UIInput.java:1013)
                             at javax.faces.component.UIInput.validate(UIInput.java:867)
                             at javax.faces.component.UIInput.executeValidate(UIInput.java:1065)
                             at javax.faces.component.UIInput.processValidators(UIInput.java:666)
                             at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)
                             at javax.faces.component.UIForm.processValidators(UIForm.java:229)
                             at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)
                             at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:662)
                             at org.ajax4jsf.framework.ajax.AjaxViewRoot.access$201(AjaxViewRoot.java:53)
                             at org.ajax4jsf.framework.ajax.AjaxViewRoot$3.invokeRoot(AjaxViewRoot.java:315)
                             at org.ajax4jsf.framework.ajax.JsfOneOneInvoker.invokeOnRegionOrRoot(JsfOneOneInvoker.java:53)
                             at org.ajax4jsf.framework.ajax.AjaxContext.invokeOnRegionOrRoot(AjaxContext.java:191)
                             at org.ajax4jsf.framework.ajax.AjaxViewRoot.processValidators(AjaxViewRoot.java:329)
                             at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:100)
                             at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                             at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
                             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
                             at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:398)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                             at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:87)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:63)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:46)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
                             at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
                             at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:40)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:140)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:217)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)
                             at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:217)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)
                             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
                             at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:258)
                             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:189)
                             at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
                             at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
                             at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:81)
                             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:193)
                             at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
                             at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
                             at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:558)
                             at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1067)
                             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
                             at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
                             at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
                             at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:558)
                             at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1067)
                             at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:255)
                             at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:618)
                             at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:549)
                             at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:790)
                             at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:326)
                             at com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.process(SSLReadTask.java:427)
                             at com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.doTask(SSLReadTask.java:215)
                             at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
                             at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:93)
                            |#]
                            


                            Thanks.



                            • 11. Re: ConvertEntity Seam 2.0 issue
                              Pete Muir Master

                              Looks like this is fixed with CVS (please try it)

                              • 12. Re: ConvertEntity Seam 2.0 issue
                                asaf sh Expert

                                Nah,

                                It doesn't work, same error, and there are other missing classes, such as HibernateException, NestableRuntimeException and more.


                                Should I report for the missing classes (mostly available within the Hibernate code package) ?

                                Asaf.

                                • 13. Re: ConvertEntity Seam 2.0 issue
                                  Pete Muir Master

                                  Ah, maybe you do need hibernate core in your cp looking at it more carefully. Sorry. So, you can try the other option I suggested I think.

                                  • 14. Re: ConvertEntity Seam 2.0 issue
                                    asaf sh Expert

                                    Yap looks like Seam depends on many Hibernate's core classes,


                                    I'll start writing the TopLinkPersistenceProvider and post the results/errors,
                                    one question about that,

                                    How do I tell Seam that it exists? I should add the provider to the classpath and?

                                    1 2 Previous Next