简体   繁体   English

将PrimeFaces应用程序部署到GlassFish4会导致java.lang.NoClassDefFoundError:org / apache / commons / fileupload / FileItem

[英]Deploying PrimeFaces app to GlassFish4 causes java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItem

I'd like to use <p:calendar> in my JSF app developed in Netbeans, so I added the PrimeFaces library. 我想在Netbeans开发的JSF应用程序中使用<p:calendar> ,所以我添加了PrimeFaces库。 However, when I deploy the app, it errors 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)

And 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 is this caused and how can I solve it? 这是怎么造成的,我该如何解决?

java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItem java.lang.NoClassDefFoundError:org / apache / commons / fileupload / FileItem

There is the cause. 有原因。 It's crystal clear. 它很清楚。 The mentioned class is missing in the runtime classpath. 运行时类路径中缺少所提到的类。 The solution is rather straightforward: put the mentioned class (or, the JAR file containing it) in the runtime classpath. 解决方案非常简单:将提到的类(或包含它的JAR文件)放在运行时类路径中。 As the package name hints, it's available on http://commons.apache.org/fileupload (which in turn has by the way http://commons.apache.org/io as dependency). 正如软件包名称提示的那样,它可以在http://commons.apache.org/fileupload获得 (顺便提一下http://commons.apache.org/io作为依赖项)。 Just download and drop those JARs in the same place as PrimeFaces JAR and all should be well. 只需将这些JAR下载并放在与PrimeFaces JAR相同的位置,一切都应该很好。


Unrelated to the concrete problem, note that this particular problem is in turn unintented by PrimeFaces. 具体问题无关 ,请注意PrimeFaces无法解决这个特殊问题。 This problem should actually only occur when you register the FileUploadFilter for the <p:fileUpload> component in web.xml . 实际上,只有在web.xml<p:fileUpload>组件注册FileUploadFilter时才会出现此问题。 However, since GlassFish 4.0, it is overzealously preloading every single JSF component and renderer class found in the classpath even if it's never used by the application. 但是,自从GlassFish 4.0以来,即使它从未被应用程序使用过,它也会过度预加载在类路径中找到的每个JSF组件和渲染器类。 The class loading in turn causes all its runtime dependencies to be checked. 类加载反过来导致检查其所有运行时依赖性。 If it's missing, then you get the NoClassDefFoundError . 如果它丢失了,那么你得到NoClassDefFoundError This problem is thus specific to GlassFish 4.0 and does not occur when using GlassFish 3.x or any other servletcontainer such as Tomcat or JBoss. 因此,此问题特定于GlassFish 4.0,并且在使用GlassFish 3.x或任何其他servlet容器(如Tomcat或JBoss)时不会发生。

  1. Download file .jar in http://www.primefaces.org/downloads.html . http://www.primefaces.org/downloads.html下载.jar文件。 (Example primefaces-3.5.jar). (例如primefaces-3.5.jar)。
  2. Add file .jar in project 在项目中添加.jar文件
  3. Add this text xmlns:p="http://primefaces.org/ui" in tag <html> on file .xhtml 在文件.xhtml的标签<html>添加此文本xmlns:p="http://primefaces.org/ui"
  4. Write code for create calendar use primefaces: <p:calendar value="#{dateBean.date}" /> 编写创建日历的代码使用primefaces: <p:calendar value="#{dateBean.date}" />

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.NoClassDefFoundError:org / apache / commons / digester / Digester Apache 7 - java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester Apache 7 java.lang.NoClassDefFoundError:org / apache / commons / discovery / tools / DiscoverSingleton - java.lang.NoClassDefFoundError: org/apache/commons/discovery/tools/DiscoverSingleton 初始化上下文时捕获到异常:java.lang.NoClassDefFoundError:org / apache / commons / digester / Digester - Exception caught while initializing context: java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester java.lang.NoClassDefFoundError:Lorg / apache / myfaces / custom / fileupload / UploadedFile - java.lang.NoClassDefFoundError: Lorg/apache/myfaces/custom/fileupload/UploadedFile java.lang.NoClassDefFoundError:org / primefaces / event / CellEditEvent - java.lang.NoClassDefFoundError: org/primefaces/event/CellEditEvent 在 glassfish4 上部署项目后 org.apache.jasper.JasperException - org.apache.jasper.JasperException after deploying project on glassfish4 java.lang.NoClassDefFoundError:org / apache / poi / ss / usermodel / RichTextString at org.primefaces.component.export.ExporterFactory.getExporterForType - java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/RichTextString at org.primefaces.component.export.ExporterFactory.getExporterForType java.lang.NoClassDefFoundError:org / ajax4jsf / resource / InternetResourceBuilder - java.lang.NoClassDefFoundError: org/ajax4jsf/resource/InternetResourceBuilder java.lang.NoClassDefFoundError:org / atmosphere / cpr / AsyncSupportListenerAdapter - java.lang.NoClassDefFoundError: org/atmosphere/cpr/AsyncSupportListenerAdapter 将GlassFish迁移到Tomcat会引发java.lang.NoClassDefFoundError:com / sun / enterprise / InjectionException - Migrating GlassFish to Tomcat throws java.lang.NoClassDefFoundError: com/sun/enterprise/InjectionException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM