RE: Primefaces unable to create resources for jquery

jose fernandez, modified 5 Years ago. New Member Posts: 13 Join Date: 3/2/20 Recent Posts
Hello,
We have a portlet on Liferay DXP 7.1, JSF 2.2 and Primefaces 6.2.There is message on the logs concerning the Jquery resources form Primefaces. The Primefaces library is as provided no modifications have done on it.11:02:00,106 ERROR [MissingResourceImpl:94] Resource handler=[com.sun.faces.application.resource.ResourceHandlerImpl@7b8db7f8] was unable to create a resource for resourceName=[jquery/jquery.js] libraryName=[primefaces] contentType=[null
]
11:02:00,170 ERROR [MissingResourceImpl:94] Resource handler=[com.sun.faces.application.resource.ResourceHandlerImpl@7b8db7f8] was unable to create a resource for resourceName=[jquery/jquery-plugins.js] libraryName=[primefaces] contentTy
pe=[null]

did somebody has ever had a similar problem?thx Jose
thumbnail
Neil Griffin, modified 5 Years ago. Liferay Legend Posts: 2655 Join Date: 7/27/05 Recent Posts
If you create a new portlet project with the PrimeFaces archetype, build it, and copy the resulting WAR to $LIFERAY_HOME/deploy, then do you see the same error in the logs?

mvn archetype:generate \
  -DarchetypeGroupId=com.liferay.faces.archetype \
  -DarchetypeArtifactId=com.liferay.faces.archetype.primefaces.portlet \
  -DarchetypeVersion=5.0.7 \
  -DgroupId=com.mycompany \
  -DartifactId=com.mycompany.my.primefaces.portlet
jose fernandez, modified 5 Years ago. New Member Posts: 13 Join Date: 3/2/20 Recent Posts
Hi Neil,Thanks for your reply.I did follow your instructions, the error is the same:15:59:30,774 ERROR [MissingResourceImpl:94] Resource handler=[com.sun.faces.application.resource.ResourceHandlerImpl@a951d48] was unable to create a resource for resourceName=[jquery/jquery.js] libraryName=[primefaces] contentType=[null]
15:59:30,828 ERROR [MissingResourceImpl:94] Resource handler=[com.sun.faces.application.resource.ResourceHandlerImpl@a951d48] was unable to create a resource for resourceName=[jquery/jquery-plugins.js] libraryName=[primefaces] contentType=[null]

Jose
thumbnail
Neil Griffin, modified 5 Years ago. Liferay Legend Posts: 2655 Join Date: 7/27/05 Recent Posts
Hi Jose,
I just did the following, in order to deploy a PrimeFaces portlet to Liferay DXP 7.1:
mvn archetype:generate \
  -DarchetypeGroupId=com.liferay.faces.archetype \
  -DarchetypeArtifactId=com.liferay.faces.archetype.primefaces.portlet \
  -DarchetypeVersion=5.0.7 \
  -DgroupId=com.mycompany \
  -DartifactId=com.mycompany.my.primefaces.portlet

mvn archetype:generate

mvn clean package

cp target/*.war to $LIFERAY_HOME/deploy
And then I added the portlet to a portal page and reloaded the page.
The portlet rendered fine. I am unable to reproduce your error.Therefore I would recommend that you try deploying the archetype to a clean install of Liferay DXP 7.1 and see if you encounter the same error.
Kind Regards,
Neil
jose fernandez, modified 5 Years ago. New Member Posts: 13 Join Date: 3/2/20 Recent Posts
Hi Neil,Yes that is what we have done, but it the error remains on the logs.Any idea what could be causing this issue?
On the source of the page we have this:
<script data-senna-track="permanent" type="text/javascript" src="[url=http://vpp-sn.slcloud.ch:8080/o/VPPportlet/RES_NOT_FOUND&amp;v=6.2]/o/VPPportlet/RES_NOT_FOUND&amp;v=6.2[/url]" id="primefaces:jquery/jquery.js">
</code></pre>Thanks for your answer.José</script>
jose fernandez, modified 5 Years ago. New Member Posts: 13 Join Date: 3/2/20 Recent Posts
To solve the issue we have implemented a class:public class VppCustomJsfResourceHandler extends javax.faces.application.ResourceHandlerWrapper {
.... @Override
    public Resource createResource(final String resourceName, final String libraryName) {
        final Resource resource = super.createResource(resourceName, libraryName);
        if ("primefaces".equals(libraryName) && "jquery/jquery.js".equals(resourceName)) {
            Resource localResource = new ResourceWrapper() {
                @Override
                public String getRequestPath() {
                    return "/o/theme/libs/jquery/jquery.js";
                }
...}Extract the jquery.js  library from the PF jar file and place it on the theme so this can be returned when required by jsf.
Cheers.José
thumbnail
Neil Griffin, modified 5 Years ago. Liferay Legend Posts: 2655 Join Date: 7/27/05 Recent Posts
Hi José,
Apologies for the delay in my reply. Thank you for posting your solution. I am very glad to know that it is working for you, but it is a workaround that you should not have to be doing.
Are you certain that you exactly/precisely followed my instructions regarding deploying a PrimeFaces portlet to Liferay DXP 7.1 using mvn archetype:generate? Also, did you try it with a clean install of DXP 7.1? Again, I was not able to reproduce the problem.
Kind Regards,Neil