Re: CODI ViewAccessScoped issue with EAR on JBoss 7.1.x
hi adrian, we can do EXTCDI-308 easily, but basically it isn't an issue of codi - please file an issue for WAS8. regards, gerhard http://www.irian.at Your JSF/JavaEE powerhouse - JavaEE Consulting, Development and Courses in English and German Professional Support for Apache MyFaces 2013/4/3 Adrian Gonzalez adr_gonza...@yahoo.fr Just created : * https://issues.apache.org/jira/browse/EXTCDI-307 (EAR support for JBoss) * https://issues.apache.org/jira/browse/EXTCDI-308 (EAR support for WAS) and attached the corresponding patches. Please note that these patches doesn't cover support for all the CODI modules (I've tested EAR support only for the JSF module). Regards, Adrian - Mail original - De : Adrian Gonzalez adr_gonza...@yahoo.fr À : MyFaces Discussion users@myfaces.apache.org Cc : Envoyé le : Mercredi 3 avril 2013 11h52 Objet : Re: CODI ViewAccessScoped issue with EAR on JBoss 7.1.x Hello, I just resolved java.lang.NullPointerException: null on Websphere (8.0.0.4) (see [2] below). This issue was due : When a client calls a method with package level access on a CDI bean, WAS 8.0.0.4 doesn't execute the interceptor chain. The call is executed directly on the javassist class (and @Inject fields are null in the javassist class - so we get the NPE). For now, just setting method visibility to public on both JsfRequestLifecycleBroadcaster#broadcastBeforeEvent et JsfRequestLifecycleBroadcaster#broadcastAfterEvent resolves this issue. Question is : bug located in Websphere or in CODI ? In other workds, does CDI 1.0 supports calling methods with package level access ? I looked at the CDI spec, but didn't find anything on this matter. Interceptor spec 1.1 supports it (from chapter Method interceptors : 'Around-invoke methods can have public, private, protected, or package level access. An around-invoke method must not be declared as final or static.') If it's in WAS, I can open a PMR for this. I will open 2 tickets for EAR support : one for JBoss and another one for Websphere and attach both patches. Sounds good ? Best regards, Adrian De : Adrian Gonzalez adr_gonza...@yahoo.fr À : MyFaces Discussion users@myfaces.apache.org; Mark Struberg strub...@yahoo.de Envoyé le : Mardi 26 mars 2013 17h22 Objet : Re: CODI ViewAccessScoped issue with EAR on JBoss 7.1.x Hello, Sorry for the late feedback. Currently struggling on making it work with Websphere 8 (as Denis before) before sending a patch. I've corrected locally the IllegalAccessError on DefaultBeanEntryFactory [1] (just making DefaultBeanEntryFactory public corrects the issue). Now I get only the NullPointerException on JsfRequestLifecycleBroadcaster.broadcastBeforeEvent [2]. I know I could set classloader to APPLICATION, but as Denis said, it is not officially supported by Websphere. So I prefer to modify CODI's code (if possible) to be able to use it on WAS. I don't have anymore time this week to work on these issues, so I'll follow up next week. Thanks, Adrian [1] [3/26/13 16:52:53:494 CET] 00bc webappE com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[Faces Servlet]: java.lang.RuntimeException: by java.lang.IllegalAccessError: org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.DefaultBeanEntryFactory at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:509) at javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:486) at javassist.util.proxy.ProxyFactory.createClass1(ProxyFactory.java:422) at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:394) [2] java.lang.NullPointerException: null at org.apache.myfaces.extensions.cdi.jsf.impl.listener.phase.JsfRequestLifecycleBroadcaster.broadcastBeforeEvent(JsfRequestLifecycleBroadcaster.java:58) ~[myfaces-extcdi-bundle-jsf20-1.0.5.nxs1-SNAPSHOT.jar:1.0.5.nxs1-SNAPSHOT] at org.apache.myfaces.extensions.cdi.jsf.impl.listener.phase.JsfRequestLifecyclePhaseListener.beforePhase(JsfRequestLifecyclePhaseListener.java:56) ~[myfaces-extcdi-bundle-jsf20-1.0.5.nxs1-SNAPSHOT.jar:1.0.5.nxs1-SNAPSHOT] at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:76) ~[com.ibm.ws.jsf.myfaces.jar:na] at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:159) ~[com.ibm.ws.jsf.myfaces.jar:na] at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) ~[com.ibm.ws.jsf.myfaces.jar:na] at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.execute(CodiLifecycleWrapper.java:101) ~[myfaces-extcdi-bundle-jsf20-1.0.5.nxs1-SNAPSHOT.jar:1.0.5.nxs1-SNAPSHOT] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189) ~[javax.j2ee.jsf.jar:na] De : Mark Struberg strub...@yahoo.de À : MyFaces
Re: CODI ViewAccessScoped issue with EAR on JBoss 7.1.x
but basically it isn't an issue of codi - please file an issue for WAS8. +1 might probably be a problem of WAS using EJB proxies for CDI beans. LieGrue, strub - Original Message - From: Gerhard Petracek gerhard.petra...@gmail.com To: MyFaces Discussion users@myfaces.apache.org; Adrian Gonzalez adr_gonza...@yahoo.fr Cc: Sent: Thursday, April 4, 2013 11:06 AM Subject: Re: CODI ViewAccessScoped issue with EAR on JBoss 7.1.x hi adrian, we can do EXTCDI-308 easily, but basically it isn't an issue of codi - please file an issue for WAS8. regards, gerhard http://www.irian.at Your JSF/JavaEE powerhouse - JavaEE Consulting, Development and Courses in English and German Professional Support for Apache MyFaces 2013/4/3 Adrian Gonzalez adr_gonza...@yahoo.fr Just created : * https://issues.apache.org/jira/browse/EXTCDI-307 (EAR support for JBoss) * https://issues.apache.org/jira/browse/EXTCDI-308 (EAR support for WAS) and attached the corresponding patches. Please note that these patches doesn't cover support for all the CODI modules (I've tested EAR support only for the JSF module). Regards, Adrian - Mail original - De : Adrian Gonzalez adr_gonza...@yahoo.fr À : MyFaces Discussion users@myfaces.apache.org Cc : Envoyé le : Mercredi 3 avril 2013 11h52 Objet : Re: CODI ViewAccessScoped issue with EAR on JBoss 7.1.x Hello, I just resolved java.lang.NullPointerException: null on Websphere (8.0.0.4) (see [2] below). This issue was due : When a client calls a method with package level access on a CDI bean, WAS 8.0.0.4 doesn't execute the interceptor chain. The call is executed directly on the javassist class (and @Inject fields are null in the javassist class - so we get the NPE). For now, just setting method visibility to public on both JsfRequestLifecycleBroadcaster#broadcastBeforeEvent et JsfRequestLifecycleBroadcaster#broadcastAfterEvent resolves this issue. Question is : bug located in Websphere or in CODI ? In other workds, does CDI 1.0 supports calling methods with package level access ? I looked at the CDI spec, but didn't find anything on this matter. Interceptor spec 1.1 supports it (from chapter Method interceptors : 'Around-invoke methods can have public, private, protected, or package level access. An around-invoke method must not be declared as final or static.') If it's in WAS, I can open a PMR for this. I will open 2 tickets for EAR support : one for JBoss and another one for Websphere and attach both patches. Sounds good ? Best regards, Adrian De : Adrian Gonzalez adr_gonza...@yahoo.fr À : MyFaces Discussion users@myfaces.apache.org; Mark Struberg strub...@yahoo.de Envoyé le : Mardi 26 mars 2013 17h22 Objet : Re: CODI ViewAccessScoped issue with EAR on JBoss 7.1.x Hello, Sorry for the late feedback. Currently struggling on making it work with Websphere 8 (as Denis before) before sending a patch. I've corrected locally the IllegalAccessError on DefaultBeanEntryFactory [1] (just making DefaultBeanEntryFactory public corrects the issue). Now I get only the NullPointerException on JsfRequestLifecycleBroadcaster.broadcastBeforeEvent [2]. I know I could set classloader to APPLICATION, but as Denis said, it is not officially supported by Websphere. So I prefer to modify CODI's code (if possible) to be able to use it on WAS. I don't have anymore time this week to work on these issues, so I'll follow up next week. Thanks, Adrian [1] [3/26/13 16:52:53:494 CET] 00bc webapp E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[Faces Servlet]: java.lang.RuntimeException: by java.lang.IllegalAccessError: org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.DefaultBeanEntryFactory at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:509) at javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:486) at javassist.util.proxy.ProxyFactory.createClass1(ProxyFactory.java:422) at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:394) [2] java.lang.NullPointerException: null at org.apache.myfaces.extensions.cdi.jsf.impl.listener.phase.JsfRequestLifecycleBroadcaster.broadcastBeforeEvent(JsfRequestLifecycleBroadcaster.java:58) ~[myfaces-extcdi-bundle-jsf20-1.0.5.nxs1-SNAPSHOT.jar:1.0.5.nxs1-SNAPSHOT] at org.apache.myfaces.extensions.cdi.jsf.impl.listener.phase.JsfRequestLifecyclePhaseListener.beforePhase(JsfRequestLifecyclePhaseListener.java:56) ~[myfaces-extcdi-bundle-jsf20-1.0.5.nxs1-SNAPSHOT.jar:1.0.5.nxs1-SNAPSHOT] at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:76) ~[com.ibm.ws.jsf.myfaces.jar:na] at
How to programmatically instantiate a composite component or a tag component ?
Dear all, how can I programatically instantiate a composite component or a tag component from a custom component ? I proceed this way to instantiate a composite component, but I do not really like it as I use reflection to hijack FaceletViewDeclarationLanguage methods... public UIComponent instantiateComposite(String namespace, String componentName) { FacesContext ctx = FacesContext.getCurrentInstance(); Resource resource = ctx.getApplication().getResourceHandler().createResource( componentName + .xhtml, namespace ); UIComponent cc = ctx.getApplication().createComponent( ctx, resource ); UIPanel panel = (UIPanel) ctx.getApplication().createComponent( UIPanel.COMPONENT_TYPE ); // set the facelet's parent cc.getFacets().put( UIComponent.COMPOSITE_FACET_NAME, panel ); FaceletFactory ff = (DefaultFaceletFactory) DefaultFaceletFactory.getInstance(); if(ff == null) { FaceletViewDeclarationLanguage vdl = new FaceletViewDeclarationLanguage(ctx); Method createCompiler = null; Method createFaceletFactory = null; try { createCompiler = FaceletViewDeclarationLanguage.class.getDeclaredMethod(createCompiler,FacesContext.class); createFaceletFactory = FaceletViewDeclarationLanguage.class.getDeclaredMethod(createFaceletFactory,FacesContext.class,org.apache.myfaces.view.facelets.compiler.Compiler.class); createCompiler.setAccessible(true); createFaceletFactory.setAccessible(true); org.apache.myfaces.view.facelets.compiler.Compiler compiler = (org.apache.myfaces.view.facelets.compiler.Compiler) createCompiler.invoke(vdl, ctx); ff = (FaceletFactory) createFaceletFactory.invoke(vdl, ctx, compiler); } catch (IllegalAccessException ex) { Logger.getLogger(SenatDataTableEntryDetail.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalArgumentException ex) { Logger.getLogger(SenatDataTableEntryDetail.class.getName()).log(Level.SEVERE, null, ex); } catch (InvocationTargetException ex) { Logger.getLogger(SenatDataTableEntryDetail.class.getName()).log(Level.SEVERE, null, ex); } catch (NoSuchMethodException ex) { Logger.getLogger(SenatDataTableEntryDetail.class.getName()).log(Level.SEVERE, null, ex); } catch (SecurityException ex) { Logger.getLogger(SenatDataTableEntryDetail.class.getName()).log(Level.SEVERE, null, ex); } } try { Facelet facelet = ff.getFacelet(resource.getURL()); facelet.apply( ctx, panel ); } catch ( IOException e ) { e.printStackTrace(); } return cc; } How can I do the same stuff in a cleanier way ? And how can I instantiate a tag component I mean a component declared the following way : tag descriptionblah blah/description tag-namemyWonderfulTag/tag-name sourcetags/mwl/myWonderfulTag.xhtml/source !-- attributes -- /tag in a taglib. Thanks in advance, Ludovic PS : question also asked on stackoverflow : http://stackoverflow.com/questions/15813582/how-to-programmatically-instantiate-a-composite-component-or-a-tag-component | | AVANT D'IMPRIMER, PENSEZ A L'ENVIRONNEMENT. |