Topic
  • 2 replies
  • Latest Post - ‏2013-05-01T18:54:15Z by VB3C_Wendy_Raschke
SystemAdmin
SystemAdmin
590 Posts

Pinned topic Wink error parsing multipart form-data with BufferedInMultiPart on WAS 8.5

‏2013-04-04T14:16:45Z |
I am trying to use the BufferedInMultiPart for multipart/form-data so I can see the name from the form of each file. If I include the content-type: multipart/form-data I get this: "Error 500: java.lang.StringIndexOutOfBoundsException". If I remove it, it works fine. Same works for my real rest service that is working with all the parts just fine, but fails the same as this small test if I include the content-type.
I did find this https://issues.apache.org/jira/browse/WINK-371 but is this what I am seeing? Sending from windows using any rest client and receiving on linux. WAS 8.5.0.1
Anyone know of a work around?
Java file:
package com.rest.test;

import org.apache.wink.common.model.multipart.BufferedInMultiPart;

import javax.ws.rs.*;
import javax.ws.rs.core.Application;
import java.util.HashSet;
import java.util.Set;

@ApplicationPath("rest")
@Path("/multipart")
public class MultipartResource extends Application
{
@Override
public Set<Class<?>> getClasses()
{
Set<Class<?>> classes = new HashSet<Class<?>>();
classes.add(MultipartResource.class);
return classes;
}

@GET
@Produces({"text/plain", "text/html", "application/xml"})
public String get()
{
return "The get works";
}

@POST
@Consumes({"multipart/form-data", "multipart/mixed"})
@Produces({"text/plain", "text/html", "application/xml"})
public String post(BufferedInMultiPart bimp)
{
return "The post works";
}
}

web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="MultipartTest" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

<display-name>MultipartTest</display-name>

<servlet>
<servlet-name>MultipartTest</servlet-name>
<servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.rest.test.MultipartResource</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>MultipartTest</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>MultipartTest</groupId>
<artifactId>MultipartTest</artifactId>
<version>1.0</version>
<packaging>war</packaging>

<dependencies>
<dependency>
<groupId>org.apache.wink</groupId>
<artifactId>wink-server</artifactId>
<version>1.2.1-incubating</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
  • SystemAdmin
    SystemAdmin
    590 Posts

    Re: Wink error parsing multipart form-data with BufferedInMultiPart on WAS 8.5

    ‏2013-04-05T12:46:29Z  
    Wiztools sets the boundary and content-type automatically if you leave it blank. If you fill it in or try to set your own boundary it ignores it and still uses it own, which causes a problem. No problem with websphere. Websphere also only seems to likes a-zA-Z0-9 and dashes in the boundary.
  • VB3C_Wendy_Raschke
    VB3C_Wendy_Raschke
    14 Posts

    Re: Wink error parsing multipart form-data with BufferedInMultiPart on WAS 8.5

    ‏2013-05-01T18:54:15Z  
    Wiztools sets the boundary and content-type automatically if you leave it blank. If you fill it in or try to set your own boundary it ignores it and still uses it own, which causes a problem. No problem with websphere. Websphere also only seems to likes a-zA-Z0-9 and dashes in the boundary.

    Hi, I've only seen this post just now. I'm not sure if you have resolved your issue. Was this the exception you were seeing?

    java.lang.StringIndexOutOfBoundsException
    at java.lang.String.substring(String.java:1092)
    at org.apache.wink.common.internal.providers.multipart.MultiPartParser.parseHeaders(MultiPartParser.java:264)
    at org.apache.wink.common.internal.providers.multipart.MultiPartParser.nextPart(MultiPartParser.java:109)
    at org.apache.wink.common.model.multipart.InMultiPart.hasNext(InMultiPart.java:83)

    ....
     

    Are you saying that if you run your client application on WebSphere, then the problem does not occur?