Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Please help me with this application!!!!!

Thread view: 
gbattine - 05 Jun 2006 15:36 GMT
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[i] & 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;
       }
   }

}
Danno - 05 Jun 2006 16:45 GMT
> Hy guys,
> i've developed a JSF application that allow user to upload a file.
[quoted text clipped - 195 lines]
>
> }

tomahawk.jar needs to be in the WEB-INF/lib folder of your war file?
Juha Laiho - 05 Jun 2006 17:13 GMT
"gbattine" <gbattine@alice.it> 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
[quoted text clipped - 8 lines]
>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?
Signature

Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
        PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.