Upload started ...Server error HTTP/1.1 500 Internal Server

Upload core product.
Post Reply
raychamp
Posts: 18
Joined: Wed May 12, 2010 2:03 pm

Upload started ...Server error HTTP/1.1 500 Internal Server

Post by raychamp »

Uploading : BioAGENT Pre- and Production Tracker.xlsx
(11,211 bytes)
Upload started ...Server error HTTP/1.1 500 Internal Server Error
--------------------------------------------------

I continually get this error.
I am trying to deploy to Tomcat 6 on my machine(localhost).
I am trying to recreate folders/subfolders on server.
I beleive I have correctly modified the code for recreate folders/subfolders.
The url is correct.
Can someone give me suggestions? I am at wits end. :?

process.jsp

Code: Select all

<%@ page language="java" import="jfileupload.jspupload.*,java.util.*,java.io.*"%>
<%@ page errorPage="ExceptionHandler.jsp"%>
<!-- StrutsDemoApp-->
<% String directory = "c:/uploads"; %>
<% String tmpdirectory = "c:/uploads/tmp"; %>
<% boolean createsubfolders = true; %>
<% boolean allowresume = true; %>
<% boolean allowoverwrite = true; %>
<% String encoding = "ISO-8859-1"; %>
<% boolean keepalive = false; %>

<jsp:useBean id="upBean" scope="page" class="jfileupload.jspupload.FileUploadBean">
	<jsp:setProperty name="upBean" property="folderstore" value="<%= directory %>" />
	<jsp:setProperty name="upBean" property="parsertmpdir" value="<%= tmpdirectory %>" />
	<jsp:setProperty name="upBean" property="filesizelimit" value="99999999999"/>
	<jsp:setProperty name="upBean" property="overwrite" value="<%= allowoverwrite %>" />
	<jsp:setProperty name="upBean" property="dump" value="true" />
</jsp:useBean>

<%
	//request.setCharacterEncoding(encoding);
	//response.setContentType("text/html; charset="+encoding);
	String method = request.getMethod();
	// Head processing to support resume and overwrite features.
	if (method.equalsIgnoreCase("head"))
	{
		String filename = request.getHeader("relativefilename");
		if (filename == null) filename = request.getHeader("filename");
		if (filename != null)
		{
			if (keepalive == false) response.setHeader("Connection", "close");
			String account = request.getHeader("account");
			if (account == null) account = "";
			else if (!account.startsWith("/")) account = "/" + account;
			File fhead = new File(directory + account + "/" + filename);
			if (fhead.exists())
			{
				response.setHeader("size", String.valueOf(fhead.length()));
				String checksum = request.getHeader("checksum");
				if ((checksum != null) && (checksum.equalsIgnoreCase("crc")))
				{
					long crc = upBean.computeCRC32(fhead, -1);
					if (crc != -1) response.setHeader("checksum", String.valueOf(crc));
				} 
				else if ((checksum != null) && (checksum.equalsIgnoreCase("md5")))
				{
					String md5 = upBean.hexDump(upBean.computeMD5(fhead, -1)).toLowerCase();
					if ((md5 != null) && (!md5.equals(""))) response.setHeader("checksum", md5);
				}
			} 
			else response.sendError(HttpServletResponse.SC_NOT_FOUND);
			return;
		}
	}
%>
<html>
<head>
<title>Upload file: JSPScript sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=<%= encoding %>">
</head>
<body>
<ul>
	<%
		if (MultipartFormDataRequest.isMultipartFormData(request))
		{
			// Parse multipart HTTP POST request.
			MultipartFormDataRequest mrequest = null;
			try
			{
				mrequest = new MultipartFormDataRequest(request, null, -1, MultipartFormDataRequest.CFUPARSER, encoding, allowresume);
			} 
			catch (Exception e)
			{
				// Cancel current upload (e.g. Stop transfer)
				// Only if allowresume = false
			}
			String todo = null;
			if (mrequest != null) todo = mrequest.getParameter("todo");
			if ((todo != null) && (todo.equalsIgnoreCase("upload")))
			{
				String account = mrequest.getParameter("account");
				if (account == null) account = "";
				else if (!account.startsWith("/")) account = "/" + account;
				upBean.setFolderstore(directory + account);
				Hashtable files = mrequest.getFiles();
                                //Added by ray
                                int filesLength = files.size();
                                if ((files != null) && (!files.isEmpty()))
				{
					UploadFile file = (UploadFile) files.get("uploadfile");
					if (file != null) out.println("<li>Form field: uploadfile" + "<BR> Uploaded file: " + file.getFileName() + " (" + file.getFileSize() + " bytes)" + "<BR> Content Type: " + file.getContentType());
					// Folders and subfolders creation support.
					String relative = mrequest.getParameter("relativefilename");
                                        System.out.println("relative = "+ relative);
					if ((createsubfolders == true) && (relative != null))
					{
						int inda = relative.length();
						int indb = file.getFileName().length();
						if (inda > indb)
						{
							String subfolder = relative.substring(0, (inda - indb) - 1);
							subfolder = subfolder.replace('\\', '/').replace('/', java.io.File.separatorChar);
							upBean.setFolderstore(directory + account + java.io.File.separator + subfolder);
						}
					}
					if (keepalive == false) response.setHeader("Connection", "close");
					// Chunks recomposion support.
					String chunkidStr = mrequest.getParameter("chunkid");
					String chunkamountStr = mrequest.getParameter("chunkamount");
					String chunkbaseStr = mrequest.getParameter("chunkbase");
					if ((chunkidStr != null) && (chunkamountStr != null) && (chunkbaseStr != null))
					{
						// Always overwrite chunks.
						upBean.store(mrequest, "uploadfile");
						int chunkid = Integer.parseInt(chunkidStr);
						int chunkamount = Integer.parseInt(chunkamountStr);
						if (chunkid == chunkamount)
						{
							// recompose file.
							String fname = upBean.getFolderstore() + java.io.File.separator + chunkbaseStr;
							File fread = new File(fname);
							if (fread.canRead() && (upBean.getOverwrite() == false)) fname = fname + "." + System.currentTimeMillis();
							FileOutputStream fout = new FileOutputStream(fname);
							byte[] buffer = new byte[4096];
							for (int c = 1; c <= chunkamount; c++)
							{
								File filein = new File(upBean.getFolderstore() + java.io.File.separator + chunkbaseStr + "." + c);
								FileInputStream fin = new FileInputStream(filein);
								int read = -1;
								while ((read = fin.read(buffer)) > 0) fout.write(buffer, 0, read);
								fin.close();
								filein.delete();
							}
							fout.close();
						}
					} 
					else upBean.store(mrequest, "uploadfile");
					upBean.setFolderstore(directory + account);
				} 
				else
				{
					String emptydirectory = mrequest.getParameter("emptydirectory");
					if ((emptydirectory != null) && (!emptydirectory.equals("")))
					{
						File dir = new File(directory + account + "/" + emptydirectory);
						dir.mkdirs();
					}
					out.println("<li>No uploaded files");
				}
			} 
			else out.println("<BR> todo=" + todo);
		}
	%>
</ul>
<form method="post" action="process.jsp" name="upform" enctype="multipart/form-data">
<br>
<table width="60%" border="0" cellspacing="1" cellpadding="1" align="center">
	<tr>
		<td align="left"><b>Select a file to upload:</b></td>
	</tr>
	<tr>
		<td align="left"><input type="hidden" name="todo" value="upload">
		<input type="file" name="uploadfile" size="50"></td>
	</tr>
	<tr>
		<td align="left"><input type="submit" name="Submit" value="Upload"> <input type="reset" name="Reset" value="Cancel"></td>
	</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><font size="-1" face="Courier New, Courier, mono"><a href="http://www.jfileupload.com" target="_blank">JFileUpload</a></font></p>
</form>
</body>
</html>
applet_http.js

Code: Select all

<!--
var _info = navigator.userAgent;
var _ns = false;
var _ns6 = false;
var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
if (_info.indexOf("Opera") > 0) _ie = false;
var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0) || (_info.indexOf("AIX") > 0) || (_info.indexOf("OS/2") > 0) || (_info.indexOf("IRIX") > 0)));
var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0));
if (_ie == true) {
  document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="550" HEIGHT="250" NAME="fileupload" codebase="http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,4,0,0">');
}
else if (_ns == true && _ns6 == false) { 
  // BEGIN: Update parameters below for NETSCAPE 3.x and 4.x support.
  document.write('<EMBED ');
  document.write('type="application/x-java-applet;version=1.4" ');
  document.write('CODE="jfileupload.upload.client.MApplet.class" ');
  document.write('JAVA_CODEBASE="./" ');
  document.write('ARCHIVE="lib/jfileupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar" ');
  document.write('NAME="fileupload" ');
  document.write('WIDTH="250" ');
  document.write('HEIGHT="250" ');
  //document.write('url="http://192.168.5.24:8080/JFileUploadHTTP/process.jsp" ');
 // document.write('url="http://12.144.92.205:8080/JFileUploadHTTP/process.jsp" ');
  document.write('url="http://localhost:8087/StrutsDemoApp/process.jsp" ');
  document.write('paramfile="uploadfile" ');
  document.write('param1="todo" ');
  document.write('value1="upload" ');
  document.write('folderdepth="-1" ');
  document.write('param2="relativefilename" ');
  document.write('value2="true" ');
  document.write('mode="http" ');
  document.write('scriptable=true ');
  document.write('resources="i18n"');
  document.write('hidebar="false"');
  document.writeln('pluginspage="http://java.sun.com/products/plugin/index.html#download"><NOEMBED>');
  // END
}
else {
  document.writeln('<APPLET CODE="jfileupload.upload.client.MApplet.class" JAVA_CODEBASE="./" ARCHIVE="lib/jfileupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar" WIDTH="250" HEIGHT="250" NAME="fileupload">');
}
// BEGIN: Update parameters below for INTERNET EXPLORER, FIREFOX, SAFARI, OPERA, MOZILLA, NETSCAPE 6+ support.
document.writeln('<PARAM NAME=CODE VALUE="jfileupload.upload.client.MApplet.class">');
document.writeln('<PARAM NAME=CODEBASE VALUE="./">');
document.writeln('<PARAM NAME=ARCHIVE VALUE="lib/jfileupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar">');
document.writeln('<PARAM NAME=NAME VALUE="fileupload">');
document.writeln('<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">');
document.writeln('<PARAM NAME="scriptable" VALUE="true">');
//document.writeln('<PARAM NAME="url" VALUE="http://192.168.5.24:8080/JFileUploadHTTP/process.jsp">');
//document.writeln('<PARAM NAME="url" VALUE="http://12.144.92.205:8080/JFileUploadHTTP/process.jsp">');
//document.writeln('<PARAM NAME="url" VALUE="http://12.144.92.205:8080/StrutsDemoApp/process.jsp">');
document.writeln('<PARAM NAME="url" VALUE="http://localhost:8087/StrutsDemoApp/process.jsp">');
document.writeln('<PARAM NAME="paramfile" VALUE="uploadfile">');
document.writeln('<PARAM NAME="param1" VALUE="todo">');
document.writeln('<PARAM NAME="value1" VALUE="upload">');
document.writeln('<PARAM NAME="folderdepth" VALUE="-1">');
document.writeln('<PARAM NAME="param2" VALUE="relativefilename">');
document.writeln('<PARAM NAME="value2" VALUE="true">');
document.writeln('<PARAM NAME="mode" VALUE="http">');
document.writeln('<PARAM NAME="resources" VALUE="i18n">');
document.writeln('<PARAM NAME="hidebar" VALUE="false">');

// END
if (_ie == true) {
  document.writeln('</OBJECT>');
}
else if (_ns == true && _ns6 == false) {
  document.writeln('</NOEMBED></EMBED>');
}
else {
  document.writeln('</APPLET>');
}
//-->

User avatar
support
Posts: 1503
Joined: Sun Jan 27, 2008 6:19 pm

Re: Upload started ...Server error HTTP/1.1 500 Internal Server

Post by support »

Are you able to run the JSP in browser and upload a file? I mean without the applet.

raychamp
Posts: 18
Joined: Wed May 12, 2010 2:03 pm

Re: Upload started ...Server error HTTP/1.1 500 Internal Server

Post by raychamp »

No I get
java.lang.NoSuchMethodError: jfileupload.jspupload.parsing.CfuFileItemFactory.getFileCleaningTracker()Lorg/apache/commons/io/FileCleaningTracker;

raychamp
Posts: 18
Joined: Wed May 12, 2010 2:03 pm

Re: Upload started ...Server error HTTP/1.1 500 Internal Server

Post by raychamp »

I enabled Java Console to get more debug infoemation. Here is what I get:
Java Plug-in 1.6.0_18
Using JRE version 1.6.0_18-b07 Java HotSpot(TM) Client VM
User home directory = C:\Users\CMEBio2

----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

[INFO] MApplet - JFileUpload 2.6 Build FINAL.001
[DEBUG] DefaultHttpParams - Set parameter http.useragent = Jakarta Commons-HttpClient/3.1
[DEBUG] DefaultHttpParams - Set parameter http.protocol.version = HTTP/1.1
[DEBUG] DefaultHttpParams - Set parameter http.connection-manager.class = class org.apache.commons.httpclient.SimpleHttpConnectionManager
[DEBUG] DefaultHttpParams - Set parameter http.protocol.cookie-policy = default
[DEBUG] DefaultHttpParams - Set parameter http.protocol.element-charset = US-ASCII
[DEBUG] DefaultHttpParams - Set parameter http.protocol.content-charset = ISO-8859-1
[DEBUG] DefaultHttpParams - Set parameter http.method.retry-handler = org.apache.commons.httpclient.DefaultHttpMethodRetryHandler@c837cd
[DEBUG] DefaultHttpParams - Set parameter http.dateparser.patterns = [EEE, dd MMM yyyy HH:mm:ss zzz, EEEE, dd-MMM-yy HH:mm:ss zzz, EEE MMM d HH:mm:ss yyyy, EEE, dd-MMM-yyyy HH:mm:ss z, EEE, dd-MMM-yyyy HH-mm-ss z, EEE, dd MMM yy HH:mm:ss z, EEE dd-MMM-yyyy HH:mm:ss z, EEE dd MMM yyyy HH:mm:ss z, EEE dd-MMM-yyyy HH-mm-ss z, EEE dd-MMM-yy HH:mm:ss z, EEE dd MMM yy HH:mm:ss z, EEE,dd-MMM-yy HH:mm:ss z, EEE,dd-MMM-yyyy HH:mm:ss z, EEE, dd-MM-yyyy HH:mm:ss z]
[DEBUG] HttpClient - Java version: 1.6.0_18
[DEBUG] HttpClient - Java vendor: Sun Microsystems Inc.
[DEBUG] HttpClient - Java class path: C:\\PROGRA~2\\Java\\jre6\\classes
[DEBUG] HttpClient - Operating system name: Windows Vista
[DEBUG] HttpClient - Operating system architecture: x86
[DEBUG] HttpClient - Operating system version: 6.0
[DEBUG] HttpClient - SUN 1.6: SUN (DSA key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom; X.509 certificates; JKS keystore; PKIX CertPathValidator; PKIX CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; JavaLoginConfig Configuration)
[DEBUG] HttpClient - SunRsaSign 1.5: Sun RSA signature provider
[DEBUG] HttpClient - SunJSSE 1.6: Sun JSSE provider(PKCS12, SunX509 key/trust factories, SSLv3, TLSv1)
[DEBUG] HttpClient - SunJCE 1.6: SunJCE Provider (implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, Diffie-Hellman, HMAC)
[DEBUG] HttpClient - SunJGSS 1.0: Sun (Kerberos v5, SPNEGO)
[DEBUG] HttpClient - SunSASL 1.5: Sun SASL provider(implements client mechanisms for: DIGEST-MD5, GSSAPI, EXTERNAL, PLAIN, CRAM-MD5; server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5)
[DEBUG] HttpClient - XMLDSig 1.0: XMLDSig (DOM XMLSignatureFactory; DOM KeyInfoFactory)
[DEBUG] HttpClient - SunPCSC 1.6: Sun PC/SC provider
[DEBUG] HttpClient - SunMSCAPI 1.6: Sun's Microsoft Crypto API provider
[DEBUG] DefaultHttpParams - Set parameter http.useragent = JFileUpload
[DEBUG] DefaultHttpParams - Set parameter http.protocol.element-charset = ISO-8859-1
[DEBUG] DefaultHttpParams - Set parameter http.method.retry-handler = org.apache.commons.httpclient.DefaultHttpMethodRetryHandler@1bb5c09
[INFO] F - Auto-detect proxy settings (ps): DIRECT
[INFO] F - Auto-detect proxy settings : host = null
[INFO] F - Auto-detect proxy settings : port = -1
[INFO] HTTPUploadTransfer - Upload (POST) started : C:\Users\CMEBio2\Desktop\Ray Champion Activities.xlsx
[DEBUG] HttpConnection - Open connection to localhost:8087
[DEBUG] header - >> "POST /StrutsDemoApp/process.jsp HTTP/1.1[\r][\n]"
[DEBUG] HttpMethodBase - Adding Host request header
[DEBUG] header - >> "User-Agent: JFileUpload[\r][\n]"
[DEBUG] header - >> "Host: localhost:8087[\r][\n]"
[DEBUG] header - >> "Content-Length: 12280[\r][\n]"
[DEBUG] header - >> "Content-Type: multipart/form-data; boundary=EHM5Bf11NM0VQPQNb_DH86eN6GJ817oD4MV[\r][\n]"
[DEBUG] header - >> "[\r][\n]"
[DEBUG] EntityEnclosingMethod - Request body sent
[DEBUG] header - << "HTTP/1.1 500 Internal Server Error[\r][\n]"
[DEBUG] header - << "HTTP/1.1 500 Internal Server Error[\r][\n]"
[DEBUG] header - << "Server: Apache-Coyote/1.1[\r][\n]"
[DEBUG] header - << "Set-Cookie: JSESSIONID=E56D1876B22D8D0A3FAC012D49025587; Path=/StrutsDemoApp[\r][\n]"
[DEBUG] header - << "customerror: java.lang.NoSuchMethodError: jfileupload.jspupload.parsing.CfuFileItemFactory.getFileCleaningTracker()Lorg/apache/commons/io/FileCleaningTracker;[\r][\n]"
[DEBUG] header - << "Content-Type: text/html[\r][\n]"
[DEBUG] header - << "Content-Length: 2539[\r][\n]"
[DEBUG] header - << "Date: Fri, 14 May 2010 15:12:34 GMT[\r][\n]"
[DEBUG] header - << "Connection: close[\r][\n]"
[DEBUG] header - << "[\r][\n]"
[DEBUG] HttpMethodBase - Cookie accepted: "$Version=0; JSESSIONID=E56D1876B22D8D0A3FAC012D49025587; $Path=/StrutsDemoApp"
[INFO] HTTPUploadTransfer - Upload Status code = 500
[DEBUG] HttpMethodBase - Should close connection in response to directive: close
[DEBUG] HttpConnection - Releasing connection back to connection manager.
[INFO] HTTPUploadTransfer - Upload failed

raychamp
Posts: 18
Joined: Wed May 12, 2010 2:03 pm

Re: Upload started ...Server error HTTP/1.1 500 Internal Server

Post by raychamp »

I have keyed in on the following
[DEBUG] header - << "customerror: java.lang.NoSuchMethodError: jfileupload.jspupload.parsing.CfuFileItemFactory.getFileCleaningTracker()Lorg/apache/commons/io/FileCleaningTracker;[\r][\n]"
Based on this error I deleted the commons - io from the lib directories and reinstalled it.
It still doesn't work.

raychamp
Posts: 18
Joined: Wed May 12, 2010 2:03 pm

Re: Upload started ...Server error HTTP/1.1 500 Internal Server

Post by raychamp »

Problem solved. I was using Netbeans IDE to build the application with Struts. I noticed that there were two copies of commons-io.jar and commons-fileupload.jar in my lbrary. I removed the Struts Libraries from Netbeans and installed just the Struts jars from Apache. I then made sure that there were only one copy each of commons-io.jar and commons-fileupload.jar, the ones that come with JFileupload. Cleaned, build and deploy to tomcat server and it works! :D

User avatar
support
Posts: 1503
Joined: Sun Jan 27, 2008 6:19 pm

Re: Upload started ...Server error HTTP/1.1 500 Internal Server

Post by support »

Ok, fine

Post Reply