java.lang.NoClassDefFoundError: javax/faces/context/FacesContext
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19812574/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.NoClassDefFoundError: javax/faces/context/FacesContext
提问by Al2x
I have two web projects in Eclipse: Framework and webxxx
我在 Eclipse 中有两个 Web 项目:Framework 和 webxxx
In my framework I have some utils
functions like copy, download, upload,etc...
在我的框架中,我有一些utils
功能,如复制、下载、上传等...
When I call download method from webxxx
I got *java.lang.NoClassDefFoundError: javax/faces/context/FacesContext*.
当我从webxxx
我得到的调用下载方法时*java.lang.NoClassDefFoundError: javax/faces/context/FacesContext*.
If I move GerenciarArquivo
class to webxxx project the downloadFile method works fine.
如果我将GerenciarArquivo
班级转移到 webxxx 项目,则 downloadFile 方法可以正常工作。
FRAMEWORK :
框架 :
public abstract class GerenciarArquivo{
...
public static void downloadFile(String filePath) throws IOException{
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) context
.getExternalContext().getResponse();
WEBXXX PROJECT :
WEBXXX 项目:
GerenciarArquivo.downloadFile(abb.getPath());
Both projects has :
这两个项目都有:
Web xxx project Dependencies :
Web xxx 项目依赖项:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.9</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<scope>provided</scope>
</dependency>
Framework dependencies :
框架依赖:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.9.Final</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
采纳答案by Reetika
Add this dependency, this resolve my problem of
添加此依赖项,这解决了我的问题
class not found exception : javax.faces.context.facesContext .
未找到类异常: javax.faces.context.facesContext 。
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
回答by Bhavana
Go to your Oracle->middleware->module-> and copy javax.jsf_1.2.0.1.jar and paste it in your EAR->APP-INF->lib folder and restart your server. Worked for me
转到您的 Oracle->middleware->module-> 并复制 javax.jsf_1.2.0.1.jar 并将其粘贴到您的 EAR->APP-INF->lib 文件夹中并重新启动您的服务器。为我工作