[Resteasy-users] Issues updating from 3.0.6 to 3.0.9 and Tomcat 8

2015-07-09 Thread Gabriella Turek
I updated my RestEasy libraries from 3.0.6 to 3.0.9 on Tomcat 8
and I get the error
failed to execute
javax.ws.rs.NotFoundException: Could not find resource for full path: 
http://host/archive/modules/0.3.1

where my web.xml file looks like


?xml version=1.0 encoding=UTF-8?

web-app xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; 
xmlns=http://java.sun.com/xml/ns/javaee; xmlns:web=http

://java.sun.com/xml/ns/javaee/web-app_3_0.xsd 
xsi:schemaLocation=http://java.sun.com/xml/ns/javaee http://java.sun.com

/xml/ns/javaee/web-app_3_0.xsd version=3.0

  display-nameriskscapemr_rest/display-name

  listener

listener-class

org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap

/listener-class

  /listener

  servlet

servlet-nameResteasy/servlet-name


servlet-classorg.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher/servlet-class

  /servlet

  servlet-mapping

servlet-nameResteasy/servlet-name

url-pattern/*/url-pattern

  /servlet-mapping

  context-param

param-nameresteasy.scan/param-name

param-valuetrue/param-value

  /context-param

  context-param

param-nameresteasy.servlet.mapping.prefix/param-name

param-value//param-value

  /context-param

/web-app


Thanx

Gaby
--
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


[Resteasy-users] Another issue while migrating form RESTEasy 2.4 to 3.0.5 : file upload

2013-12-02 Thread Gabriella Turek
)

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=84349351iu=/4140/ostg.clktrk___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Replacing ProxyFactory with RestEasyWebTarget does not work

2013-11-26 Thread Gabriella Turek
No, I've tried that, it does not work. I get the following error:

java.lang.ClassCastException: javax.xml.bind.JAXBElement cannot be cast to
nz.org.riskscape.license.rest.domain.LicenseList
at
nz.org.riskscape.license.rest.RiskScapeLicenseServiceTest.testGetExpiredLic
enses(RiskScapeLicenseServiceTest.java:102)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:5
7)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp
l.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)


--
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.


Date: Tue, 26 Nov 2013 15:51:56 -0500
From: Bill Burke bbu...@redhat.com
Subject: Re: [Resteasy-users] Replacing ProxyFactory with
   RestEasyWebTarget does not work
To: resteasy-users@lists.sourceforge.net
Message-ID: 529509ec.3000...@redhat.com
Content-Type: text/plain; charset=windows-1252; format=flowed

This is a Resteasy Client - JAX-RS 2.0 mismatch migration problem.

Replace:

response.getEntity()

with:

response.readEntity(String.class);

replace String.class to whatever class you want to marshal to.
getEntity() returns null if you haven't unmarshalled anything with
readEntity().



On 11/26/2013 2:59 PM, Gabriella Turek wrote:
 After upgrading from Resteasy 2.4 to 3.0.5, none of my client calls work
 anymore. The entity which I am expecting (as simple as a String) is
 always null. In debug mode I can see it being set in the Response object
 on the server side, but on the client side the entity in the Response is
 null.
 Here is an example call:

 The interface:

 |   /**
 * @return all expired licenses
 */
@GET
@ClientResponseType(entityType=  LicenseList.class)
@Path(/expired)
@Produces(MediaType.APPLICATION_XML)
public  Response  getExpiredLicenses();|

 The implementation:

 |   /**
 * @return all expired licenses
 */
@Override
public  Response  getExpiredLicenses()  {
  try  {
LicenseList  list=  LicensesDBUtil.getExpiredLicenses();
Response  resp=  Response.ok().entity(list).build();
return  resp;
  }  catch  (SQLException  e)  {
LOG.error(Error getting expired licenses :  +  e.getMessage());
return
Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).type
(MediaType.TEXT_PLAIN).build();
  }|

 The test call :

 |   @Test
public  void  testGetExpiredLicenses()  throws  Exception  {
  ResteasyClientBuilder  rsb=  new  ResteasyClientBuilder();
  ResteasyClient  rsc=  rsb.build();
  ResteasyWebTarget  target=  rsc.target(BASEURL);
  return  target.proxy(RiskScapeLicenseService.class);
  Response  response=  client.getExpiredLicenses();
  assertTrue(HttpResponseCodes.SC_OK==  response.getStatus());
  @SuppressWarnings(unchecked)
  JAXBElementLicenseList  element=  (JAXBElementLicenseList)
response.getEntity();
  LicenseList  list=  element.getValue();
  assertEquals(4,  list.getLicenses().size());
  for  (License  lic:  list.getLicenses())  {
assertTrue((new
Date()).after(DateUtils.parseDate(lic.getValidTo(),  new  String[]  {
-MM-dd  })));
  }
}|

 My web.xml file:

 |?xml version=1.0  encoding=UTF-8?
 web-app xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xmlns=http://java.sun.com/xml/ns/javaee;
xmlns:web=http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd;
xsi:schemaLocation=http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd;  version=2.5
display-nameriskscapelic_rest/display-name
listener
  listener-class
  org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
  /listener-class
/listener
servlet
  servlet-nameResteasy/servlet-name

servlet-classorg.jboss.resteasy.plugins.server.servlet.HttpServletDispa
tcher/servlet-class
/servlet
servlet-mapping
  servlet-nameResteasy/servlet-name
  url-pattern/*/url-pattern
/servlet-mapping
context-param
  param-nameresteasy.scan/param-name
  param-valuetrue/param-value
/context-param
context-param
  param-nameresteasy.servlet.mapping.prefix/param-name
  param-value//param-value
/context-param
 /web-app|

 The LicenseList class:

 |@XmlRootElement(name=  LicenseList)
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name=  licenseList,  propOrder=  {
  licenses
 })
 public  class  LicenseList  {

  @XmlElement(name=  Licenses,  required=  true)
  protected  ListLicense  licenses;

  /**
   * Gets the value of the licenses property.
   *
   * p
   * This accessor method returns a reference to the live list,
   * not a snapshot. Therefore any modification you make

Re: [Resteasy-users] Replacing ProxyFactory with RestEasyWebTarget does not work

2013-11-26 Thread Gabriella Turek

So, I've resolved my issue by updating my schema with jaxb:version=2.0
and regenerating
the jaxb classes. The tip off was Bill's mention of there being a
Resteasy Client - JAX-RS 2.0 mismatch migration problem
Cheers!
Gaby

On 27/11/13 10:00 AM, Gabriella Turek gabriella.tu...@niwa.co.nz
wrote:

No, I've tried that, it does not work. I get the following error:

java.lang.ClassCastException: javax.xml.bind.JAXBElement cannot be cast
to
nz.org.riskscape.license.rest.domain.LicenseList
  at
nz.org.riskscape.license.rest.RiskScapeLicenseServiceTest.testGetExpiredL
i
c
enses(RiskScapeLicenseServiceTest.java:102)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
:
5
7)
  at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
m
p
l.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)


--
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.


Date: Tue, 26 Nov 2013 15:51:56 -0500
From: Bill Burke bbu...@redhat.com
Subject: Re: [Resteasy-users] Replacing ProxyFactory with
 RestEasyWebTarget does not work
To: resteasy-users@lists.sourceforge.net
Message-ID: 529509ec.3000...@redhat.com
Content-Type: text/plain; charset=windows-1252; format=flowed

This is a Resteasy Client - JAX-RS 2.0 mismatch migration problem.

Replace:

response.getEntity()

with:

response.readEntity(String.class);

replace String.class to whatever class you want to marshal to.
getEntity() returns null if you haven't unmarshalled anything with
readEntity().



On 11/26/2013 2:59 PM, Gabriella Turek wrote:
 After upgrading from Resteasy 2.4 to 3.0.5, none of my client calls
work
 anymore. The entity which I am expecting (as simple as a String) is
 always null. In debug mode I can see it being set in the Response
object
 on the server side, but on the client side the entity in the Response
is
 null.
 Here is an example call:

 The interface:

 |   /**
 * @return all expired licenses
 */
@GET
@ClientResponseType(entityType=  LicenseList.class)
@Path(/expired)
@Produces(MediaType.APPLICATION_XML)
public  Response  getExpiredLicenses();|

 The implementation:

 |   /**
 * @return all expired licenses
 */
@Override
public  Response  getExpiredLicenses()  {
  try  {
LicenseList  list=  LicensesDBUtil.getExpiredLicenses();
Response  resp=  Response.ok().entity(list).build();
return  resp;
  }  catch  (SQLException  e)  {
LOG.error(Error getting expired licenses :  +
e.getMessage());
return
Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).ty
p
e
(MediaType.TEXT_PLAIN).build();
  }|

 The test call :

 |   @Test
public  void  testGetExpiredLicenses()  throws  Exception  {
  ResteasyClientBuilder  rsb=  new  ResteasyClientBuilder();
  ResteasyClient  rsc=  rsb.build();
  ResteasyWebTarget  target=  rsc.target(BASEURL);
  return  target.proxy(RiskScapeLicenseService.class);
  Response  response=  client.getExpiredLicenses();
  assertTrue(HttpResponseCodes.SC_OK==  response.getStatus());
  @SuppressWarnings(unchecked)
  JAXBElementLicenseList  element=  (JAXBElementLicenseList)
response.getEntity();
  LicenseList  list=  element.getValue();
  assertEquals(4,  list.getLicenses().size());
  for  (License  lic:  list.getLicenses())  {
assertTrue((new
Date()).after(DateUtils.parseDate(lic.getValidTo(),  new  String[]  {
-MM-dd  })));
  }
}|

 My web.xml file:

 |?xml version=1.0  encoding=UTF-8?
 web-app xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xmlns=http://java.sun.com/xml/ns/javaee;
xmlns:web=http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd;
xsi:schemaLocation=http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd;  version=2.5
display-nameriskscapelic_rest/display-name
listener
  listener-class

org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
  /listener-class
/listener
servlet
  servlet-nameResteasy/servlet-name

servlet-classorg.jboss.resteasy.plugins.server.servlet.HttpServletDis
p
a
tcher/servlet-class
/servlet
servlet-mapping
  servlet-nameResteasy/servlet-name
  url-pattern/*/url-pattern
/servlet-mapping
context-param
  param-nameresteasy.scan/param-name
  param-valuetrue/param-value
/context-param
context-param
  param-nameresteasy.servlet.mapping.prefix/param-name
  param-value//param-value
/context-param
 /web-app|

 The LicenseList class:

 |@XmlRootElement(name=  LicenseList)
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name=  licenseList,  propOrder=  {
  licenses
 })
 public  class  LicenseList  {

  @XmlElement(name=  Licenses

[Resteasy-users] How do I set proxy information when using a ProxyClient

2013-03-27 Thread Gabriella Turek
In a client call to my service,


MyService client = ProxyFactory.create(MyService.class, www.myservice.com);

Response response = client.doSomething();


I see no way to set proxy information when the client sits behind a proxy.

How do you set proxy information?

Thanx

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.
--
Own the Future-Intelreg; Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game 
on Steam. $5K grand prize plus 10 genre and skill prizes. 
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Error when executing a post request with a complex (List) object - solved

2013-01-23 Thread Gabriella Turek
I solved this problem as follows:
I handcrafted the class

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;

@XmlRootElement(name = ClientModules)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlSeeAlso(JAXBClientModuleInfo.class)
public class ClientModuleInfoList {
  @XmlElement(name = ModuleInfo, namespace =
http://archive.riskscape.org.nz;)
  private ListJAXBClientModuleInfo list;

  public ClientModuleInfoList() {
list = new ArrayListJAXBClientModuleInfo();
  }

  public ClientModuleInfoList(ListJAXBClientModuleInfo list) {
this.list = list;
  }

  public void setList(ListJAXBClientModuleInfo list) {
this.list = list;
  }

  public ListJAXBClientModuleInfo getList() {
return list;
  }
}


And modified the service spec:

@POST
  @ClientResponseType(entityType = JAXBModuleList.class)
  @Path(/updateStatus)
  @Consumes(MediaType.APPLICATION_XML)
  @Wrapped(element = list, namespace =
http://archive.riskscape.org.nz;, prefix = rs)
  @Produces(MediaType.APPLICATION_XML)
  public Response getUpdateStatus(ClientModuleInfoList clientModules);


Still, it's too bad it wouldn't work the other way, it seems more intuitive
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.





On 24/01/13 11:26 AM, Gabriella Turek gabriella.tu...@niwa.co.nz wrote:

Hello I have the following service request I am trying to execute:

@POST
  @ClientResponseType(entityType = JAXBModuleList.class)
  @Path(/updateStatus)
  @Consumes(MediaType.APPLICATION_XML)
  @Produces(MediaType.APPLICATION_XML)
  public Response getUpdateStatus(JAXBClientModuleList clientModuleList);


Where JAXBClientModuleList is just a list of JAXBClientModuleInfo objects,
defined as follows:


?xml version=1.0 encoding=UTF-8?
schema xmlns=http://www.w3.org/2001/XMLSchema;
targetNamespace=http://archive.riskscape.org.nz;
   xmlns:rs=http://archive.riskscape.org.nz;
xmlns:jaxb=http://java.sun.com/xml/ns/jaxb;
   jaxb:version=1.0 elementFormDefault=qualified

   element name=JAXBClientModuleList type=rs:jaxbClientModuleList /
   element name=JAXBClientModuleInfo type=rs:jaxbClientModuleInfo /

   complexType name=jaxbClientModuleList
   annotation
   appinfo
   jaxb:class name=JAXBClientModuleList /
   /appinfo
   /annotation
   sequence
   element name=ClientModule 
 type=rs:jaxbClientModuleInfo
maxOccurs=unbounded minOccurs=1/element
   /sequence
   /complexType

   complexType name=jaxbClientModuleInfo
   annotation
   appinfo
   jaxb:class name=JAXBClientModuleInfo /
   /appinfo
   /annotation
   sequence
   element name=Name type=string maxOccurs=1
minOccurs=1/element
   element name=Organisation type=string maxOccurs=1
minOccurs=1/element
   element name=Version type=string maxOccurs=1
minOccurs=1/element
   element name=RSVersion type=string maxOccurs=1
minOccurs=1/element
   /sequence
   /complexType

/schema


I've tried both mock and live testing and in both cases I get a 500 error
return.
Here's the code for the mock test:

@Test
  public void testGetUpdateStatus() throws Exception {
MockHttpRequest request = MockHttpRequest.post(/updateStatus);
request.contentType(MediaType.APPLICATION_XML_TYPE);

StringWriter writer = new StringWriter();

JAXBClientModuleList cml = new JAXBClientModuleList();
JAXBClientModuleInfo cmi = new JAXBClientModuleInfo();
cmi.setName(TestModule3);
cmi.setOrganisation(Hobbits);
cmi.setVersion(1.3.2);
cmi.setRSVersion(0.2.4);
cml.getClientModule().add(cmi);

JAXBContext jc = JAXBContext.newInstance(JAXBClientModuleList.class);
Marshaller marshaller = jc.createMarshaller();
marshaller.marshal(cmi, writer);
System.out.println(writer.toString());
request.setInputStream(new
ByteArrayInputStream(writer.toString().getBytes()));

MockHttpResponse response = new MockHttpResponse();
dispatcher.invoke(request, response);
assertEquals(HttpResponseCodes.SC_OK,response.getStatus());

jc = JAXBContext.newInstance(JAXBModuleList.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();

StringReader reader = new StringReader(response.getContentAsString());
JAXBModuleList result = (JAXBModuleList)
unmarshaller.unmarshal(reader);
assertTrue(result.getModule().size() == 1);
JAXBModule

[Resteasy-users] Cannot upload file to RESTEasy service using @MultipartForm , POJO and Client Framework

2013-01-20 Thread Gabriella Turek
Hello, I need a little help on making requests from a desktop client to a 
RESTEasy service. The service works great with a web form, but this is not the 
intended client, I need to implement client in a desktop application. I've 
followed examples on the web, but I still cannot get my client to work:

I am using RESTEasy version 2.3.5.Final
I can use the service from the a form, but not from a client.

Relevant code:

My form POJO:

public class FileUploadForm {


  @FormParam(file)
  @PartType(MediaType.APPLICATION_OCTET_STREAM)
  private byte[] 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 byte[] getData() {
   return data;
  }

  public void setData(final byte[] 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;
  }

}

My service side method definition:

@POST
@Path(/upload)
@Consumes(multipart/form-data)
@Produces(MediaType.TEXT_PLAIN)
public Response add(@MultipartForm FileUploadForm form);

My client side interface:

public interface MultipartClient
{
  @PUT
  @Path(/upload)
  @Consumes(multipart/form-data)
  @Produces(MediaType.TEXT_PLAIN)
  public Response add(@MultipartForm FileUploadForm form);
}

My test code:

MultipartClient client = ProxyFactory.create(MultipartClient.class, BASEURL 
+ URL_ROOT);
FileUploadForm upload = new FileUploadForm();
upload.setUser(bob);
upload.setPassword(xyzzxy);
upload.setFilename(file.zip);
String fileToUpload = file.zip
FileInputStream fis = new FileInputStream(fileToUpload);
byte[] fileData = IOUtils.toByteArray(fis);
upload.setData(fileData);
Response response = client.add(upload);
System.out.println(Response status:   + response.getStatus());
System.out.println(Response message:   + response.getEntity());
assertTrue(HttpResponseCodes.SC_OK == response.getStatus());


I get a response code 405 from the server. I am at my wits' end.





--
Please consider the environment before printing this email.
NIWA is the trading name of the National Institute of Water  Atmospheric 
Research Ltd.
--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users