Hello,
1. was just a typo here in the forum.
2. I changed it, but it does still does not work.
I sniffed the network traffic using wireshark when submitting/uploading the file and the file is transfered to the server, the temporary file is created but the resulting page ( the one only visible by sniffing the network traffic) throws a javax.faces.application.ViewExpiredException
----
ok, I actually narrowed down the problem even more...
my faces servlet is mapped like this
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
now, JSF 2.0 allows faces to be called either as /upload or as /upload.xhtml
When I open the page as /upload.xhtml, try to upload a sample file (0.5kb) i get a ViewExpiredException like this
- Code:
POST /skriptum/upload.xhtml;jsessionid=56e7c11d28a245b1de5b4ecee5bd HTTP/1.1
Host: localhost:8080
Accept: */*
User-Agent: Shockwave Flash
Connection: Keep-Alive
Cache-Control: no-cache
Content-Length: 1171
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----------------------------8fafa1477dfa
HTTP/1.1 100 Continue
------------------------------8fafa1477dfa
Content-Disposition: form-data; name="Filename"
blabla.pdf
------------------------------8fafa1477dfa
Content-Disposition: form-data; name="primefacesAjaxRequest"
true
------------------------------8fafa1477dfa
Content-Disposition: form-data; name="javax.faces.ViewState"
-6524465661669890995:6420893136122431694
------------------------------8fafa1477dfa
Content-Disposition: form-data; name="j_idt15"
j_idt15
------------------------------8fafa1477dfa
Content-Disposition: form-data; name="update"
messages
------------------------------8fafa1477dfa
Content-Disposition: form-data; name="fileext"
*.doc;*.docx;*.odt;*.pdf
------------------------------8fafa1477dfa
Content-Disposition: form-data; name="folder"
/skriptum/
------------------------------8fafa1477dfa
Content-Disposition: form-data; name="documentToUpload"; filename="blabla.pdf"
Content-Type: application/octet-stream
asdkfasdf
asd
f
asd
f
asd
f
asdfasdf
EOF!!!
------------------------------8fafa1477dfa
Content-Disposition: form-data; name="Upload"
Submit Query
------------------------------8fafa1477dfa--
HTTP/1.1 500 Internal Server Error
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Date: Sun, 06 Dec 2009 20:34:53 GMT
Connection: close
2000
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can obtain
a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
language governing permissions and limitations under the License.
When distributing the software, include this License Header Notice in each
file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
Sun designates this particular file as subject to the "Classpath" exception
as provided by Sun in the GPL Version 2 section of the License file that
accompanied this code. If applicable, add the following below the License
Header, with the fields enclosed by brackets [] replaced by your own
identifying information: "Portions Copyrighted [year]
[name of copyright owner]"
Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
only the GPL Version 2, indicate your decision by adding "[Contributor]
elects to include this software in this distribution under the [CDDL or GPL
Version 2] license." If you don't indicate a single choice of license, a
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above. However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
This file incorporates work covered by the following copyright and
permission notice:
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Error - viewId:/upload.xhtml - View /upload.xhtml could not be restored.</title>
<style type="text/css">
body, div, span, td, th, caption { font-family: 'Trebuchet MS', Verdana, Arial, Sans-Serif; font-size: small; }
ul, li, pre { padding: 0; margin: 0; }
h1 { color: #900; }
h2, h2 span { font-size: large; color: #339; }
h2 a { text-decoration: none; color: #339; }
.grayBox { padding: 8px; margin: 10px 0; border: 1px solid #CCC; background-color: #f9f9f9; }
#error { color: #900; font-weight: bold; font-size: medium; }
#trace, #tree, #vars { display: none; }
code { font-size: medium; }
#tree dl { color: #006; }
#tree dd { margin-top: 2px; margin-bottom: 2px; }
#tree dt { border: 1px solid #DDD; padding: 4px; border-left: 2px solid #666; font-family: "Courier New", Courier, mono; font-size: small; }
.uicText { color: #999; }
table { border: 1px solid #CCC; border-collapse: collapse; border-spacing: 0px; width: 100%; text-align: left; }
td { border: 1px solid #CCC; }
thead tr th { padding: 2px; color: #030; background-color: #F9F9F9; }
tbody tr td { padding: 10px 6px; }
table caption { text-align: left; padding: 10px 0; font-size: large; }
</style>
<style type="text/css" media="print">
#trace, #tree, #vars { display: block; }
</style>
<script language="javascript" type="text/javascript">
function faceletstoggle(id) {
var style = document.getElementById(id).style;
if ("block" == style.display) {
style.display = "none";
document.getElementById(id+"Off").style.display = "inline";
document.getElementById(id+"On").style.display = "none";
} else {
style.display = "block";
document.getElementById(id+"Off").style.display = "none";
document.getElementById(id+"On").style.display = "inline";
}
}
</script>
</head>
<body>
<div id="javax.faces.error.xhtml">
<h1>An Error Occurred:</h1>
<div id="error" class="grayBox" style="border: 1px solid #900;">viewId:/upload.xhtml - View /upload.xhtml could not be restored.</div>
<h2><a href="#" onclick="faceletstoggle('trace'); return false;"><span id="traceOff">+</span><span id="traceOn" style="display: none;">-</span> Stack Trace</a></h2>
<div id="trace" class="grayBox"><pre><code>javax.faces.application.ViewExpiredException: viewId:/upload.xhtml - View /upload.xhtml could not be restored.
.at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:212)
.at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
.at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
.at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
.at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
.at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
.at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
.at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
.at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:77)
.at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
.at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
.at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:74)
.at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
.at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
.at com.dominikdorn.sk.service.UserRoleFilter.doFilter(UserRoleFilter.java:46)
.at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
.at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
.at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
.at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
.at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
.at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
.at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
.at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
.at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
.at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
.at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
.at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
.at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
.at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
.at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
.at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
.at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
.at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
.at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
.at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
.at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
.at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
.at com.sun.grizzly.util.AbstractThread
2000
Pool$Worker.doWork(AbstractThreadPool.java:330)
.at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
.at java.lang.Thread.run(Thread.java:619)
</code></pre></div>
....
When I try to upload it from just /upload it works with the small example file and renders the view in the background, as seen in the following snipped
- Code:
POST /skriptum/upload;jsessionid=56e7c11d28a245b1de5b4ecee5bd HTTP/1.1
Host: localhost:8080
Accept: */*
User-Agent: Shockwave Flash
Connection: Keep-Alive
Cache-Control: no-cache
Content-Length: 1170
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----------------------------d01cf8041573
HTTP/1.1 100 Continue
------------------------------d01cf8041573
Content-Disposition: form-data; name="Filename"
blabla.pdf
------------------------------d01cf8041573
Content-Disposition: form-data; name="primefacesAjaxRequest"
true
------------------------------d01cf8041573
Content-Disposition: form-data; name="javax.faces.ViewState"
1253717635934289772:-810517928959273638
------------------------------d01cf8041573
Content-Disposition: form-data; name="j_idt15"
j_idt15
------------------------------d01cf8041573
Content-Disposition: form-data; name="update"
messages
------------------------------d01cf8041573
Content-Disposition: form-data; name="fileext"
*.doc;*.docx;*.odt;*.pdf
------------------------------d01cf8041573
Content-Disposition: form-data; name="folder"
/skriptum/
------------------------------d01cf8041573
Content-Disposition: form-data; name="documentToUpload"; filename="blabla.pdf"
Content-Type: application/octet-stream
asdkfasdf
asd
f
asd
f
asd
f
asdfasdf
EOF!!!
------------------------------d01cf8041573
Content-Disposition: form-data; name="Upload"
Submit Query
------------------------------d01cf8041573--
HTTP/1.1 200 OK
X-Powered-By: Servlet/3.0
Server: GlassFish v3
Set-Cookie: JSESSIONID=5b72e6342ab68e807583a814ae28; Path=/skriptum
X-Powered-By: JSF/2.0
X-Powered-By: JSF/2.0
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Date: Sun, 06 Dec 2009 20:38:41 GMT
2000
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<title> <ui:define name="title"> </ui:define>
</title>
<script type="text/javascript" src="/skriptum/primefaces_resource/2.0.0.RC/yui/utilities/utilities.js"></script>
<script type="text/javascript" src="/skriptum/primefaces_resource/2.0.0.RC/primefaces/core/core.js"></script>
<link rel="stylesheet" type="text/css" href="/skriptum/primefaces_resource/2.0.0.RC/jquery/plugins/gritter/assets/gritter.css" />
<script type="text/javascript" src="/skriptum/primefaces_resource/2.0.0.RC/jquery/jquery.js"></script>
<script type="text/javascript" src="/skriptum/primefaces_resource/2.0.0.RC/jquery/plugins/gritter/jquery.gritter.js"></script>
<link rel="stylesheet" type="text/css" href="/skriptum/primefaces_resource/2.0.0.RC/jquery/plugins/uploadify/uploadify.css" />
<script type="text/javascript" src="/skriptum/primefaces_resource/2.0.0.RC/yui/cookie/cookie-min.js"></script>
<script type="text/javascript" src="/skriptum/primefaces_resource/2.0.0.RC/jquery/plugins/uploadify/swfobject.js"></script>
<script type="text/javascript" src="/skriptum/primefaces_resource/2.0.0.RC/jquery/plugins/uploadify/jquery.uploadify.v2.1.0.min.js"></script>
<script type="text/javascript" src="/skriptum/primefaces_resource/2.0.0.RC/primefaces/ajax/ajax.js"></script>
<script type="text/javascript" src="/skriptum/primefaces_resource/2.0.0.RC/primefaces/uploader/uploader.js"></script>
<link type="text/css" rel="stylesheet" href="/skriptum/javax.faces.resource/layout.css.xhtml?ln=skripts" /><link type="text/css" rel="stylesheet" href="/skriptum/javax.faces.resource/layout_m.css.xhtml?ln=skripts" /></head><body>
<div id="main" class="container">
<div id="content" class="middlecolumns">
<!--<h1><ui:insert name="title" /></h1>-->
<h1>Dokument hochladen</h1>
<style type="text/css">
form div p label {
display: block;
width: 200px;
float: left;
}
form div p input {
width: 200px;
}
form div {
display: block;
background: rgb(201, 219, 255);
margin: 5px; /*width: 800px;*/
}
</style>
<form id="j_idt15" name="j_idt15" method="post" action="/skriptum/upload;jsessionid=5b72e6342ab68e807583a814ae28" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt15" value="j_idt15" />
<script type="text/javascript">PrimeFaces.onContentReady('messages', function() {
});
</script><span id="messages"></span>
<div>
<h2>1. Lade Dein Dokument hoch</h2>
FOOBAR
<pre><label for="documentToUpload">
Dokument</label><script type="text/javascript">PrimeFaces.onContentReady('documentToUpload', function () {
documentToUpload_widget = new PrimeFaces.widget.Uploader('documentToUpload', {
uploader:'/skriptum/primefaces_resource/2.0.0.RC/jquery/plugins/uploadify/uploadify.swf',script:'/skriptum/upload;jsessionid=5b72e6342ab68e807583a814ae28',cancelImg:'/skriptum/primefaces_resource/2.0.0.RC/jquery/plugins/uploadify/cancel.png',formId:'j_idt15',fileDataName:'documentToUpload',multi:false,auto:false,update:'messages',fileExt:'*.doc;*.docx;*.odt;*.pdf',fileDesc:'Dokumente',sizeLimit:1073741824});
});
</script><input type="file" id="documentToUpload" name="documentToUpload" /><a href="javascript:documentToUpload_widget.upload();">Upload</a> | <a href="javascript:documentToUpload_widget.clear();">Clear</a><input type="submit" name="j_idt19" value="" />
</pre>
<p><label for="title">
Titel des Dokuments</label><input id="title" type="text" name="title" />
</p>
</div>
<div>
<h2>2. Art des Dokumentes festlegen</h2>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p><table id="type">
.<tr>
<td>
<input type="radio" name="type" id="type:0" value="0" /><label for="type:0"> Zusammenfassung</label></td>
<td>
<input type="radio" name="type" id="type:1" value="1" /><label for="type:1"> Klausur</label></td>
<td>
<input type="radio" name="type" id="type:2" value="2" /><label for="type:2"> Hausuebung</label></td>
<td>
<input type="radio" name="type" id="type:3" value="3" /><label for="type:3"> Mitschrift</label></td>
.</tr>
</table>
</div>
<div>
<h2>3. Dokument zuordnen</h2>
<select>
<option value="#">Uni</option>
<option value="tuwien">TU Wien</option>
<option value="wuwien">WU Wien</option>
<option value="uniwien">UNI Wien</option>
<option value="meduniwien">MedUni Wien</option>
</select>
<br />
<select>
<option value="#">Studienrichtung</option>
<option>....</option>
<option>....</option>
<option>....</option>
</select>
<br />
<select>
<option value="#">Kurs</option>
<option>....</option>
<option>....</option>
<option>....</option>
<option>....</option>
</select>
<br />
<select>
<option value="#">Professor</option>
<option>....</option>
<option>....</option>
<option>....</option>
<option>....</option>
</select>
<br /><input type="submit" name="j_idt31" value="DO SOMETHING!" />
</div><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="-4522075482166600990:-9047861676398256697" autocomplete="off" />
</form>
</div>
<div id="header">
<h2>Skripts - Meine Lernunterlagen</h2>
<!--<ul>-->
<!--<li><a href="#">Top Nav Link</a></li>-->
<!--<li><a href="#">Top Nav Link</a></li>-->
<!--<li><a href="#">Top Nav Link</a></li>-->
<!--<li><a href="#">Top Nav Link</a></li>-->
<!--<li><a href="#">Top Nav Link</a></li>-->
<!--<li><a href="#">Top Nav Link</a></li>-->
<!--</ul>-->
<div id="topInfo">
<form id="j_idt35" name="j_idt35" method="post" action="/skriptum/upload;jsessionid=5b72e6342ab68e807583a814ae28" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt35" value="j_idt35" />
Hallo Gast |
<a href="/skriptum/register;jsessionid=5b72e6342ab68e807583a814ae28" id="j_idt35:j_idt38">registrieren</a> |
<a href="/skriptum/login;jsessionid=5b72e6342ab68e807583a814ae28" id="j_idt35:j_idt41">einloggen</a> |
0 Artikel im <a href="/skriptum/basket;jsessionid=5b72e6342ab68e807583a814ae28" id="j_idt35:j_idt44">Warenkorb</a><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="-4522075482166600990:-9047861676398256697" autocomplete="off" />
</form>
</div>
</div>
<div id="header2">
<ul>
<li><a href="/skriptum">Home</a></li>
<li><a href="/skriptum/mycourses;jsessionid=5b72e6342ab68e807583a814ae28" id="j_idt57">Meine Kurse</a>
</li>
<li><a href="/skriptum/upload;jsessionid=5b72e6342ab68e807583a814ae28" id="j_idt60">Upload</a></li>
<li><a href="/skriptum/firstSteps;jsessionid=5b72e6342ab68e807583a814ae28" id="j_idt63">Erste Schritte</a></li>
</ul>
...
so there gets no exception thrown, but also no event is triggered on the server side.
If I try to upload a bigger file ( > 7MB ) from the /upload, no error gets thrown but also nothing is rendered, no event is fired and nothing is returned from the POST done by the flash-thing:
- Code:
POST /skriptum/upload;jsessionid=56e7c11d28a245b1de5b4ecee5bd HTTP/1.1
Host: localhost:8080
Accept: */*
User-Agent: Shockwave Flash
Connection: Keep-Alive
Cache-Control: no-cache
Content-Length: 7196943
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----------------------------507599e9d180
HTTP/1.1 100 Continue
------------------------------507599e9d180
Content-Disposition: form-data; name="Filename"
Lou Paget - Der Perfekte Liebhaber.pdf
------------------------------507599e9d180
Content-Disposition: form-data; name="j_idt15"
j_idt15
------------------------------507599e9d180
Content-Disposition: form-data; name="folder"
/skriptum/
------------------------------507599e9d180
Content-Disposition: form-data; name="primefacesAjaxRequest"
true
------------------------------507599e9d180
Content-Disposition: form-data; name="update"
messages
------------------------------507599e9d180
Content-Disposition: form-data; name="fileext"
*.doc;*.docx;*.odt;*.pdf
------------------------------507599e9d180
Content-Disposition: form-data; name="javax.faces.ViewState"
-6912964522790549731:-6598567267547027095
------------------------------507599e9d180
Content-Disposition: form-data; name="documentToUpload"; filename="Lou Paget - Der Perfekte Liebhaber.pdf"
Content-Type: application/octet-stream
%PDF-1.4
%....
986 0 obj
<<
/Linearized 1
/O 989
/H [ 900 2031 ]
/L 7195763
.... LOTS OF DATA .....
0007174248 00000 n
0007174479 00000 n
trailer
<<
/Size 986
/ID[<44ad8f635d3a92c80375d16634b88e5f><aa3d6473baa8794ec7b1384bf40e4d56>]
>>
startxref
173
%%EOF
------------------------------507599e9d180
Content-Disposition: form-data; name="Upload"
Submit Query
------------------------------507599e9d180--
HERE IT STOPS, NOTHING IS RETURNED FROM THE SERVER
I'm not sure whats going wrong here.. any help appreciated!