javax.faces.FacesException: Assertion Failed....help me!!!

G

gbattine

Hi guys,
i'm a big question and i need your help.
I'm developing a Jsf applications that allows user to upload a file.
It' s a simple application and i have used commonsfile_upload to
realize the upload.
I use Eclipse and running the application i see:

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: javax.servlet.jsp.JspException:
Assertion Failed
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:821)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.pages.msg_jsp._jspService(msg_jsp.java:104)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jsp.pages.fileuploaddemo_jsp._jspService(fileuploaddemo_jsp.java:87)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:670)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:637)
org.apache.jsp.index_jsp._jspService(index_jsp.java:48)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.faces.FacesException: Assertion Failed
com.sun.faces.util.Util.doAssert(Util.java:1302)
com.sun.faces.taglib.jsf_core.ViewTag.getComponentType(ViewTag.java:241)
javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1013)
javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1036)
javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:749)
javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:429)
com.sun.faces.taglib.jsf_core.ViewTag.doStartTag(ViewTag.java:105)
org.apache.jsp.pages.msg_jsp._jspService(msg_jsp.java:65)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jsp.pages.fileuploaddemo_jsp._jspService(fileuploaddemo_jsp.java:87)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:670)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:637)
org.apache.jsp.index_jsp._jspService(index_jsp.java:48)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


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


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

Apache Tomcat/5.0.28


What can i do?Please help me, my simple code is:

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>UploadFile</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</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>
<navigation-rule>
<from-view-id>/pages/fileuploaddemo.jsp</from-view-id>
<navigation-case>
<from-outcome>msg</from-outcome>
<to-view-id>/pages/msg.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>

fileuploaddemo.jsp

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ page import="org.apache.commons.fileupload.*, java.util.List,
java.io.File, java.util.Iterator" %>
<html>
<head>
<title></title>
</head>
<body>
<f:view>
<%
// first check if the upload request coming in is a multipart request
boolean isMultipart = FileUpload.isMultipartContent(request);
// if not, send to message page with the error message
if(!isMultipart){
request.setAttribute("msg", "Request was not multipart!");
request.getRequestDispatcher("msg.jsp").forward(request, response);
return;
}

// now lets create a handler for the upload request.
DiskFileUpload upload = new DiskFileUpload();

// parse this request by the handler
// this gives us a list of items from the request
List items = upload.parseRequest(request);

// now iterate over this list
Iterator itr = items.iterator();

while(itr.hasNext()){

FileItem item = (FileItem) itr.next();

// check if the current item is a form field or an uploaded file
if(item.isFormField()){

// get the name of the field
String fieldName = item.getFieldName();

// if it is name, we can set it in request to thank the user
if(fieldName.equals("name"))
request.setAttribute("msg", "Thank You: " + item.getString());
} else {

// the item must be an uploaded file
// save it to disk
File fullFile = new File(item.getName());
File savedFile = new File(getServletContext().getRealPath("/"),
fullFile.getName());
item.write(savedFile);
}
}

// finally send to the msg page
request.getRequestDispatcher("msg.jsp").forward(request, response);

%>
</f:view>
</body>
</html>


msg.jsp

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<html>
<head>
<title></title>
</head>
<body>
<f:view>
<%
String msg = (String)request.getAttribute("msg");
if(msg != null)
out.println("<font size=+1>" + msg + "</font><br/>");
%>

Click <a href="fileuploaddemo.htm">here</a> to go to the upload page.
</f:view>
</body>
</html>


fileuploaddemo.html

<!-- saved from url=(0022)http://internet.e-mail -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Upload Test</title>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
</head>
<body>

<form name="myform" action="fileuploaddemo.jsp" method="post"
enctype="multipart/form-data">
Specify your name:<br/><input type="text" name="name" ize="15"/><br/>
Specify your Image:<br/><input type="file" name="myimage"><br/>
Specify your File:<br/><input type="file" name="myfile"><br/>
<br/><input type="submit" name="Submit" value="Submit your files"/>
</form>

</body>
</html>

index.jsp

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head></head>
<body>
<jsp:forward page="/pages/fileuploaddemo.jsf" />
</body>
</html>


Thanks too much
 

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,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top