Hi,
I'm developing a JIRA plugin where I want to import issues by uploading an XML file. It works absolutely fine on my localhost, but I'm running in to a strange problem on the company test server. When I try to run the plugin I get the "Oops, you've found a dead link" error.
I found out that the ServletFileUpload in line 6 is causing this problem. Without it, the error disappears but I need it to process the XML files.
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (isMultipart) { FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); try { List<FileItem> items = upload.parseRequest(request); Iterator<FileItem> iterator = items.iterator(); while (iterator.hasNext()) { FileItem item = iterator.next(); if (!item.isFormField()) { IssueExchange ix = JAXB.unmarshal(item.getInputStream(), IssueExchange.class); for(VectorIssue vectorIssue : ix.getIssues()){ importIssue(vectorIssue); } } } response.setContentType("text/html;charset=UTF-8"); response.getWriter().write("Successfully imported."); } catch (FileUploadException e) { e.printStackTrace(); } } }
Does anyone know what the problem might be? Could it be, that the test server has some restrictions which the localhost doesn't have?
Thanks in advance,
Andreas
Community moderators have prevented the ability to post new answers.
Check the logs to find out the actual error. Maybe there is no access to tmp directory on the test machine?
Thanks for your answer.
I checked the logs and there were no errors. Also the temp directory seemed not to be the problem. The actual upload worked and I could get the input stream from the request.
I build a workaround where I go through the input stream with the BufferedReader to filter the form fields out, so that i have only the XML file in the end.
Strange thing is, that I just can place the critical lines anywhere in the correspondent class, without calling it, to crash the whole thing:
private void test(){ FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.