Please help me with this application!!!!!

G

gbattine

Hy guys,
i've developed a JSF application that allow user to upload a file.
I've used Myfaces extensions to do it as exposed in an article
http://www.onjava.com/pub/a/onjava/2005/07/13/jsfupload.html?page=1

My question is:when i run the application and i select a file,after i
submit i've this error in eclipse

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented
it from fulfilling this request.

exception

javax.servlet.ServletException: Filter execution threw an exception


root cause

java.lang.NoClassDefFoundError:
org/apache/commons/fileupload/FileUpload
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:114)


note The full stack trace of the root cause is available in the Apache
Tomcat/5.0.28 logs.

How can i resolve it?
I send you my web.xml,my faces-config.xml and Mybean.java...........
Can you help me?Please....it's urgent....


Web.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>

<filter>
<filter-name>ExtensionsFilter</filter-name>
<filter-class>
org.apache.myfaces.component.html.util.ExtensionsFilter
</filter-class>
<init-param>
<param-name>uploadMaxFileSize</param-name>
<param-value>100m</param-value>
</init-param>
<init-param>
<param-name>uploadThresholdSize</param-name>
<param-value>100k</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>ExtensionsFilter</filter-name>
<servlet-name>FacesServlet</servlet-name>
</filter-mapping>

<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>
javax.faces.webapp.FacesServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

</web-app>


faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD
JavaServer Faces Config 1.1//EN"

"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
<managed-bean>
<managed-bean-name>myBean</managed-bean-name>

<managed-bean-class>com.devsphere.articles.jsfupload.MyBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/pages/MyForm.jsp</from-view-id>
<navigation-case>
<from-outcome>OK</from-outcome>
<to-view-id>/pages/MyResult.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>

Mybean.java

package com.devsphere.articles.jsfupload;

import org.apache.myfaces.custom.fileupload.UploadedFile;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import java.security.MessageDigest;
//import java.security.NoSuchAlgorithmException;

import java.io.*;

public class MyBean {
private UploadedFile myFile;
private String myParam;
private String myResult;

public UploadedFile getMyFile() {
return myFile;
}

public void setMyFile(UploadedFile myFile) {
this.myFile = myFile;
}

public String getMyParam() {
return myParam;
}

public void setMyParam(String myParam) {
this.myParam = myParam;
}

public String getMyResult() {
return myResult;
}

public void setMyResult(String myResult) {
this.myResult = myResult;
}

public String processMyFile() {
try {
MessageDigest md
= MessageDigest.getInstance(myParam);
InputStream in = new BufferedInputStream(
myFile.getInputStream());
try {
byte[] buffer = new byte[64 * 1024];
int count;
while ((count = in.read(buffer)) > 0)
md.update(buffer, 0, count);
} finally {
in.close();
}
byte hash[] = md.digest();
StringBuffer buf = new StringBuffer();
for (int i = 0; i < hash.length; i++) {
int b = hash & 0xFF;
int c = (b >> 4) & 0xF;
c = c < 10 ? '0' + c : 'A' + c - 10;
buf.append((char) c);
c = b & 0xF;
c = c < 10 ? '0' + c : 'A' + c - 10;
buf.append((char) c);
}
myResult = buf.toString();
return "OK";
} catch (Exception x) {
FacesMessage message = new FacesMessage(
FacesMessage.SEVERITY_FATAL,
x.getClass().getName(), x.getMessage());
FacesContext.getCurrentInstance().addMessage(
null, message);
return null;
}
}

}
 
D

Danno

gbattine said:
Hy guys,
i've developed a JSF application that allow user to upload a file.
I've used Myfaces extensions to do it as exposed in an article
http://www.onjava.com/pub/a/onjava/2005/07/13/jsfupload.html?page=1

My question is:when i run the application and i select a file,after i
submit i've this error in eclipse

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented
it from fulfilling this request.

exception

javax.servlet.ServletException: Filter execution threw an exception


root cause

java.lang.NoClassDefFoundError:
org/apache/commons/fileupload/FileUpload
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:114)


note The full stack trace of the root cause is available in the Apache
Tomcat/5.0.28 logs.

How can i resolve it?
I send you my web.xml,my faces-config.xml and Mybean.java...........
Can you help me?Please....it's urgent....


Web.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>

<filter>
<filter-name>ExtensionsFilter</filter-name>
<filter-class>
org.apache.myfaces.component.html.util.ExtensionsFilter
</filter-class>
<init-param>
<param-name>uploadMaxFileSize</param-name>
<param-value>100m</param-value>
</init-param>
<init-param>
<param-name>uploadThresholdSize</param-name>
<param-value>100k</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>ExtensionsFilter</filter-name>
<servlet-name>FacesServlet</servlet-name>
</filter-mapping>

<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>
javax.faces.webapp.FacesServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

</web-app>


faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD
JavaServer Faces Config 1.1//EN"

"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
<managed-bean>
<managed-bean-name>myBean</managed-bean-name>

<managed-bean-class>com.devsphere.articles.jsfupload.MyBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/pages/MyForm.jsp</from-view-id>
<navigation-case>
<from-outcome>OK</from-outcome>
<to-view-id>/pages/MyResult.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>

Mybean.java

package com.devsphere.articles.jsfupload;

import org.apache.myfaces.custom.fileupload.UploadedFile;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import java.security.MessageDigest;
//import java.security.NoSuchAlgorithmException;

import java.io.*;

public class MyBean {
private UploadedFile myFile;
private String myParam;
private String myResult;

public UploadedFile getMyFile() {
return myFile;
}

public void setMyFile(UploadedFile myFile) {
this.myFile = myFile;
}

public String getMyParam() {
return myParam;
}

public void setMyParam(String myParam) {
this.myParam = myParam;
}

public String getMyResult() {
return myResult;
}

public void setMyResult(String myResult) {
this.myResult = myResult;
}

public String processMyFile() {
try {
MessageDigest md
= MessageDigest.getInstance(myParam);
InputStream in = new BufferedInputStream(
myFile.getInputStream());
try {
byte[] buffer = new byte[64 * 1024];
int count;
while ((count = in.read(buffer)) > 0)
md.update(buffer, 0, count);
} finally {
in.close();
}
byte hash[] = md.digest();
StringBuffer buf = new StringBuffer();
for (int i = 0; i < hash.length; i++) {
int b = hash & 0xFF;
int c = (b >> 4) & 0xF;
c = c < 10 ? '0' + c : 'A' + c - 10;
buf.append((char) c);
c = b & 0xF;
c = c < 10 ? '0' + c : 'A' + c - 10;
buf.append((char) c);
}
myResult = buf.toString();
return "OK";
} catch (Exception x) {
FacesMessage message = new FacesMessage(
FacesMessage.SEVERITY_FATAL,
x.getClass().getName(), x.getMessage());
FacesContext.getCurrentInstance().addMessage(
null, message);
return null;
}
}

}


tomahawk.jar needs to be in the WEB-INF/lib folder of your war file?
 
J

Juha Laiho

gbattine said:
i've developed a JSF application that allow user to upload a file.
I've used Myfaces extensions to do it as exposed in an article
http://www.onjava.com/pub/a/onjava/2005/07/13/jsfupload.html?page=1

My question is:when i run the application and i select a file,after i
submit i've this error in eclipse

root cause

java.lang.NoClassDefFoundError:
org/apache/commons/fileupload/FileUpload
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:114)

For some reason your system does not find the Apache commons fileupload
library. Where did you place the commons-fileupload.jar on the server?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,965
Messages
2,570,148
Members
46,710
Latest member
FredricRen

Latest Threads

Top