gpt4 book ai didi

java.lang.NoClassDefFoundError : javax/faces/context/FacesContext

转载 作者:行者123 更新时间:2023-12-01 18:41:30 26 4
gpt4 key购买 nike

我在 Eclipse 中有两个 Web 项目:Framework 和 webxxx

在我的框架中,我有一些 utils复制、下载、上传等功能...

当我从webxxx调用下载方法时我得到了*java.lang.NoClassDefFoundError: javax/faces/context/FacesContext*.

如果我搬家GerenciarArquivo类到 webxxx 项目 downloadFile 方法工作正常。

框架:

public abstract class GerenciarArquivo{
...
public static void downloadFile(String filePath) throws IOException{
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) context
.getExternalContext().getResponse();

WEBXXX 项目:

GerenciarArquivo.downloadFile(abb.getPath());

两个项目都有:

enter image description here enter image description here

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>

框架依赖项:

<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>

最佳答案

添加此依赖项,这解决了我的问题

class not found exception : javax.faces.context.facesContext .

<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>

关于java.lang.NoClassDefFoundError : javax/faces/context/FacesContext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19812574/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com