Reputation: 1357
I just moved my application from glassfish to TomEE, that includes moving from mojarra to myfaces. So far I had a few problems that I could fix, but I don't know how to tackle this one.
If I use CDNResourceHandler and the PROJECT_STAGE is Production I get a NullPointerException (it does work fine in Development mode)
java.lang.NullPointerException
javax.faces.application.ResourceWrapper.getLibraryName(ResourceWrapper.java:94)
org.apache.myfaces.renderkit.html.HtmlScriptRenderer.encodeEnd(HtmlScriptRenderer.java:259)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:674)
javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:554)
org.primefaces.renderkit.HeadRenderer.encodeBegin(HeadRenderer.java:84)
javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:596)
javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:526)
The Resource is (org.omnifaces.resourcehandler.CDNResourceHandler$1) https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css
The relevant parts of the code
faces-config.xml
<application>
<resource-handler>org.omnifaces.resourcehandler.UnmappedResourceHandler</resource-handler>
<resource-handler>org.omnifaces.resourcehandler.CDNResourceHandler</resource-handler>
</application>
web.xml
<context-param>
<param-name>org.omnifaces.CDN_RESOURCE_HANDLER_URLS</param-name>
<param-value>bootstrap-cdn:bootstrap/3.2.0/js/bootstrap.min.js=//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js,
bootstrap-cdn:font-awesome/4.1.0/css/font-awesome.css=//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css,
bootstrap-cdn:bootstrap/3.2.0/css/bootstrap.min.css=//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css,
cloudflare-cdn:meyer-reset/2.0/reset.min.css=https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css.....
Omnifaces 1.8.1 (also tried with 2.0-SNAPSHOT) Myfaces 2.2.3
Upvotes: 1
Views: 246
Reputation: 1109532
MyFaces needed the library and resource name of the original resource so that it could mark the resource as "already rendered" (to prevent duplicate rendering). However, the CDNResourceHandler
didn't pass the original resource back via getWrapped()
.
This has been fixed and is available as per current snapshot. In the future, when you encounter an exception when using OmniFaces, you'd better report an issue.
Upvotes: 1