0

I have two web projects in Eclipse: Framework and webxxx

In my framework I have some utils functions like copy, download, upload,etc...

When I call download method from webxxx I got *java.lang.NoClassDefFoundError: javax/faces/context/FacesContext*.

If I move GerenciarArquivo class to webxxx project the downloadFile method works fine.

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 :

GerenciarArquivo.downloadFile(abb.getPath());

Both projects has :

enter image description here enter image description here

Web xxx project Dependencies :

<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>
9
  • Primefaces upload component needs commons-fileupload. do you have it?
    – erencan
    Nov 6, 2013 at 12:54
  • Avoid including code as images. Just paste your code as text in a code block (4 spaces indentation)
    – rzymek
    Nov 6, 2013 at 13:00
  • @Al2x Could you try with JSF 2.2.4 (javax.faces-2.2.4.jar) and servlet version 3.0? And make sure you've included jar in your classpath please. Nov 6, 2013 at 14:07
  • in addition to commons-fileupload.jar, commons-ui.jar and commons-el.jar are also needed.
    – erencan
    Nov 6, 2013 at 14:20
  • Im getting this error : java.lang.ClassNotFoundException: javax.faces.context.FacesContext from [Module "deployment.Servicoxxx.ear.framework-1.0.0-SNAPSHOT.jar:main" from Service Module Loader] @ÖmerFarukAlmalı
    – Al2x
    Nov 6, 2013 at 15:28

2 Answers 2

6

Add this dependency, this resolve my problem of

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>
1
  • It worked.... I realized also that I need to create in framework project the facesconfig.xml inside META-INF folder. The facesconfig.xml can be empty.
    – Al2x
    Mar 19, 2015 at 13:44
-1

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

1
  • This solution is specific to an old version of a server we don't know the asker is using. Feb 4, 2014 at 15:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.