From users-return-10296-apmail-openjpa-users-archive=openjpa.apache.org@openjpa.apache.org Sat Sep 8 16:15:00 2012 Return-Path: X-Original-To: apmail-openjpa-users-archive@minotaur.apache.org Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 29618D238 for ; Sat, 8 Sep 2012 16:15:00 +0000 (UTC) Received: (qmail 82448 invoked by uid 500); 8 Sep 2012 16:15:00 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 82361 invoked by uid 500); 8 Sep 2012 16:14:59 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 82349 invoked by uid 99); 8 Sep 2012 16:14:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Sep 2012 16:14:58 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of maxtorzito@gmail.com designates 74.125.82.52 as permitted sender) Received: from [74.125.82.52] (HELO mail-wg0-f52.google.com) (74.125.82.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Sep 2012 16:14:50 +0000 Received: by wgbfg15 with SMTP id fg15so551579wgb.9 for ; Sat, 08 Sep 2012 09:14:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=33Hjbr7eo6Pr5JrfhnymF7t8RZOPgdrsKSKQ0hgYrM0=; b=OrIOtvamKG6IemuBAC/Pd/xvaIYGLHoufBaosc7X4Hwz5Q0oZa5qklu3uxyV/3i7gv N2g0ZgBCJ99LNsuwh7lwevXTNZnUKR07jowd4UehEA1GnItHQ6SSPEiGs90x/qXl5qlK FcKiVzg6eQD+WIlZQW8rctlHiD48Izt1X4suNpiTXSayjwUeQcyauBmD7roEKc6N4zrm yl75w2osheUmForCn1hXzjzE8vkOyT2S0TnR5MBxw5MssznrNyM7hNAFUeBlRpWiB8lI l6FE17b+rAezYj023Z1SCZ1jyDOszViPfxcqx4Gt+pNED4uRAL4qVZQ11BbouMH6hO1q eIGw== MIME-Version: 1.0 Received: by 10.216.93.6 with SMTP id k6mr5361480wef.86.1347120869728; Sat, 08 Sep 2012 09:14:29 -0700 (PDT) Received: by 10.194.14.102 with HTTP; Sat, 8 Sep 2012 09:14:29 -0700 (PDT) Received: by 10.194.14.102 with HTTP; Sat, 8 Sep 2012 09:14:29 -0700 (PDT) In-Reply-To: References: Date: Sat, 8 Sep 2012 11:14:29 -0500 Message-ID: Subject: Re: DelagatingResultList From: =?ISO-8859-1?Q?Jos=E9_Luis_Cetina?= To: users@openjpa.apache.org Content-Type: multipart/alternative; boundary=0016e6d78459e8e28204c933048c --0016e6d78459e8e28204c933048c Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I dont have an idea why. I did a workaround creating an arraylist with the content of getresultlist. Like this: List resultList =3D (List) em.createQuery(cq).getResultList(); //solution List mySecondList =3D new ArrayList(resultList); return mySecondList; El 04/09/2012 14:35, "Rick Curtis" escribi=F3: > Do you have any idea why javax.faces is trying to create an instance > of DelegatingResultList? > Maybe someone from one of the other mailing lists can help us out? > > [1] javax.faces.component.UIComponentBase.restoreAttachedState( > UIComponentBase.java:1842) > > On Thu, Aug 30, 2012 at 10:32 AM, Jos=E9 Luis Cetina >wrote: > > > Hi. I have a problem using myfaces 2.1.8 + openjpa 2.2.0 + primefaces > > 3.4-SNAPSHOT. > > > > I dont know if asked this in myfaces list or here, anyway, i hope > somebody > > can help me. > > > > I have 2 SelectOneMenu in a composite component(cc), this cc has a > > componentType in a facescomponent class. > > > > The first selectonemenu have a change event in the cc, when this event = is > > fired the second selectonemenu load data from the database. > > > > In the facescomponent class i use statehelper to save the state of the = 2 > > selectonemenu's, but i have a problem: > > > > This is the scenario: > > > > I have this in my database: > > > > Table country: > > id name > > 1 Spain > > 2 Mexico > > 3 USA > > > > Table cities: > > id fk name > > 1 3 New York > > 2 3 LA > > > > When my page load the country selectonemenu show all the countries > without > > problem (i retrive them using openjpa), in the cities selectonemenu's > show > > nothing because Spain doesnt have cities, well then if i select Mexico = my > > valuechangelistener method execute and load all the cities, but Mexico > > doesnt have nothing in the database then again nothing showed as > expected, > > then if a select USA the cities are retrived OK and they are shown in t= he > > cities selectonemenu although if i select another city like Spain i can > see > > this error (my valuechangelistener never get called again): > > > > java.lang.InstantiationException: > > org.apache.openjpa.kernel.DelegatingResultList > > java.lang.InstantiationException: > > org.apache.openjpa.kernel.DelegatingResultList at > > java.lang.Class.newInstance0(Class.java:357) at > > java.lang.Class.newInstance(Class.java:325) at > > > javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBas= e.java:1842) > > at > > > javax.faces.component._DeltaStateHelper.restoreState(_DeltaStateHelper.ja= va:616) > > at > > > javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:2= 021) > > at > > > org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.r= estoreStateFromMap(DefaultFaceletsStateManagementStrategy.java:661) > > at > > > org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.r= estoreStateFromMap(DefaultFaceletsStateManagementStrategy.java:680) > > at > > > org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.r= estoreStateFromMap(DefaultFaceletsStateManagementStrategy.java:680) > > at > > > org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.r= estoreStateFromMap(DefaultFaceletsStateManagementStrategy.java:680) > > at > > > org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.r= estoreView(DefaultFaceletsStateManagementStrategy.java:330) > > at > > > org.apache.myfaces.application.StateManagerImpl.restoreView(StateManagerI= mpl.java:130) > > at > > > org.apache.myfaces.shared.view.ViewDeclarationLanguageBase.restoreView(Vi= ewDeclarationLanguageBase.java:106) > > at > > > org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.restoreVi= ew(FaceletViewDeclarationLanguage.java:2109) > > at > > > org.apache.myfaces.application.ViewHandlerImpl.restoreView(ViewHandlerImp= l.java:300) > > at > > > com.ocpsoft.pretty.faces.application.PrettyViewHandler.restoreView(Pretty= ViewHandler.java:109) > > at > > > org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.WindowConte= xtAwareViewHandler.restoreView(WindowContextAwareViewHandler.java:122) > > at > > > org.apache.myfaces.extensions.cdi.jsf.impl.CodiViewHandler.restoreView(Co= diViewHandler.java:99) > > at > > > javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper= .java:83) > > at > > > javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper= .java:83) > > at > > > org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecu= tor.java:127) > > at > > > org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.jav= a:170) > > at > > > org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117= ) > > at > > > org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleW= rapper.execute(CodiLifecycleWrapper.java:95) > > at > > javax.faces.webapp.FacesServlet.service(FacesServlet.java:197) at > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicat= ionFilterChain.java:305) > > at > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilte= rChain.java:210) > > at > > com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145) at > > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicat= ionFilterChain.java:243) > > at > > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilte= rChain.java:210) > > at > > > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve= .java:225) > > at > > > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve= .java:123) > > at > > org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45) > at > > > org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorB= ase.java:472) > > at > > > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:= 168) > > at > > > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:= 98) > > at > > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:92= 7) > > at > > > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.j= ava:118) > > at > > > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:40= 7) > > at > > > org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Pr= ocessor.java:1001) > > at > > > org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(Abst= ractProtocol.java:579) > > at > > > org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.ja= va:312) > > at > > > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java= :1110) > > at > > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.jav= a:603) > > at > > java.lang.Thread.run(Thread.java:722) > > > > > > I observe this: > > > > If you select countries that doesnt have cities no error is shown > > (something like moving from Spain to Mexico and viceversa), but when i > > select a country like USA that have cities the cities load ok, but if i > try > > to select another country like mexico then the valuechangelistener meth= od > > never get called again because the exception is thrown. > > > > I get the cities using this method: > > > > public List getCities(Country country) { > > > > CriteriaBuilder cb =3D em.getCriteriaBuilder(); > > CriteriaQuery cq =3D cb.createQuery(City.class); > > Root root =3D cq.from(City.class); > > cq.select(root); > > cq.where(cb.equal(root.get(City_.countryId).get(Country_.countryId= ), > > country.getCountryId())); > > List resultList =3D (List) > > em.createQuery(cq).getResultList(); > > return resultList; > > } > > > > I debug my example and i can see in the saveAttachedState method of > > UIComponentBase.java the list of cities is a type of DelagatingResultLi= st > > but i dont understand why, if im doing a cast when i use the > getResultList > > method, why openjpa encapsulate my object in a DelagatingResultList? > > > > Then the attachedObject from the saveAttachedState method arrives as > > DelagatingResultList and then it cant create an instance. > > > > What i did is return a manual arraylist something like this, and the > > exception never thrown. > > > > public List getCities(Country country) { > > ArrayList list =3D new ArrayList(2); > > list.add(new City("New York")); > > list.add(new City("LA")); > > return list; > > } > > > > Finally i dont know what or which is wrong, openjpa or myfaces, openjpa > > return a DelagatingResultList object and myfaces cant create an instanc= e > of > > that object. > > What can i do ? > > > > > > > > > > > > -- > > ------------------------------------------------------------------- > > *SCJA. Jos=E9 Luis Cetina* > > ------------------------------------------------------------------- > > > > > > -- > *Rick Curtis* > --0016e6d78459e8e28204c933048c--