[Resteasy-users] How to set up RestEasyClient to follow redirects?
So I've managed to expend my client code to support proxy and SSL. Now I need to make them work with a redirect. My queries are all failing with a status 301 (both POST and GET) What do I need to do to make sure the redirect is followed? Here's an example of my call ResteasyClientBuilder rsb = new ResteasyClientBuilder(); rsb.defaultProxy("myproxy",80,"http"); SSLContext ctx = getSSLContext(); rsb.sslContext(ctx); ResteasyClient rsc = rsb.build(); ResteasyWebTarget target = rsc.target(BASEURL); RiskScapeLicenseService client = target.proxy(RiskScapeLicenseService.class); Response response = client.licenseRequest(……); Thanx Gaby -- 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
Re: [Resteasy-users] How to setup RESTEasy with CDI and Netty?
Submit a pull request, i'll take a look On 11/26/2013 7:05 PM, John D. Ament wrote: > Bill, > > Actually from looking at the current impl, I have a fairly small > trivial change. It would only work in CDI 1.1 though. I could > probably implement it using reflection to avoid the compilation > change, if you're interested in taking the contribution. This would > use standard CDI look up in an SE environment. > > John > > On Tue, Nov 26, 2013 at 6:06 PM, Bill Burke wrote: >> >> >> On 11/26/2013 4:17 PM, Christian Helmbold wrote: >>> >>> >>> >>> >>> >>> John D. Ament schrieb am 20:23 Dienstag, 26.November 2013: > > I assumed this would happen, based on Bill's email. >>> >>> >>> You're right. This happend after adding the following line to my startup >>> code: >>> >>> >>> deployment.setInjectorFactoryClass(org.jboss.resteasy.cdi.CdiInjectorFactory.class.getName()); >>> you'll probably need to extend the CdiInjectorFactory to use your own BeanManager. >>> >>> >>> I wonder why >>> http://docs.jboss.org/resteasy/docs/3.0.5.Final/userguide/html_single/index.html#d4e2034 >>> seems to be so simple. >>> >>> Sounds like Weld and RESTEasy are simply not built for what I want to do! >>> The philosophie seems to be: use the whole application server or use >>> something else. My idea was to create a small configuration which could be >>> restarted very fast during development. I've done something similar with >>> Guice and Jersey. But Wildfly should start pretty fast, so this could be >>> better than trying to do the configuration myself. >>> >> >> I would dive into this, but I don' thave the cycles at this time. Its just >> a matter of gettin Weld initialized in a SE environment, and then tweaking >> the CdiInjectorFactory. >> >> >> There is a Resteasy Guice adapter too. >> >> >> >> -- >> Bill Burke >> JBoss, a division of Red Hat >> http://bill.burkecentral.com -- Bill Burke JBoss, a division of Red Hat http://bill.burkecentral.com -- 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
Re: [Resteasy-users] How to setup RESTEasy with CDI and Netty?
Bill, Actually from looking at the current impl, I have a fairly small trivial change. It would only work in CDI 1.1 though. I could probably implement it using reflection to avoid the compilation change, if you're interested in taking the contribution. This would use standard CDI look up in an SE environment. John On Tue, Nov 26, 2013 at 6:06 PM, Bill Burke wrote: > > > On 11/26/2013 4:17 PM, Christian Helmbold wrote: >> >> >> >> >> >> >>> John D. Ament schrieb am 20:23 Dienstag, >>> 26.November 2013: I assumed this would happen, based on Bill's email. >> >> >> You're right. This happend after adding the following line to my startup >> code: >> >> >> deployment.setInjectorFactoryClass(org.jboss.resteasy.cdi.CdiInjectorFactory.class.getName()); >> >>> you'll probably >>> need to extend the CdiInjectorFactory to use your own BeanManager. >> >> >> I wonder why >> http://docs.jboss.org/resteasy/docs/3.0.5.Final/userguide/html_single/index.html#d4e2034 >> seems to be so simple. >> >> Sounds like Weld and RESTEasy are simply not built for what I want to do! >> The philosophie seems to be: use the whole application server or use >> something else. My idea was to create a small configuration which could be >> restarted very fast during development. I've done something similar with >> Guice and Jersey. But Wildfly should start pretty fast, so this could be >> better than trying to do the configuration myself. >> > > I would dive into this, but I don' thave the cycles at this time. Its just > a matter of gettin Weld initialized in a SE environment, and then tweaking > the CdiInjectorFactory. > > > There is a Resteasy Guice adapter too. > > > > -- > Bill Burke > JBoss, a division of Red Hat > http://bill.burkecentral.com -- 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
Re: [Resteasy-users] How to setup RESTEasy with CDI and Netty?
On 11/26/2013 4:17 PM, Christian Helmbold wrote: > > > > > >> John D. Ament schrieb am 20:23 Dienstag, >> 26.November 2013: >>> I assumed this would happen, based on Bill's email. > > You're right. This happend after adding the following line to my startup code: > > deployment.setInjectorFactoryClass(org.jboss.resteasy.cdi.CdiInjectorFactory.class.getName()); > >> you'll probably >> need to extend the CdiInjectorFactory to use your own BeanManager. > > I wonder why > http://docs.jboss.org/resteasy/docs/3.0.5.Final/userguide/html_single/index.html#d4e2034 > seems to be so simple. > > Sounds like Weld and RESTEasy are simply not built for what I want to do! The > philosophie seems to be: use the whole application server or use something > else. My idea was to create a small configuration which could be restarted > very fast during development. I've done something similar with Guice and > Jersey. But Wildfly should start pretty fast, so this could be better than > trying to do the configuration myself. > I would dive into this, but I don' thave the cycles at this time. Its just a matter of gettin Weld initialized in a SE environment, and then tweaking the CdiInjectorFactory. There is a Resteasy Guice adapter too. -- Bill Burke JBoss, a division of Red Hat http://bill.burkecentral.com -- 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
Re: [Resteasy-users] Replacing ProxyFactory with RestEasyWebTarget does not work
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" >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 >>>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") JAXBElement element= (JAXBElement) 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: | 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"> riskscapelic_rest org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap Resteasy org.jboss.resteasy.plugins.server.servlet.HttpServletDis p a tcher Resteasy /* resteasy.scan true resteasy.servlet.mapping.prefix / | The LicenseList class: |@XmlRootElement(name= "LicenseList") @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name= "lic
Re: [Resteasy-users] How to setup RESTEasy with CDI and Netty?
> John D. Ament schrieb am 20:23 Dienstag, 26.November > 2013: > > I assumed this would happen, based on Bill's email. You're right. This happend after adding the following line to my startup code: deployment.setInjectorFactoryClass(org.jboss.resteasy.cdi.CdiInjectorFactory.class.getName()); > you'll probably > need to extend the CdiInjectorFactory to use your own BeanManager. I wonder why http://docs.jboss.org/resteasy/docs/3.0.5.Final/userguide/html_single/index.html#d4e2034 seems to be so simple. Sounds like Weld and RESTEasy are simply not built for what I want to do! The philosophie seems to be: use the whole application server or use something else. My idea was to create a small configuration which could be restarted very fast during development. I've done something similar with Guice and Jersey. But Wildfly should start pretty fast, so this could be better than trying to do the configuration myself. Christian -- 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
Re: [Resteasy-users] Replacing ProxyFactory with RestEasyWebTarget does not work
This does not work? LicenseList list = response.readEntity(LicenseList.class); You could also try this: LicenseList list = response.readEntity(new GenericType>() {}).getValue(); javax.ws.rs.core.GenericType On 11/26/2013 4:00 PM, Gabriella Turek 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.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 >> 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") >>> JAXBElement element= (JAXBElement) >>> 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: >>> >>> | >>> 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"> >>> riskscapelic_rest >>> >>> >>> org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap >>> >>> >>> >>> Resteasy >>> >>> org.jboss.resteasy.plugins.server.servlet.HttpServletDispa >>> tcher >>> >>> >>> Resteasy >>> /* >>> >>> >>> resteasy.scan >>> true >>> >>> >>> resteasy.servlet.mapping.prefix >>> / >>> >>> | >>> >>> The LicenseList class: >>> >>> |@XmlRootElement(name= "LicenseList") >>> @XmlAccessorType(XmlAccessType.FIELD) >>> @XmlType(name= "licenseList", propOrder= { >>> "licenses" >>> }) >>> public class LicenseList { >>> >>>
Re: [Resteasy-users] Replacing ProxyFactory with RestEasyWebTarget does not work
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 >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") >> JAXBElement element= (JAXBElement) >>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: >> >> | >> 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"> >>riskscapelic_rest >> >> >> org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap >> >> >> >> Resteasy >> >>org.jboss.resteasy.plugins.server.servlet.HttpServletDispa >>tcher >> >> >> Resteasy >> /* >> >> >> resteasy.scan >> true >> >> >> resteasy.servlet.mapping.prefix >> / >> >> | >> >> The LicenseList class: >> >> |@XmlRootElement(name= "LicenseList") >> @XmlAccessorType(XmlAccessType.FIELD) >> @XmlType(name= "licenseList", propOrder= { >> "licenses" >> }) >> public class LicenseList { >> >> @XmlElement(name= "Licenses", required= true) >> protected List licenses; >> >> /** >> * Gets the value of the licenses property. >> * >> * >> * This accessor method returns a reference to the live list, >> * not a snapshot. Therefore any modification you make to the >> * returned list will be present inside the JAXB object. >> * This is why there is not a set method for the >>licenses property. >> * >> * >> * For example, to add a ne
Re: [Resteasy-users] Replacing ProxyFactory with RestEasyWebTarget does not work
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") > JAXBElement element= (JAXBElement) > 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: > > | > 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"> >riskscapelic_rest > > > org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap > > > > Resteasy > > org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher > > > Resteasy > /* > > > resteasy.scan > true > > > resteasy.servlet.mapping.prefix > / > > | > > The LicenseList class: > > |@XmlRootElement(name= "LicenseList") > @XmlAccessorType(XmlAccessType.FIELD) > @XmlType(name= "licenseList", propOrder= { > "licenses" > }) > public class LicenseList { > > @XmlElement(name= "Licenses", required= true) > protected List licenses; > > /** > * Gets the value of the licenses property. > * > * > * This accessor method returns a reference to the live list, > * not a snapshot. Therefore any modification you make to the > * returned list will be present inside the JAXB object. > * This is why there is not a set method for the licenses > property. > * > * > * For example, to add a new item, do as follows: > * > *getLicenses().add(newItem); > * > * > * > * > * Objects of the following type(s) are allowed in the list > * {@link License } > * > * > */ > public List getLicenses() { > if (licenses== null) { > licenses= new ArrayList(); > } > return this.licenses; > } > > }| > > I am using JDK 1.7, Tomcat 7.0.47 > -- > 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.
[Resteasy-users] Replacing ProxyFactory with RestEasyWebTarget does not work
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") JAXBElement element = (JAXBElement) 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: 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"> riskscapelic_rest org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap Resteasy org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher Resteasy /* resteasy.scan true resteasy.servlet.mapping.prefix / The LicenseList class: @XmlRootElement(name = "LicenseList") @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "licenseList", propOrder = { "licenses" }) public class LicenseList { @XmlElement(name = "Licenses", required = true) protected List licenses; /** * Gets the value of the licenses property. * * * This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the licenses property. * * * For example, to add a new item, do as follows: * *getLicenses().add(newItem); * * * * * Objects of the following type(s) are allowed in the list * {@link License } * * */ public List getLicenses() { if (licenses == null) { licenses = new ArrayList(); } return this.licenses; } } I am using JDK 1.7, Tomcat 7.0.47 -- 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
Re: [Resteasy-users] How to setup RESTEasy with CDI and Netty?
I assumed this would happen, based on Bill's email. you'll probably need to extend the CdiInjectorFactory to use your own BeanManager. On Tue, Nov 26, 2013 at 1:58 PM, Christian Helmbold wrote: > Thank you. After adding one more dependency (javax.servlet-api), I get the > following error, when I try to start my RESTEasy/Weld configuration: > > Exception in thread "main" java.lang.RuntimeException: Unable to instantiate > InjectorFactory implementation. > at > org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:156) > at > org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer.start(NettyJaxrsServer.java:130) > at com.example.jaxrscdi.App.run(App.java:25) > 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.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93) > at > org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:266) > at > org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253) > at > org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:232) > at > org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:169) > at > org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:165) > at > org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:119) > at > org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:112) > at org.jboss.weld.event.EventImpl.fire(EventImpl.java:83) > at org.jboss.weld.environment.se.Weld.initialize(Weld.java:153) > at org.jboss.weld.environment.se.StartMain.go(StartMain.java:41) > at org.jboss.weld.environment.se.StartMain.main(StartMain.java:52) > Caused by: java.lang.NullPointerException > at > org.jboss.resteasy.cdi.CdiInjectorFactory.lookupBeanManager(CdiInjectorFactory.java:155) > at > org.jboss.resteasy.cdi.CdiInjectorFactory.(CdiInjectorFactory.java:45) > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > at java.lang.reflect.Constructor.newInstance(Constructor.java:526) > at java.lang.Class.newInstance(Class.java:374) > at > org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:148) > ... 18 more > > > Any idea? > > Regards, > Christian > > > -- > 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 -- 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
Re: [Resteasy-users] How to setup RESTEasy with CDI and Netty?
Thank you. After adding one more dependency (javax.servlet-api), I get the following error, when I try to start my RESTEasy/Weld configuration: Exception in thread "main" java.lang.RuntimeException: Unable to instantiate InjectorFactory implementation. at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:156) at org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer.start(NettyJaxrsServer.java:130) at com.example.jaxrscdi.App.run(App.java:25) 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.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93) at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:266) at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253) at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:232) at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:169) at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:165) at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:119) at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:112) at org.jboss.weld.event.EventImpl.fire(EventImpl.java:83) at org.jboss.weld.environment.se.Weld.initialize(Weld.java:153) at org.jboss.weld.environment.se.StartMain.go(StartMain.java:41) at org.jboss.weld.environment.se.StartMain.main(StartMain.java:52) Caused by: java.lang.NullPointerException at org.jboss.resteasy.cdi.CdiInjectorFactory.lookupBeanManager(CdiInjectorFactory.java:155) at org.jboss.resteasy.cdi.CdiInjectorFactory.(CdiInjectorFactory.java:45) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:374) at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:148) ... 18 more Any idea? Regards, Christian -- 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