2 Replies Latest reply on Aug 28, 2007 3:45 PM by asaf sh

    SeamGen+EntityQuery - 'argument type mismatch'

    asaf sh Expert

      Hey,

      I have a simple entityList class inherited from EntityQuery,

      Everything seems to work fine with pagination, search ,etc... as seamGen generates this just fine,


      but I can't seems to find a way to add a search parameter that is an entity and not a primitive datatype,


      so here's an example..
      lets assume I have a list of person where each person entity has a reference to an 'address' entity.

      public class PersonList extends EntityQuery {
      private static final String[] RESTRICTIONS = {
      "person.address = #{personList.person.address}"};
      
      private Person = new Person();
      
      ...getting of Person...
      ...etc...
      




      In my personList.xhtml I have a default datatable that iterates over the resultList of the 'personList', etc...

      and a search parameter as:
      <h:selectOneMenu id="address" value="#{personList.person.address}" required="false">
      <s:selectItems value="#{allAddresses}" var="r" label="#{r.displayName}"
      <s:convertEntity />
      </h:selectOneMenu>
      


      (where 'allAddresses' is a resultList of another entityQuery)


      last thing is the parameters, I've added the following parameter to the page descriptor:
      <param name="address" value="#{personList.person.address}"/>
      




      Submitting the form results an 'IllegalArgumentException - argument type mismatch'


      Am I doing something wrong?



      Following is the full stacktrace;

      17:49:57,671 ERROR [SeamPhaseListener] uncaught exception
      javax.el.ELException: java.lang.IllegalArgumentException: argument type mismatch
       at javax.el.BeanELResolver.setValue(BeanELResolver.java:116)
       at javax.el.CompositeELResolver.setValue(CompositeELResolver.java:68)
       at com.sun.faces.el.FacesCompositeELResolver.setValue(FacesCompositeELResolver.java:93)
       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 org.jboss.seam.core.Expressions$1.setValue(Expressions.java:117)
       at org.jboss.seam.navigation.Pages.applyConvertedValidatedValuesToModel(Pages.java:753)
       at org.jboss.seam.navigation.Pages.postRestore(Pages.java:392)
       at org.jboss.seam.jsf.SeamPhaseListener.postRestorePage(SeamPhaseListener.java:527)
       at org.jboss.seam.jsf.SeamPhaseListener.afterRestoreView(SeamPhaseListener.java:374)
       at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:211)
       at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:184)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)
       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.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:82)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:293)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
       at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:149)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:82)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
       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:60)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
       at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:68)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:149)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.IllegalArgumentException: argument type mismatch
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at javax.el.BeanELResolver.setValue(BeanELResolver.java:108)
      





      thanks a lot,

      Asaf.


        • 1. Re: SeamGen+EntityQuery - 'argument type mismatch'
          asaf sh Expert

          Another test of the same thing resulted a 'classCastException',
          almost same seam stacktrace, but here are the important lines again:


           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Thread.java:619)
          Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@19de347
           at sun.reflect.GeneratedMethodAccessor558.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at javax.el.BeanELResolver.setValue(BeanELResolver.java:108)
          


          • 2. Re: SeamGen+EntityQuery - 'argument type mismatch'
            asaf sh Expert

            Well,

            I actually tried almost anything possible that is elegant enough,


            I also tried to a add the referenced entity as a property for the EntityQuery but nothing,


            Address address;
            
            getter/setter
            


            and in the view I have added an EntityConverter for this address via a SelectOneMenu/selectItems, then I get a EntityManager is closed exception,



            I think the problem is due to the fact that the generated EntityQuery via Seam-Gen is not bound to any conv/session contexts, and keeping the search parameters/values is done via parameters specified within the page descriptor.


            This is -too- basic, I am definitely sure there's a way to add restrictions based on -entities- associated to the main entity that being fetched except of criteria based on primitive datatypes !


            anyone? :)

            Asaf.