You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(4) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2010 |
Jan
(1) |
Feb
(2) |
Mar
(6) |
Apr
(5) |
May
(1) |
Jun
(2) |
Jul
(2) |
Aug
(8) |
Sep
(4) |
Oct
(2) |
Nov
(6) |
Dec
(4) |
| 2011 |
Jan
(4) |
Feb
(18) |
Mar
(9) |
Apr
(7) |
May
(6) |
Jun
(13) |
Jul
(11) |
Aug
(7) |
Sep
(12) |
Oct
(28) |
Nov
(12) |
Dec
(11) |
| 2012 |
Jan
(20) |
Feb
(21) |
Mar
(19) |
Apr
(12) |
May
(44) |
Jun
(23) |
Jul
(14) |
Aug
(26) |
Sep
(23) |
Oct
(7) |
Nov
(42) |
Dec
(15) |
| 2013 |
Jan
(62) |
Feb
(20) |
Mar
(14) |
Apr
(52) |
May
(29) |
Jun
(46) |
Jul
(20) |
Aug
(55) |
Sep
(27) |
Oct
(53) |
Nov
(29) |
Dec
(21) |
| 2014 |
Jan
(35) |
Feb
(44) |
Mar
(12) |
Apr
(37) |
May
(24) |
Jun
(17) |
Jul
(13) |
Aug
(1) |
Sep
(4) |
Oct
(13) |
Nov
(1) |
Dec
(1) |
| 2015 |
Jan
(11) |
Feb
(8) |
Mar
(10) |
Apr
(7) |
May
(17) |
Jun
(11) |
Jul
(13) |
Aug
(14) |
Sep
(6) |
Oct
(3) |
Nov
(7) |
Dec
(3) |
| 2016 |
Jan
(1) |
Feb
(4) |
Mar
(8) |
Apr
(2) |
May
(2) |
Jun
(10) |
Jul
|
Aug
|
Sep
(5) |
Oct
(1) |
Nov
|
Dec
|
|
From: Michael M. <mmu...@re...> - 2010-11-24 15:56:55
|
The url in location header is already unique so why do you need to refer to it by another id. Some rest folk say that urls should be opaque so they would advise against parsing it for meaningful information. Mike > Hi List, > > I have many typical entity resources to which a POST will create a new > instance and return the resource URL as a Location header. However, I > find myself parsing this header in my application clients frequently to > strip out the ID of the newly-created entity. > > While the logic is trivial, I feel like it's silly to do this when I > control the server logic as well. I'm thinking about adding and > Entity-Id header to store the uniqe ID of whatever entities are created > at the various resources. Is there any reason why this is bad practice, > RESTfully speaking? I would of course leave the standard Location > header(s) there. > > Thanks, > > Chris > > ------------------------------------------------------------------------------ > Increase Visibility of Your 3D Game App& Earn a Chance To Win $500! > Tap into the largest installed PC base& get more eyes on your game by > optimizing for Intel(R) Graphics Technology. Get started today with the > Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. > http://p.sf.net/sfu/intelisp-dev2dev > _______________________________________________ > Resteasy-users mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-users |
|
From: Chris B. <cbr...@re...> - 2010-11-24 15:40:13
|
Hi List, I have many typical entity resources to which a POST will create a new instance and return the resource URL as a Location header. However, I find myself parsing this header in my application clients frequently to strip out the ID of the newly-created entity. While the logic is trivial, I feel like it's silly to do this when I control the server logic as well. I'm thinking about adding and Entity-Id header to store the uniqe ID of whatever entities are created at the various resources. Is there any reason why this is bad practice, RESTfully speaking? I would of course leave the standard Location header(s) there. Thanks, Chris |
|
From: Joe L. <joe...@gm...> - 2010-11-01 10:46:22
|
Hi, I have created a MessageBodyReader/MessageBodyWriter that needs to read a configuration value. Ideally I'd like this to be held in the web.xml as a context-param. Is there any way that a RESTEasy provider can access context params? Is there any type that I can inject using @Context that will allow me to get context-param values? I haven't been able to find one. Alternatively, is there a better way to provide configuration values to a provider? I'd like to avoid having to use a system property. Cheers, Joe |
|
From: Borut B. <bor...@gm...> - 2010-10-21 08:31:43
|
Hello,
I hope someone reads this, as the list seem a bit deserted, but anyways...
Yesterday I tried to use the client side of the RestEasy framework. The
interface has a method:
@PUT
@Path("document/autoincrement")
@Consumes("application/xml")
BaseClientResponse<String> insertPointOfInterest(PoiDocument
poiDocument);
and the call to some (Jersey) rest service looks like:
String restServerServiceUrl = "
http://my.jersey.server/rest/serviceFoo/v1/";
NSSClientService client =
ProxyFactory.create(NSSClientService.class, restServerServiceUrl);
PoiDocument poiDocument = new PoiDocument("Parkirišče", "90",
390262.85133115170, 42240.33558245482);
BaseClientResponse<String> response =
client.insertPointOfInterest(poiDocument);
assert response.getResponseStatus() == Response.Status.OK;
// Expected result
//<?xml version="1.0" encoding="UTF-8"
standalone="yes"?><insertedRecord><record>14</record></insertedRecord>
logger.info("Returned: " + response.getEntity());
And the logger prints:
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?><insertedRecord><record>14</record></insertedRecord>
Kind of expected.
But I want an object not a string, so I can easely assert the values
returned. The interface:
@PUT
@Path("document/autoincrement")
@Consumes("application/xml")
BaseClientResponse<InsertedResponse> insertPointOfInterest(PoiDocument
poiDocument);
Instead of String there is now a InsertedResponse class which looks like:
@XmlRootElement(name="insertedRecord")
public class InsertedResponse extends ResponseResult{
String insertedRecord;
public InsertedResponse(int insertedRecord) {
this.insertedRecord = Integer.toString(insertedRecord);
}
public InsertedResponse(){
insertedRecord = "";
}
@XmlElement(name="record")
public String getInsertedRecords(){
return insertedRecord;
}
public void add(int recNo) {
insertedRecord = Integer.toString(recNo);
}
}
...and his superclass:
@XmlRootElement(name = "result")
public abstract class ResponseResult {
protected String getClearString(String string) {
if (string != null) {
return Constants.removeInvalidXMLCharacters(string);
}
return "";
}
}
Now, when I change the client call also to:
BaseClientResponse<InsertedResponse> response =
client.insertPointOfInterest(poiDocument);
logger.info("Returned: " +
response.getEntity().getInsertedRecords());
I get an empty string instead of some value.
So, the question is - where did the value of <record> go? It should print a
number, like 14 in the above example.
Kind regards,
Borut
|
|
From: Ken G. <ke...@gl...> - 2010-10-17 10:25:06
|
Hi. I'm trying to get the ajax client to work following the guide at: http://docs.jboss.org/resteasy/docs/2.0.0.GA/userguide/html_single/index.html#d0e3137 <http://docs.jboss.org/resteasy/docs/2.0.0.GA/userguide/html_single/index.html#d0e3137>I am using JBOSS AS 6 M5 and my project is generated using the weld archetype with some modifications. Here is my pom: http://github.com/kenglxn/cdi-demo/blob/master/pom.xml Here is my web.xml: http://github.com/kenglxn/cdi-demo/blob/master/src/main/webapp/WEB-INF/web.xml <http://gist.github.com/630714>I have followed the example and added a JAX-RS API: http://github.com/kenglxn/cdi-demo/blob/master/src/main/java/demo/resteasy/Foo.java <http://gist.github.com/630715>I can't seem to find the generated javascript anywhere. The result of a request to http://localhost:8080/cdi-demo/rest-js gives: http://gist.github.com/630725 And there is no automatically generated javascript api. Can't seem to figure out what I'm missing. <http://gist.github.com/630725>Any help is greatly appreciated :) /ken P.S: the code in question is located here: http://github.com/kenglxn/cdi-demo |
|
From: Darius B. <d....@gm...> - 2010-09-28 09:31:47
|
Hi, I'm trying to set a specific ip address to listen on the embedded server. HTTP works well: TJWS httpd 127.0.0.1 - SimpleAcceptor ServerSocket[addr= 127.0.0.1/127.0.0.1,port=0,localport=8080] is listening. If I use SSL, the ip is allways 0.0.0.0 TJWS httpd 0.0.0.0 - Acme.Serve.SSLAcceptor@bc917c is listening. What is my fault? I use Resteasy 1.2 GA. regards, |
|
From: Michael M. <mmu...@re...> - 2010-09-20 16:33:52
|
I have only recently joined this mailing list and therefore I am unable to answer older queries. Apart from cutting and pasting from the archives is there a mechanism for replying to old emails? Something similar to what we get on the forums. Mike |
|
From: Michael M. <mmu...@re...> - 2010-09-20 16:27:21
|
If you need more you could look at how Jersey does it: http://wikis.sun.com/display/Jersey/WADL InfoQ also caries a short article on what google and others are doing in this area: http://www.infoq.com/news/2007/03/WADL Mike > On 08/26/2010 12:15 PM, Chris Bredesen wrote: > >> I haven't been able to find any tools that can generate service >> documentation from a set of RS-annotated interfaces. I have pretty >> tight XSD doc generated automatically but lack doco for my services. >> >> WADL fits the bill fairly well but I'm certainly not tied to it. Anyone >> working on anything like this? Have I missed a tool somewhere in the chain? > Found this: > > http://github.com/ameingast/java2wadl > > It's pretty green but generated a skeleton WADL that I can hand edit and > XSL transform into something useful. Going that route, I think. If > anyone is doing something else for documentation, I'd love to hear about it. > > -Chris > > ------------------------------------------------------------------------------ > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program > Be part of this innovative community and reach millions of netbook users > worldwide. Take advantage of special opportunities to increase revenue and > speed time-to-market. Join now, and jumpstart your future. > http://p.sf.net/sfu/intel-atom-d2d > _______________________________________________ > Resteasy-users mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-users |
|
From: Michael M. <mmu...@re...> - 2010-09-20 15:00:54
|
Hi Sean, You need to add your Application class as a web archive context param in web.xml. For example: <context-param> <param-name>javax.ws.rs.core.Application</param-name> <param-value>org.jboss.jbossts.rts.service.TMApplication</param-value> </context-param> The servlet class should reference Bills' implementation as in: <servlet> <servlet-name>Resteasy</servlet-name> <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> </servlet> Mike > Hello, > I am new to using RESTEasy and am having trouble getting an example to work. > > When I build the war and deploy to JBOSS 6, I am getting the following > error trace > > 11:09:29,148 ERROR [[/Chap3]] Exception starting filter Resteasy: > java.lang.ClassCastException: ca.st.services.ShopApp cannot be cast to > javax.ws.rs.core.Application > > The ShopApp Class extends javax.ws.rs.core.Application so i am not > really sure what is going on. > > My snippet from the web.xml looks like the following. > > <servlet> > <servlet-name>Rest</servlet-name> > <servlet-class> > ca.st.services.ShopApp > </servlet-class> > </servlet> > > Any ideas would be appreciated... > > Thanks > |
|
From: Chris B. <cbr...@re...> - 2010-08-27 13:39:54
|
On 08/26/2010 12:15 PM, Chris Bredesen wrote: > I haven't been able to find any tools that can generate service > documentation from a set of RS-annotated interfaces. I have pretty > tight XSD doc generated automatically but lack doco for my services. > > WADL fits the bill fairly well but I'm certainly not tied to it. Anyone > working on anything like this? Have I missed a tool somewhere in the chain? Found this: http://github.com/ameingast/java2wadl It's pretty green but generated a skeleton WADL that I can hand edit and XSL transform into something useful. Going that route, I think. If anyone is doing something else for documentation, I'd love to hear about it. -Chris |
|
From: Chris B. <cbr...@re...> - 2010-08-26 16:15:18
|
Hello community, I haven't been able to find any tools that can generate service documentation from a set of RS-annotated interfaces. I have pretty tight XSD doc generated automatically but lack doco for my services. WADL fits the bill fairly well but I'm certainly not tied to it. Anyone working on anything like this? Have I missed a tool somewhere in the chain? Cheers, Chris |
|
From: Christos V. <cva...@gm...> - 2010-08-26 13:33:15
|
Hi there, I searched but I couldn't find an answer, my apologies if this was asked before. I would like to know what is the proper way to configure the Jackson Provider. I want to set some properties (eg. SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS). How can programmatically, on the init of the application set some configuration options for the provider. Thanks in advance Regards, Christos |
|
From: Elias R. de M. <eli...@bo...> - 2010-08-26 08:16:15
|
Hello, I created a StringConverter for a Collection<?>, but I don't get it to work. When the execution arrives in fromString method there is only one of my elements's Collection. The others are lost. Thanks, Elias |
|
From: Frans v. N. <fra...@gm...> - 2010-08-26 05:25:10
|
Is it possible to automatically follow a see other (303) redirect using ClientRequest post? Thanks in advance. |
|
From: Sean T. <sea...@gm...> - 2010-08-20 16:11:02
|
Hello,
I am new to using RESTEasy and am having trouble getting an example to work.
When I build the war and deploy to JBOSS 6, I am getting the following
error trace
11:09:29,148 ERROR [[/Chap3]] Exception starting filter Resteasy:
java.lang.ClassCastException: ca.st.services.ShopApp cannot be cast to
javax.ws.rs.core.Application
The ShopApp Class extends javax.ws.rs.core.Application so i am not
really sure what is going on.
My snippet from the web.xml looks like the following.
<servlet>
<servlet-name>Rest</servlet-name>
<servlet-class>
ca.st.services.ShopApp
</servlet-class>
</servlet>
Any ideas would be appreciated...
Thanks
--
Sean Tiley
sea...@gm...
|
|
From: Michael M. <mmu...@re...> - 2010-08-20 13:01:42
|
I'm getting puzzling behaviour running my unit tests that use the embedded container (org.jboss.resteasy.test.EmbeddedContainer). I am seeing the following, consistently, but on random tests: I perform a POST to one of my resources using ClientRequest (the first line of log output). However the JAXRS annotated resource that should handle the request doesn't get called for 60 seconds (the second line): 2010-08-20 11:55:03,268 [Acme.Utils.ThreadPool(16)-PooledThread: Acme.Serve.Serve$ServeConnection@e11e831] TRACE - POST: http://localhost:8081/tx/participant/pid2/tx/0_ffff7f000001_ddce_4c6e5f06_5/commit 2010-08-20 11:56:02,513 [Acme.Utils.ThreadPool(4)-PooledThread: Acme.Serve.Serve$ServeConnection@33f98d58] DEBUG - particpant: commit: pid2/tx/0_ffff7f000001_ddce_4c6e5f06_5/commit I'm using the per request model for my resources. I tried moving to the Singleton model to see if I get different behaviour but this gives me the error "Class is not a root resource. It, or one of its interfaces must be annotated with @Path". This latter error is also exhibited by the RESTeasy test suite: I checked out: https://resteasy.svn.sourceforge.net/svnroot/resteasy/trunk/jaxrs/resteasy-jaxrs Modified the following simple test src/test/java/org/jboss/resteasy/test/finegrain/client/ClientResponseTest.java such that SimpleResource.class is registered as a SingletonResource and got the same error: "java.lang.RuntimeException: Class is not a root resource. It, or one of its interfaces must be annotated with @Path" |
|
From: David H. <dav...@gm...> - 2010-08-05 15:28:38
|
I am stumped by this one and would appreciate any help. I am having trouble
parsing the response body back into a Java object.
The relevant piece of code looks like this:
ClientRequest request = new ClientRequest(sdURL);
request.body("application/xml", xml);
try {
ClientResponse<SdErrorMessageXml> response = request.post();
if( response.getResponseStatus() != Response.Status.NO_CONTENT )
{
System.out.println("service returned a
'"+response.getResponseStatus()+"' response");
SdErrorMessageXml error =
response.getEntity(SdErrorMessageXml.class);
System.out.println("service desk error: "+error.getText());
}
} catch (Exception e) {
e.printStackTrace();
}
The SdErrorMessageXml was generated from and XSD using xjc.
When I attempt to use the getEntity() method, I get the following:
service returned a 'Not Modified' response
org.jboss.resteasy.plugins.providers.jaxb.JAXBUnmarshalException:
javax.xml.bind.UnmarshalException
- with linked exception:
[java.io.IOException: Stream closed]
at
org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.readFrom(AbstractJAXBProvider.java:86)
at
org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:105)
at
org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.read(GZIPDecodingInterceptor.java:46)
at
org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:108)
at
org.jboss.resteasy.core.messagebody.ReaderUtility.doRead(ReaderUtility.java:111)
at
org.jboss.resteasy.client.core.BaseClientResponse.readFrom(BaseClientResponse.java:246)
at
org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:210)
at
org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:183)
at
org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:177)
at com.dhc.RestTest.main(RestTest.java:33)
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[java.io.IOException: Stream closed]
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:213)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:184)
at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:105)
at
org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.readFrom(AbstractJAXBProvider.java:82)
... 9 more
Caused by: java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:134)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
at
org.jboss.resteasy.client.core.SelfExpandingBufferredInputStream.read(SelfExpandingBufferredInputStream.java:48)
at
com.sun.org.apache.xerces.internal.impl.XMLEntityManager$RewindableInputStream.read(XMLEntityManager.java:2932)
at
com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:704)
at
com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:186)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:772)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:211)
... 13 more
The httpclient wire reports:
[DEBUG]org.apache.commons.httpclient.Wire:wire(Wire.java:70): << "HTTP/1.1
304 Not Modified[\r][\n]"
[DEBUG]org.apache.commons.httpclient.Wire:wire(Wire.java:70): << "Server:
Apache-Coyote/1.1[\r][\n]"
[DEBUG]org.apache.commons.httpclient.Wire:wire(Wire.java:70): << "ETag:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><sd-error-message-xml
text="No Person found with search code containing:
"9999999999""/>[\r][\n]"
[DEBUG]org.apache.commons.httpclient.Wire:wire(Wire.java:70): << "Date: Thu,
05 Aug 2010 11:20:32 GMT[\r][\n]"
[DEBUG]org.apache.commons.httpclient.Wire:wire(Wire.java:70): << "[\r][\n]"
Resteasy 1.2.1, jaxrs 1.2.1, jaxb-2.1
I have tried a number of ideas but none of them have worked out.
If you have any suggestions, I would be grateful if you sent them to me.
Thanks
-david-
|
|
From: David H. <dav...@gm...> - 2010-07-22 22:13:43
|
Please ignore this. Turns out that a missing java library message was being hidden from me. -david- |
|
From: David H. <dav...@gm...> - 2010-07-22 18:32:50
|
I am not sure if this is expected behavior but when I create a new
ClientRequest to an URL that is not in service, the instantiation never
returns.
i.e. ClientRequest request = new ClientRequest("http://127.0.0.1/foo/rest");
never times out.
Am I missing something (I hope)?
Thanks
-david-
|
|
From: Guilherme G. <ger...@gm...> - 2010-06-29 16:38:49
|
Hi again,
After going into the Resteasy and jackson's code, I've seen that
the ResteasyJacksonProvider (because of JacksonJsonProvider) won't
(des)serialize String (as well as other types: byte[], char[], Response,
OutputStream, etc.). So I've must follow approach (1) to make it work.
Thanks,
On Mon, Jun 28, 2010 at 5:04 PM, Guilherme Germoglio <ger...@gm...>wrote:
> Hello,
>
> Let's say there's a method:
>
> @GET
> @Path("/any_path")
> @Produces("application/json")
> public String getAnyValue();
>
> Should this implementation return a String already converted to a JSON (1)
> or the conversion to JSON would be implemented automatically by Resteasy
> (2)?
>
> (1) Something along the lines of (all exceptions were omitted):
>
> @GET
> @Path("/any_path")
> @Produces("application/json")
> public String getAnyValue() {
> ObjectMapper codec = new ObjectMapper(); // jackson's mapper
> ByteArrayOutputStream baos = new ByteArrayOutputStream();
> codec.writeValue(baos, "any value");
> return new String(baos.toByteArray());
> }
>
> (2) Something along the lines of:
>
> @GET
> @Path("/any_path")
> @Produces("application/json")
> public String getAnyValue() {
> return "any value"; // the magic is made by Resteasy, just like would
> be made
> // if an annotated object would be returned.
> }
>
> If approach (2) is to be ok, I run into trouble: When I create a client
> using the Resteasy Client Framework, both client and server communicate
> perfectly. However, if I use another client, e.g. implemented using
> org.apache.commons.httpclient.HttpClient, this client is unable to parse the
> response into a JSON. Also, by debugging the response, I can see that the
> supposed automatic conversion from String to JSON is not working (the same
> String returned is received by the client, when the correct -- I think --
> would be to put it between double quotes: this is how a String is
> represented in JSON, right?).
>
> Thank you very much (and congratulations for such wonderful tool!)
>
> --
> Guilherme
>
> msn: gui...@ho...
> homepage: http://sites.google.com/site/germoglio/
>
--
Guilherme
msn: gui...@ho...
homepage: http://sites.google.com/site/germoglio/
|
|
From: Guilherme G. <ger...@gm...> - 2010-06-28 20:04:43
|
Hello,
Let's say there's a method:
@GET
@Path("/any_path")
@Produces("application/json")
public String getAnyValue();
Should this implementation return a String already converted to a JSON (1)
or the conversion to JSON would be implemented automatically by Resteasy
(2)?
(1) Something along the lines of (all exceptions were omitted):
@GET
@Path("/any_path")
@Produces("application/json")
public String getAnyValue() {
ObjectMapper codec = new ObjectMapper(); // jackson's mapper
ByteArrayOutputStream baos = new ByteArrayOutputStream();
codec.writeValue(baos, "any value");
return new String(baos.toByteArray());
}
(2) Something along the lines of:
@GET
@Path("/any_path")
@Produces("application/json")
public String getAnyValue() {
return "any value"; // the magic is made by Resteasy, just like would be
made
// if an annotated object would be returned.
}
If approach (2) is to be ok, I run into trouble: When I create a client
using the Resteasy Client Framework, both client and server communicate
perfectly. However, if I use another client, e.g. implemented using
org.apache.commons.httpclient.HttpClient, this client is unable to parse the
response into a JSON. Also, by debugging the response, I can see that the
supposed automatic conversion from String to JSON is not working (the same
String returned is received by the client, when the correct -- I think --
would be to put it between double quotes: this is how a String is
represented in JSON, right?).
Thank you very much (and congratulations for such wonderful tool!)
--
Guilherme
msn: gui...@ho...
homepage: http://sites.google.com/site/germoglio/
|
|
From: Eoghan G. <eg...@re...> - 2010-05-04 21:11:32
|
Hi Folks,
I'm using a javax.ws.rs.WebApplicationException to trigger a 409
response with a non-empty entity body containing a JAXB-generated Fault
type. Something like:
throw new WebApplicationException(
Response.status(Response.Status.CONFLICT)
.entity(fault)
.build());
The resource method is decorated with @Consumes & @Produces listing
application/xml, application/yaml and application/json.
The incoming request that causes the 409 condition to fire has both
Content-Type and Accept both set to application/xml.
Now for some reason, the Fault instance in the response is being
marshalled as yaml, but with the Content-Type of the response left
unset, literally as follows:
HTTP/1.1 409 Conflict
Content-Length: 122
Server: Jetty(6.1.23)
--- !com.redhat.rhevm.api.model.Fault
detail: "Attempt to set immutable field: id"
reason: Broken immutability constraint
Whereas if I explicitly apply the conneg rules myself, and set the
Content-Type of the response to the type specified in the incoming
Accept header like so:
throw new WebApplicationException(
Response.status(Response.Status.CONFLICT)
.headers("Content-Type", <type from incoming Accept>)
.entity(fault)
.build());
then all is well again and the response plays out as follows:
HTTP/1.1 409 Conflict
Content-Type: application/xml
Content-Length: 168
Server: Jetty(6.1.23)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<fault>
<reason>Broken immutability constraint</reason>
<detail>Attempt to set immutable field: id</detail>
</fault>
exactly as I expected originally. Does this smell like a bug, as in
shouldn't the appropriate content type be applied automatically?
Cheers,
Eoghan
|
|
From: David M. <mcw...@cc...> - 2010-04-09 16:11:37
|
Hi,
We are using Resteasy in an EJB 3.0 application on Jboss 5.1. We use a
custom stateless EJB implementation of javax.ws.rs.ext.ContextResolver,
javax.ws.rs.ext.MessageBodyReader, and import
javax.ws.rs.ext.MessageBodyWriter to marshal and unmarshal xml in our
system, mainly to resolve entities referenced by id (XMLID and XMLIDREF) in
xml to their corresponding entities in the database, accessed through JPA.
I have figured out how to set resteasy to use this custom EJB as a provider,
by adding the following lines to the web.xml of our webapp:
<context-param>
<param-name>resteasy.providers</param-name>
<param-value>
com.ccri.xml.JAXBContextResolverBean,
org.jboss.resteasy.plugins.providers.jackson.ResteasyJacksonProvider
</param-value>
</context-param>
My problem, however, is this: when resteasy uses our JAXBContextResolverBean
class to marshal/unmarshal XML, it seems that it creates an instance of the
class by calling the constructor, rather than actually looking up an EJB
instance of the class. This is a problem because we need the
JAXBContextResolverBean to be able to inject an Entity Manager in the
following manner, in order to translate XMLIDREFs back to the actual object
stored by JPA:
@PersistenceContext
private EntityManager entityManager;
Would anyone know of any way to make resteasy look up the provider as an EJB
bean rather than just creating it by calling the constructor. Or, perhaps
alternatively, would anyone know a way to inject the Jboss/EJB entity
manager into the Context Resolver in this context?
Thank you very much for any help you are able to provide,
David
--
David McWhorter
Software Engineer
Commonwealth Computer Research, Inc.
|
|
From: Tim T. <tim...@gm...> - 2010-04-08 13:56:13
|
What is needed in JBoss 6 M2 in order to have the javax.ws.rs.Path
annotation scanned automatically in my war? I have the class below and
an index.jsp in a myapp.war file. I can see /myapp/index.jsp in the
browser, but I get 404 for /myapp/hello. Would could be missing?
/Tim
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Path ("hello")
public class Hello {
@GET
public String world() {
return "world";
}
}
|
|
From: Roman <rom...@gm...> - 2010-04-07 05:48:41
|
Hello,
In my RESTEasy client application I would like to be able to retrieve
the response body when server responds with 500 error code, in order
to provide a meaningful error message to the user. Attempt to read the body
from exception using the following code fails, as the input
stream is already closed:
ClientResponse response = failure.getResponse();
responseBody = (String) response.getEntity(String.class);
I'was able to work around it by creating a ClientErrorInterceptor
which does nothing, but reads the response body as
public void handle(ClientResponse<?> response) throws RuntimeException {
try {
response.getEntity(String.class);
} catch (Exception e) {
e.printStackTrace();
}
}
The above exception handling code started working after that.
Still, it works only in some clients, others fail to read response
body. I do not have an exact error message at hand, but it is saying
something like "MessageBodyReader for media type */* and Java type
java.lang.String is not found".
Am I missing some bits in the solution or Is there any better way to
solve the problem?
Thank you,
Roman
|