Search code examples
javaservletsweblogic-10.xweblogic11g

HttpServletRequest inputstream empty on Weblogic 10.3


I'm using the Apache Commons FileUpload to receive file uploads. The below method works fine for all of the application servers tested, including Weblogic 12.1.3, except for Weblogic 10.3.6.

The parseRequest method is returning an empty list which indicates that the HttpServletRequest inputstream is empty. Just looking for how I can get this working on a Weblogic 10.3.6 server?

@POST
@Path("upload/{environment}/{queueName}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
public Message putQueueFile(
        @PathParam("environment") String environmentName,
        @PathParam("queueName") String queueName,
        @Context HttpServletRequest req) {

    if (ServletFileUpload.isMultipartContent(req)) {
        log.debug("putQueueFile:: Multipart form submission received");
        // Create a factory for disk-based file items 
        DiskFileItemFactory  fileItemFactory = createDiskFileItemFactory(req.getSession().getServletContext());
        ServletFileUpload uploadHandler = new ServletFileUpload(fileItemFactory);
        uploadHandler.setFileSizeMax(MAX_UPLOAD_FILE_SIZE);

        try {
            /*
             * Parse the request
             */
            List items = uploadHandler.parseRequest(req);
            log.debug(String.format("putQueueFile:: Looping through %d items", items.size()));

Solution

  • Finally got to the bottom of it and it was an issue with the web.xml file we were using for 10.3. Specifically we had enabled jersey logging for requests with

    <init-param>
        <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
        <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
    </init-param>
    

    This was causing the request to be read and therefore causing an empty input stream. Once the logging for the requests was disabled the error was resolved.