Hi Leo, I agree that with you that the proposed fix via the additional export packages is quick and dirty.
However, I think MYFACES-3051 could solve this problem anyway, but I'm not totally sure. I will provide a patch for it later today, then we can test it. Regards, Jakob 2011/2/22 Leonardo Uribe <[email protected]>: > Hi > > The problem presented here is related to the custom OSGi setup used. In > theory, the default ResourceHandler implementation uses the Thread Context > Class Loader (TCCL) to load its resources. That includes everything inside > META-INF/resources and for MyFaces everything inside > META-INF/internal-resources, but across jar files. OSGi by default does not > set the TCCL, but MyFaces expects that, so the problem finally appears. > > The first consideration is the fix on the manifest proposed is questionable. > At start META-INF/resources/javax.faces is not a java package!. Why should > MyFaces export that as a package?. That just does not make sense. Even if it > works, it is a quick fix that does not solves the main problem. > > The problem is similar to the one with OSGi and SPI interfaces (scan files > through META-INF/services in different jars using a discovery mechanism). To > solve this problem in a friendly way, MyFaces has a new interface called > org.apache.myfaces.spi.ServiceProviderFinder, so users can implement this > interface to help MyFaces to find the files through bundles. > > Here there are two solutions: > > 1. Install a TCCL that could scan through bundles the resources. > 2. Create a custom ResourceHandler implementation that implement OSGi > specific rules. > > It is possible to apply the hack proposed (add the additional entries on > myfaces bundle manifest). I don't see any side effect of doing that, but > note it is not a full solution (so in principle it is safe to apply the > changes proposed). > > regards, > > Leonardo Uribe > > 2011/2/22 Jakob Korherr <[email protected]> > >> Hi Clovis, >> >> I agree that this issue (MYFACES-3044) should be fixed and not closed >> as invalid. Thus I just reopened it. >> >> However, before I commit your proposed solution, are there any >> objections? Leonardo? >> >> Regards, >> Jakob >> >> 2011/2/22 Mark Struberg <[email protected]>: >> > Hi Clovis! >> > >> > Please note that there is a new myfaces-2.0.4 out since last week. Afaik >> this got a bit love in regards to the OSGi part. >> > >> > If you like to submit patches, then please open a Jira and provide a svn >> diff against the latest trunk from >> > >> > svn co https://svn.apache.org/repos/asf/myfaces/current20 myfaces-trunk >> > >> > current20 contains all svn references you need to build the latest >> MyFaces2 version. >> > >> > LieGrue, >> > strub >> > >> > --- On Tue, 2/22/11, [email protected] < >> [email protected]> wrote: >> > >> >> From: [email protected] <[email protected]> >> >> Subject: NullPointerException with OSGi Bundle >> >> To: [email protected] >> >> Date: Tuesday, February 22, 2011, 8:05 AM >> >> Hello, >> >> >> >> using the OSGi Bundle of MyFaces >> >> (myfaces-bundle-2.0.3.jar), I get first a >> >> warning: >> >> WARNING: Resource referenced by resourceName jsf.js and >> >> libraryName >> >> javax.faces not found in call to >> >> ResourceHandler.createResource. It will >> >> be silenty ignored. >> >> >> >> and then a NullPointerException: >> >> javax.faces.FacesException: java.lang.NullPointerException >> >> at >> >> org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.wrap( >> >> ExceptionHandlerImpl.java:241) >> >> at >> >> org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.handle( >> >> ExceptionHandlerImpl.java:156) >> >> at >> >> org.apache.myfaces.lifecycle.LifecycleImpl.render( >> >> LifecycleImpl.java:258) >> >> at >> >> javax.faces.webapp.FacesServlet.service(FacesServlet.java:191) >> >> ... >> >> Caused by: java.lang.NullPointerException >> >> at >> >> >> org.apache.myfaces.shared_impl.renderkit.html.util.ResourceUtils.renderDefaultJsfJsInlineIfNecessary( >> >> ResourceUtils.java:204) >> >> at >> >> >> org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd( >> >> HtmlTextRendererBase.java:69) >> >> at >> >> javax.faces.component.UIComponentBase.encodeEnd( >> >> UIComponentBase.java:519) >> >> at >> >> javax.faces.component.UIComponent.encodeAll( >> >> UIComponent.java:626) >> >> at >> >> javax.faces.component.UIComponent.encodeAll( >> >> UIComponent.java:622) >> >> at >> >> javax.faces.component.UIComponent.encodeAll( >> >> UIComponent.java:622) >> >> at >> >> javax.faces.component.UIComponent.encodeAll( >> >> UIComponent.java:622) >> >> at >> >> >> org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView( >> >> FaceletViewDeclarationLanguage.java:1320) >> >> at >> >> org.apache.myfaces.application.ViewHandlerImpl.renderView( >> >> ViewHandlerImpl.java:263) >> >> at >> >> org.apache.myfaces.lifecycle.RenderResponseExecutor.execute( >> >> RenderResponseExecutor.java:85) >> >> at >> >> org.apache.myfaces.lifecycle.LifecycleImpl.render( >> >> LifecycleImpl.java:239) >> >> ... 23 more >> >> >> >> I submitted a bug, but it was closed, as this is the >> >> expected behavior. I >> >> was able to solve the problem by adding >> >> META-INF.internal-resources.javax.faces >> >> and >> >> META-INF.services >> >> to the exported packages in MANIFEST.MF. but I'd like to >> >> know anyway how I >> >> can avoid the NullPointerException without patching myself >> >> the file >> >> myfaces-bundle-2.0.3.jar. >> >> >> >> (The application I used is the first example from the book >> >> >> >> "JavaServerFaces 2.0, The complete reference" from Ed Burns >> >> & Chris >> >> Schalk) >> >> >> >> Thanks in advance >> >> >> >> Clovis Seragiotto >> >> >> >> ______________________________________ >> >> Raiffeisen Bausparkasse Gesellschaft m.b.H., 1050 Wien, >> >> Wiedner Hauptstraße 94, Firmenbuchnummer 116309v, >> >> Handelsgericht Wien, DVR 0066257, UID ATU15350206 >> >> >> >> Diese E-Mail kann vertrauliche und geschuetzte >> >> Informationen enthalten. Wenn diese E-Mail nicht für Sie >> >> bestimmt ist, bitten wir Sie, uns unverzueglich zu >> >> informieren und sie zu loeschen. >> >> >> >> This e-mail message may contain information, which is >> >> confidential and protected. If you are not the intended >> >> recipient of this message, we ask you to inform us >> >> immediately and delete the message afterwards. >> >> >> > >> > >> > >> > >> >> >> >> -- >> Jakob Korherr >> >> blog: http://www.jakobk.com >> twitter: http://twitter.com/jakobkorherr >> work: http://www.irian.at >> > -- Jakob Korherr blog: http://www.jakobk.com twitter: http://twitter.com/jakobkorherr work: http://www.irian.at

