0

我在 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());

这两个项目都有:

在此处输入图像描述 在此处输入图像描述

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

2 回答 2

5

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

找不到类异常:javax.faces.context.facesContext。

<dependency>
     <groupId>javax</groupId>
     <artifactId>javaee-web-api</artifactId>
     <version>6.0</version>
     <scope>provided</scope>
</dependency>
于 2014-04-16T05:46:41.573 回答
-1

转到您的 Oracle->middleware->module-> 并复制 javax.jsf_1.2.0.1.jar 并将其粘贴到您的 EAR->APP-INF->lib 文件夹中并重新启动您的服务器。为我工作

于 2014-02-04T13:56:07.723 回答