JSF – deploying the primefaces application to glassfish4 will result in Java lang.NoClassDefFoundError:org / apache / commons / fileupload / FileItem

I want to use < p: calendar > in the JSF application I developed in NetBeans, so I added the primefaces library However, when I deploy the application, its errors are as follows:

Context with name [/ManagedBeansWithComponents] has not yet been started
C:\Users\Dell-pc\Documents\NetBeansProjects\ManagedBeansWithComponents\nbproject\build-   impl.xml:1040: The module has not been deployed.
See the server log for details.
BUILD Failed (total time: 1 second)

The server log says:

Source Document: jar:file:/C:/Users/Dell-pc/Documents/NetBeansProjects/ManagedBeansWithComponents/build/web/WEB-INF/lib/primefaces-3.5.jar!/Meta-INF/faces-config.xml
Cause: Class 'org.primefaces.component.fileupload.FileUploadRenderer' is missing a runtime dependency: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItem

How did this happen and how should I solve it?

Solution

There is a reason It's clear The mentioned class is missing from the runtime classpath The solution is simple: put the mentioned class (or jar file containing it) in the runtime classpath As the package name suggests, it is http://commons.apache.org/fileupload Available on (and 0700 depends on it) Just download these jars and put them in the same location as primefaces jars, and everything should be fine

It has nothing to do with the specific problem. Please note that primefaces cannot solve this special problem In fact, this problem only occurs when registering fileuploadfilter for < p: fileUpload > web. Components in XML However, since GlassFish 4.0, even if it has never been used by an application, it will over preload every JSF component and renderer class found in the classpath Class loading in turn causes all of its runtime dependencies to be checked If it is lost, you get NoClassDefFoundError Therefore, this problem is specific to GlassFish 4.0 and is using GlassFish 3.0 X or any other servlet container, such as Tomcat or JBoss

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>