You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Nick Khamis <sy...@gmail.com> on 2013/07/26 18:57:06 UTC

Fwd: JsonJaxbModule for JAX-RS 2.0

Hello Everyone,

Our environment is Tomee web profile with JAX-RS 2.0 libraries added to our
project and api jars on the server.
We are getting a MessageBodyWriter not found when creating a resource that
produces json. The quick searching
I found maven solution however, we do not use maven. Also, I could not find
the binary for JsonJaxbModule anywhere.
We do use web.xml for the project, but not sure which dependency we need to
add and where to find the
dependency. Is this a JEE6 vs 7 issue?

Thanks in Advance,

Nick.

Re: Fwd: JsonJaxbModule for JAX-RS 2.0

Posted by Nick Khamis <sy...@gmail.com>.
Yeah, I know about that JSON-P standard client api however, wanted
to have the serialization done automatically as is the case for xml.
What I did was, added:

jackson-jaxrs-1.5.4.jar
jackson-core-asl-1.7.0.jar
jackson-mapper-asl-1.7.0.jar

Included "org.codehaus.jackson.jaxrs" to params in web.xml

<init-param>
  <param-name>jersey.config.server.provider.packages</param-name>
  <param-value>com.project.example, org.codehaus.jackson.jaxrs</param-value>
</init-param>

And Bob is my uncle! Onto the next problem....

Kind Regards,

Nick.

Re: Fwd: JsonJaxbModule for JAX-RS 2.0

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Ok

Just to try to give the idea of what i was thinking of:
http://www.adam-bien.com/roller/abien/entry/configuring_jax_rs_2_01 for
server side (but jersey has its own scanning for auto discovery on server
side it seems) and json links are
https://jersey.java.net/documentation/latest/modules-and-dependencies.html.
Think to add needed deps (jackson, moxy...depending your choice).

Last note: cxf is not yet 100% jaxrs2 but upgrzding cxf to v2.7 and
replacing jaxrs api in tomee would do something close and more integrated i
think
Le 27 juil. 2013 00:43, "Nick Khamis" <sy...@gmail.com> a écrit :

> Romain, mon ami! Let's go! For now, I will Tomcat it, I thought tomee
> would be closer spec'ed to EE7 (i.e., hackable). But I will downgrade
> to Tomcat for now and see how far I can go.
>
> Nick from Toronto/Montreal
>

Re: Fwd: JsonJaxbModule for JAX-RS 2.0

Posted by Nick Khamis <sy...@gmail.com>.
Romain, mon ami! Let's go! For now, I will Tomcat it, I thought tomee
would be closer spec'ed to EE7 (i.e., hackable). But I will downgrade
to Tomcat for now and see how far I can go.

Nick from Toronto/Montreal

Re: Fwd: JsonJaxbModule for JAX-RS 2.0

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Thats half true in particular for parts of the spec. Ill try to.give
details next week
Le 26 juil. 2013 22:30, "John D. Ament" <jo...@gmail.com> a écrit :

> A single application server version only supports a single Java EE
> specification revision.  Right now, the only Java EE 7 compliant
> application server is GlassFish.  You can hack together some things (e.g.
> CDI 1.1 + JAX-RS 2.0) on Tomcat 7, but it's only going to go so far.
>
>
> On Fri, Jul 26, 2013 at 4:25 PM, Nick Khamis <sy...@gmail.com> wrote:
>
> > John thank you so much for your response. What would one expect from a
> > Tomcat+Jersey 2.0 combination.
> > Would we have support for JAX-RS 2.0 stuff like:
> >
> > Resource Context (Request. Response),
> > Filters  (Request. Response)
> > Interceptors (Writer, Reader),
> > Async
> > Context and Dependencies Injection 1.1
> >
> > I hope these are not to stupid of a question. I always struggle with 1)
> > Servlet Containers 2.5 vs 3.0
> > 2) Application Servers supporting JEE 6,7,8,9,10,321... The needle that
> > broke the back you know?
> >
> > Thanks in Advance,
> >
> > Nick.
> >
> >
> >
> >
> >
>

Re: Fwd: JsonJaxbModule for JAX-RS 2.0

Posted by "John D. Ament" <jo...@gmail.com>.
A single application server version only supports a single Java EE
specification revision.  Right now, the only Java EE 7 compliant
application server is GlassFish.  You can hack together some things (e.g.
CDI 1.1 + JAX-RS 2.0) on Tomcat 7, but it's only going to go so far.


On Fri, Jul 26, 2013 at 4:25 PM, Nick Khamis <sy...@gmail.com> wrote:

> John thank you so much for your response. What would one expect from a
> Tomcat+Jersey 2.0 combination.
> Would we have support for JAX-RS 2.0 stuff like:
>
> Resource Context (Request. Response),
> Filters  (Request. Response)
> Interceptors (Writer, Reader),
> Async
> Context and Dependencies Injection 1.1
>
> I hope these are not to stupid of a question. I always struggle with 1)
> Servlet Containers 2.5 vs 3.0
> 2) Application Servers supporting JEE 6,7,8,9,10,321... The needle that
> broke the back you know?
>
> Thanks in Advance,
>
> Nick.
>
>
>
>
>

Re: Fwd: JsonJaxbModule for JAX-RS 2.0

Posted by Nick Khamis <sy...@gmail.com>.
John thank you so much for your response. What would one expect from a
Tomcat+Jersey 2.0 combination.
Would we have support for JAX-RS 2.0 stuff like:

Resource Context (Request. Response),
Filters  (Request. Response)
Interceptors (Writer, Reader),
Async
Context and Dependencies Injection 1.1

I hope these are not to stupid of a question. I always struggle with 1)
Servlet Containers 2.5 vs 3.0
2) Application Servers supporting JEE 6,7,8,9,10,321... The needle that
broke the back you know?

Thanks in Advance,

Nick.





Re: Fwd: JsonJaxbModule for JAX-RS 2.0

Posted by "John D. Ament" <jo...@gmail.com>.
The regular wine example should not be an issue on Tomee if you're using
JAX-RS 1.1/1.0.  I have no clue what you might need to do with JAX-RS 2.0
(this type of configuration is really not supportable at this time; you may
want to try regular Tomcat + JAX-RS 2.0).


On Fri, Jul 26, 2013 at 3:40 PM, Nick Khamis <sy...@gmail.com> wrote:

> Hello John,
>
> I was am running the following example:
>
>
> http://coenraets.org/blog/2011/12/restful-services-with-jquery-and-java-using-jax-rs-and-jersey/
>
>
> Taking a closer look, his resources "produce" json, but there is no
> actually producing of JSON?
>
> Along with MessageBodyWriter what other options do we have?
>
> Thanks in advance,
>
> Nick.
>

Re: Fwd: JsonJaxbModule for JAX-RS 2.0

Posted by Nick Khamis <sy...@gmail.com>.
Hello John,

I was am running the following example:

http://coenraets.org/blog/2011/12/restful-services-with-jquery-and-java-using-jax-rs-and-jersey/


Taking a closer look, his resources "produce" json, but there is no
actually producing of JSON?

Along with MessageBodyWriter what other options do we have?

Thanks in advance,

Nick.

Re: Fwd: JsonJaxbModule for JAX-RS 2.0

Posted by "John D. Ament" <jo...@gmail.com>.
Hi,

If you need to use a MessageBodyWriter, it needs to be annotated @Provider
and implement the interface.

http://jackson.codehaus.org/javadoc/jax-rs/1.0/javax/ws/rs/ext/MessageBodyWriter.html

then it should get picked up automatically.


On Fri, Jul 26, 2013 at 3:20 PM, Nick Khamis <sy...@gmail.com> wrote:

> Romain, i'm sorry I am drawing a blank. Could you please elaborate? I just
> have a simple resource:
>
> @GET
> @Produces({ MediaType.APPLICATION_JSON})
> public List<Wine> findAll() {
> System.out.println("findAll");
> return dao.findAll();
> }
>
> And a web.xml (3.0) pointing to the resource. This is for JAX-RS 2.0 and
> maven within TOMEE.
> Is there specific example that meets this simple scenario? I did find this
> simple example
> but could not see any mention of adding a json writer?:
>
> http://tomee.apache.org/examples-trunk/rest-example/README.html
>
>
> Sorry, a noob right now...
>
> Nick.
>

Re: Fwd: JsonJaxbModule for JAX-RS 2.0

Posted by Nick Khamis <sy...@gmail.com>.
Romain, i'm sorry I am drawing a blank. Could you please elaborate? I just
have a simple resource:

@GET
@Produces({ MediaType.APPLICATION_JSON})
public List<Wine> findAll() {
System.out.println("findAll");
return dao.findAll();
}

And a web.xml (3.0) pointing to the resource. This is for JAX-RS 2.0 and
maven within TOMEE.
Is there specific example that meets this simple scenario? I did find this
simple example
but could not see any mention of adding a json writer?:

http://tomee.apache.org/examples-trunk/rest-example/README.html


Sorry, a noob right now...

Nick.

Re: Fwd: JsonJaxbModule for JAX-RS 2.0

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Depending your implementation you can need to add the writer for json which
is not on by default. There are a bunch of samples online IIRC
Le 26 juil. 2013 19:33, "Nick Khamis" <sy...@gmail.com> a écrit :

> Romain, thank you so much for your quick response!! I really appreciate it.
> Not sure really. The error I am getting is:
> MessageBodyWriter not found for media type=application/json, type=class
> java.util.ArrayList
>
> And all the solutions are related to JAX-RS 1.x and maven. We are using
> neither. JAX-RS 2.0
> and TOMEE. Any ideas?
>
> Thank you for time.
>
> PS I will post my solution once I actually have one...
>
>
> Nick.
>
>

Re: Fwd: JsonJaxbModule for JAX-RS 2.0

Posted by Nick Khamis <sy...@gmail.com>.
Romain, thank you so much for your quick response!! I really appreciate it.
Not sure really. The error I am getting is:
MessageBodyWriter not found for media type=application/json, type=class
java.util.ArrayList

And all the solutions are related to JAX-RS 1.x and maven. We are using
neither. JAX-RS 2.0
and TOMEE. Any ideas?

Thank you for time.

PS I will post my solution once I actually have one...


Nick.


Re: Fwd: JsonJaxbModule for JAX-RS 2.0

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

No jaxrs 2 works in servlet 3 containers (if you accept to not get the full
ee integration like ejb) but this class doesnt ring a bell for me, is it a
jersey one?
Le 26 juil. 2013 18:57, "Nick Khamis" <sy...@gmail.com> a écrit :

> Hello Everyone,
>
> Our environment is Tomee web profile with JAX-RS 2.0 libraries added to our
> project and api jars on the server.
> We are getting a MessageBodyWriter not found when creating a resource that
> produces json. The quick searching
> I found maven solution however, we do not use maven. Also, I could not find
> the binary for JsonJaxbModule anywhere.
> We do use web.xml for the project, but not sure which dependency we need to
> add and where to find the
> dependency. Is this a JEE6 vs 7 issue?
>
> Thanks in Advance,
>
> Nick.
>