Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Jira Plugin ServletFileUpload Dead Link Problem

Andreas Razmyslov May 23, 2016

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

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 23, 2016

Check the logs to find out the actual error. Maybe there is no access to tmp directory on the test machine?

Andreas Razmyslov June 1, 2016

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);
}
TAGS
AUG Leaders

Atlassian Community Events