The interface:

  @POST

  @ClientResponseType(entityType = JAXBModule.class)

  @Path("/upload")

  @Consumes(MediaType.MULTIPART_FORM_DATA)

  @Produces(MediaType.APPLICATION_XML)

  public Response upload(@MultipartForm FileUploadForm form);


The FileUploadForm class


public class FileUploadForm {


  @FormParam("file")

  @PartType(MediaType.APPLICATION_OCTET_STREAM)

  private InputStream data;


  @FormParam("user")

  @PartType(MediaType.TEXT_PLAIN)

  private String user;


  @FormParam("password")

  @PartType(MediaType.TEXT_PLAIN)

  private String password;


  @FormParam("filename")

  @PartType(MediaType.TEXT_PLAIN)

  private String filename;


  public FileUploadForm() {

  }


  public InputStream getData() {

    return data;

  }


  public void setData(InputStream data) {

    this.data = data;

  }


  public String getUser() {

    return user;

  }


  public void setUser(String user) {

    this.user = user;

  }


  public String getPassword() {

    return password;

  }


  public void setPassword(String password) {

    this.password = password;

  }


  public String getFilename() {

    return filename;

  }


  public void setFilename(String filename) {

    this.filename = filename;

  }

The client:


ModuleArchiveService client = getArchiveService();

    FileUploadForm upload = new FileUploadForm();

    upload.setUser("gaby");

    upload.setPassword("pwd");

    upload.setFilename("hb-tsunami.rksh");

    String fileToUpload = "testdata/hb-tsunami.rksh";

    upload.setData(new FileInputStream(fileToUpload));

    Response response = client.upload(upload);


The error message:


javax.ws.rs.ProcessingException: Unable to invoke request

at 
org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.invoke(ApacheHttpClient4Engine.java:249)

at 
org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:407)

at 
org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:102)

at 
org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:62)

at com.sun.proxy.$Proxy26.upload(Unknown Source)

at 
nz.org.riskscape.archive.rest.LiveModuleArchiveServiceTest.testUploadFile(LiveModuleArchiveServiceTest.java:68)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)

at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Caused by: javax.ws.rs.ProcessingException: could not find writer for 
content-type multipart/form-data type: 
nz.org.riskscape.archive.rest.domain.FileUploadForm

at 
org.jboss.resteasy.core.interception.ClientWriterInterceptorContext.throwWriterNotFoundException(ClientWriterInterceptorContext.java:40)

at 
org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.getWriter(AbstractWriterInterceptorContext.java:138)

at 
org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:117)

at 
org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.aroundWriteTo(GZIPEncodingInterceptor.java:100)

at 
org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:122)

at 
org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.writeRequestBody(ClientInvocation.java:341)

at 
org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.writeRequestBodyToOutputStream(ApacheHttpClient4Engine.java:520)

at 
org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.buildEntity(ApacheHttpClient4Engine.java:486)

at 
org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.loadHttpMethod(ApacheHttpClient4Engine.java:385)

at 
org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.invoke(ApacheHttpClient4Engine.java:243)

... 30 more



This was working fine before the migration. I am obviously missing something :-(

Gaby


--
Dr Gabriella Turek
Sr. Software Engineer, Systems Development Team
NIWA Auckland, New Zealand
Tel: +64 9 3754645
www.niwa.co.nz
NIWA - Enhancing the benefit of New Zealand’s natural resources.

--
Please consider the environment before printing this email.
NIWA is the trading name of the National Institute of Water & Atmospheric 
Research Ltd.
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users

Reply via email to