Re: [Resteasy-users] (no subject)

2016-06-06 Thread Systema Sephiroticum
FYI it looks like I was missing async-http-servlet-3.0-3.0.17.Final.jar
Once I added this, I was able to remove my resteasy-servlet entry from
web.xml (as the documentation recommends for servlet 3.0 containers) and
comment out the addition of my Resource class added to singletons in my
class extending Application. Looks like this approach is possible after
all!: )

Now my concern is, given that I have other entries in web.xml for existing
servlets not being handled by RESTEasy, is there any way for RESTEasy to
handle routing only for my @Path-annotated resources? Or is it all or
nothing when it comes to having RESTEasy handle endpoints? I could set
@ApplicationPath("") in my application, but then it intercepts everything.
I'd prefer that it only intercepted paths for which it has resources, so
that I can gradually move existing endpoints into resteasy without having
to prefix them with "/rest" or something as I do so.

I know I can explicitly list out all my resources with the
resteasy.resources context-param in web.xml, but this seems like a step
backwards.

On Mon, Jun 6, 2016 at 9:33 AM, Sean Dawson 
wrote:

>
> Hi again,
>
> I'm currently maintaining some RestEasy code that includes both newer and
> legacy ways of setting things up - and I'm no completely clear on what the
> latest and greatest way of doing everything RestEasy is at this point.  I'm
> working my way there but obviously as most of us, have to balance competing
> priorities.
>
> So unfortunately I can't give you a really good answer now.  I would read
> the docs and try to separate the old way of doing things with the
> new/current recommended.  Also maybe look at the most recent RestEasy
> examples you can find in the code base.
>
--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] (no subject)

2016-06-06 Thread Sean Dawson
Hi again,

I'm currently maintaining some RestEasy code that includes both newer and
legacy ways of setting things up - and I'm no completely clear on what the
latest and greatest way of doing everything RestEasy is at this point.  I'm
working my way there but obviously as most of us, have to balance competing
priorities.

So unfortunately I can't give you a really good answer now.  I would read
the docs and try to separate the old way of doing things with the
new/current recommended.  Also maybe look at the most recent RestEasy
examples you can find in the code base.


On Fri, Jun 3, 2016 at 7:10 PM, Systema Sephiroticum <
fallen.tab...@gmail.com> wrote:

> Also, sorry for the double-email, but I noticed one other thing. the
> JSR311 spec recommends:
>
> "If not using the Servlet 3 framework pluggability mechanism (e.g. in a
> pre-Servet 3.0 container), the servlet-class orfilter-class element of the
>  web.xml descriptor SHOULD name the JAX-RS implementation-supplied
> servlet or filter class respectively. The Application subclass SHOULD be
> identified using an init-param with a param-name ofjavax.ws.rs.Application
> ."
>
> I'm a bit confused at this because, although I *am* using a servlet 3.0
> container (Tomcat 7.0.59), your example that works still utilizes the
> init-param with java.ws.rs.Application. Is this only necessary because I
> don't have Maven, and can't add a dependency as mentioned here?
>
>
> http://docs.jboss.org/resteasy/docs/3.0.17.Final/userguide/html_single/index.html#d4e113
>
> Or is resteasy doing something a little different than the JAX-RS spec's
> recommendation, instead requiring this init-param?
>
> Thanks again
>
>
> On Fri, Jun 3, 2016 at 2:45 PM, Systema Sephiroticum <
> fallen.tab...@gmail.com> wrote:
>
>> Hi Sean,
>>
>> Thank you for your swift reply. That sample program does indeed work with
>> my tomcat. The magic line is " singletons.add(new HelloWorld()); ", however
>> I'm wondering if it is possible to have RESTeasy automatically scan for
>> these resources. According to the resteasy docs, "If you return any empty
>> set for by classes and singletons [in your Application], your WAR will be
>> scanned for JAX-RS annotation resource and provider classes." But this
>> doesn't seem to happen when I return null or an empty set from
>> getSingletons(). There was a resteasy.scan web.xml property, however
>> apparently it has been deprecated, and resteasy is supposed to scan for
>> these resources itself. This is the behavior that I am hoping for. I'm
>> using an exploded-war deployment locally for my application, which I hope
>> does not preclude me from taking advantage of this functionality.
>>
>> Fortunately, I got my logging working. The warning when I attempt to use
>> the old resteasy.scan is "resteasy.scan is no longer supported. Use a
>> servlet 3.0 container and the ResteasyServletInitializer". This seems like
>> a stab in the right direction, but I'm not sure what to do with
>> ResteasyServletInitializer.
>>
>> Again, very appreciative of your response.
>>
>> On Fri, Jun 3, 2016 at 9:36 AM, Sean Dawson 
>> wrote:
>>
>>>
>>> You should definitely read through all the documentation here:
>>>
>>>
>>> http://docs.jboss.org/resteasy/docs/3.0.17.Final/userguide/html_single/index.html
>>>
>>> And take a look at the examples.
>>>
>>> This is a bit of an old way of doing things, but based on what you have,
>>> and the info here:
>>>
>>> http://www.mkyong.com/webservices/jax-rs/resteasy-hello-world-example/
>>>
>>> I got your example working.  I did use maven (dependencies on RestEasy
>>> and Jetty).  But here are the files:
>>>
>>> import java.util.HashSet;
>>> import java.util.Set;
>>> import javax.ws.rs.ApplicationPath;
>>> import javax.ws.rs.core.Application;
>>>
>>> @ApplicationPath("/rest")
>>> public class RootApplication extends Application
>>> {
>>> private Set singletons = new HashSet();
>>>
>>> public RootApplication()
>>> {
>>> singletons.add(new HelloWorld());
>>> }
>>>
>>> @Override
>>> public Set getSingletons()
>>> {
>>> return singletons;
>>> }
>>> }
>>>
>>>
>>> import java.util.Date;
>>> import javax.ws.rs.GET;
>>> import javax.ws.rs.Path;
>>> import javax.ws.rs.Produces;
>>>
>>> @Path("hello")
>>> public class HelloWorld
>>> {
>>> @GET
>>> @Produces("text/plain")
>>> public String helloResource()
>>> {
>>> return "Hello! It's " + new Date();
>>> }
>>> }
>>>
>>>
>>> import java.io.File;
>>> import org.eclipse.jetty.server.Server;
>>> import org.eclipse.jetty.webapp.WebAppContext;
>>>
>>> public class ReTest
>>> {
>>> public static void main(String[] args) throws Exception
>>> {
>>> WebAppContext context = new WebAppContext();
>>> context.setDescriptor(new 
>>> File("resteasytest/src/main/webapp/WEB-INF/web.xml").getAbsolutePath());
>>> context.setResourceBase(new 
>>> File("resteasytest/src/main/webapp").getAbsolutePath());
>>> context.setC

Re: [Resteasy-users] (no subject)

2016-06-03 Thread Systema Sephiroticum
Hi Sean,

Thank you for your swift reply. That sample program does indeed work with
my tomcat. The magic line is " singletons.add(new HelloWorld()); ", however
I'm wondering if it is possible to have RESTeasy automatically scan for
these resources. According to the resteasy docs, "If you return any empty
set for by classes and singletons [in your Application], your WAR will be
scanned for JAX-RS annotation resource and provider classes." But this
doesn't seem to happen when I return null or an empty set from
getSingletons(). There was a resteasy.scan web.xml property, however
apparently it has been deprecated, and resteasy is supposed to scan for
these resources itself. This is the behavior that I am hoping for. I'm
using an exploded-war deployment locally for my application, which I hope
does not preclude me from taking advantage of this functionality.

Fortunately, I got my logging working. The warning when I attempt to use
the old resteasy.scan is "resteasy.scan is no longer supported. Use a
servlet 3.0 container and the ResteasyServletInitializer". This seems like
a stab in the right direction, but I'm not sure what to do with
ResteasyServletInitializer.

Again, very appreciative of your response.

On Fri, Jun 3, 2016 at 9:36 AM, Sean Dawson 
wrote:

>
> You should definitely read through all the documentation here:
>
>
> http://docs.jboss.org/resteasy/docs/3.0.17.Final/userguide/html_single/index.html
>
> And take a look at the examples.
>
> This is a bit of an old way of doing things, but based on what you have,
> and the info here:
>
> http://www.mkyong.com/webservices/jax-rs/resteasy-hello-world-example/
>
> I got your example working.  I did use maven (dependencies on RestEasy and
> Jetty).  But here are the files:
>
> import java.util.HashSet;
> import java.util.Set;
> import javax.ws.rs.ApplicationPath;
> import javax.ws.rs.core.Application;
>
> @ApplicationPath("/rest")
> public class RootApplication extends Application
> {
> private Set singletons = new HashSet();
>
> public RootApplication()
> {
> singletons.add(new HelloWorld());
> }
>
> @Override
> public Set getSingletons()
> {
> return singletons;
> }
> }
>
>
> import java.util.Date;
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
>
> @Path("hello")
> public class HelloWorld
> {
> @GET
> @Produces("text/plain")
> public String helloResource()
> {
> return "Hello! It's " + new Date();
> }
> }
>
>
> import java.io.File;
> import org.eclipse.jetty.server.Server;
> import org.eclipse.jetty.webapp.WebAppContext;
>
> public class ReTest
> {
> public static void main(String[] args) throws Exception
> {
> WebAppContext context = new WebAppContext();
> context.setDescriptor(new 
> File("resteasytest/src/main/webapp/WEB-INF/web.xml").getAbsolutePath());
> context.setResourceBase(new 
> File("resteasytest/src/main/webapp").getAbsolutePath());
> context.setContextPath("/");
> Server server = new Server(8123);
> server.setHandler(context);
> server.start();
> }
> }
>
>
> 
> http://java.sun.com/xml/ns/javaee"; 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
> http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd";
>  version="3.0">
>
> 
> resteasy-servlet
> 
> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
> 
> 
> javax.ws.rs.Application
> RootApplication
> 
> 
>
> 
> resteasy-servlet
> /*
> 
>
> 
>
>
> Running ReTest and going to:
> http://localhost:8123/hello
>
>
> Resulted in:
>
> Hello! It's Fri Jun 03 12:30:47 EDT 2016
>
>
>
> On Thu, Jun 2, 2016 at 11:01 PM, Systema Sephiroticum <
> fallen.tab...@gmail.com> wrote:
>
>>I've been trying for a few days now to obtain a response with RESTeasy,
>> only with very little success--I was able to receive a request on my
>> Resource class when explicitly adding said resource class as a
>> singleton in
>> my Application-extending class, but I've had no luck in trying to make
>> RESTeasy scan for these classes automatically, even with
>> resteasy.scan set
>> to true in web.xml
>>
>> My web.xml file is empty except for a resteasy.logger.type
>> context-param
>> specifying LOG4J.
>>
>> Here's a basic application class (apologies for lack of formatting,
>> seems like any font change leads to my email getting bounced):
>>
>>
>>
>> import javax.ws.rs.ApplicationPath;
>> import javax.ws.rs.core.Application;
>> @ApplicationPath("/rest")
>> public class RootApplication extends Application {
>> }
>>
>>
>> And here's a basic resource class:
>>
>>
>>
>> import java.util.Date;
>> import javax.ws.rs.GET;
>> import javax.ws.rs.Path;
>> import javax.ws.rs.Produces;
>>
>>  

Re: [Resteasy-users] (no subject)

2016-06-03 Thread Sean Dawson
You should definitely read through all the documentation here:

http://docs.jboss.org/resteasy/docs/3.0.17.Final/userguide/html_single/index.html

And take a look at the examples.

This is a bit of an old way of doing things, but based on what you have,
and the info here:

http://www.mkyong.com/webservices/jax-rs/resteasy-hello-world-example/

I got your example working.  I did use maven (dependencies on RestEasy and
Jetty).  But here are the files:

import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("/rest")
public class RootApplication extends Application
{
private Set singletons = new HashSet();

public RootApplication()
{
singletons.add(new HelloWorld());
}

@Override
public Set getSingletons()
{
return singletons;
}
}


import java.util.Date;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

@Path("hello")
public class HelloWorld
{
@GET
@Produces("text/plain")
public String helloResource()
{
return "Hello! It's " + new Date();
}
}


import java.io.File;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

public class ReTest
{
public static void main(String[] args) throws Exception
{
WebAppContext context = new WebAppContext();
context.setDescriptor(new
File("resteasytest/src/main/webapp/WEB-INF/web.xml").getAbsolutePath());
context.setResourceBase(new
File("resteasytest/src/main/webapp").getAbsolutePath());
context.setContextPath("/");
Server server = new Server(8123);
server.setHandler(context);
server.start();
}
}



http://java.sun.com/xml/ns/javaee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd";
 version="3.0">


resteasy-servlet

org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher


javax.ws.rs.Application
RootApplication




resteasy-servlet
/*





Running ReTest and going to:
http://localhost:8123/hello


Resulted in:

Hello! It's Fri Jun 03 12:30:47 EDT 2016



On Thu, Jun 2, 2016 at 11:01 PM, Systema Sephiroticum <
fallen.tab...@gmail.com> wrote:

>I've been trying for a few days now to obtain a response with RESTeasy,
> only with very little success--I was able to receive a request on my
> Resource class when explicitly adding said resource class as a
> singleton in
> my Application-extending class, but I've had no luck in trying to make
> RESTeasy scan for these classes automatically, even with resteasy.scan
> set
> to true in web.xml
>
> My web.xml file is empty except for a resteasy.logger.type
> context-param
> specifying LOG4J.
>
> Here's a basic application class (apologies for lack of formatting,
> seems like any font change leads to my email getting bounced):
>
>
>
> import javax.ws.rs.ApplicationPath;
> import javax.ws.rs.core.Application;
> @ApplicationPath("/rest")
> public class RootApplication extends Application {
> }
>
>
> And here's a basic resource class:
>
>
>
> import java.util.Date;
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
>
> @Path("/hello")
> public class HelloWorld {
>@GET
>@Produces("text/plain")
>public String helloResource() {
>   return "Hello! It's "+new Date();
>}
> }
>
>
>
>
> I don't use Maven, so I have no pom.xml, though to my knowledge this
> isn't
> relevant if I just grab the needed jars myself. These are the jars I've
> added:
>
> httpclient-4.3.jar
> annotations.jar
> jars-api-3.0.9.Final.jar
> resteasy-jaxrs-3.0.17.Final.jar
>
> I feel as though this would be easier to diagnose if restEASY logged
> anything, however it's not doing so despite having this property in my
> log4j.properties:
>
> log4j.logger.org.jboss.resteasy=INFO
>
>
> Visiting http://localhost/rest/hello  after all this just returns a
> basic
> Tomcat 404 page, "The requested resource is not available". I really
> have
> no idea what's going on under the hood with logging not working. My
> tomcat
> is functioning otherwise, also.
>
> Any help would be greatly appreciated.
>
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and
> traffic
> patterns at an interface-level. Reveals which users, apps, and protocols
> are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/30529

Re: [Resteasy-users] (no subject)

2014-04-01 Thread Marcel Overdijk
Yes that's probably what I will try to use. I only wonder if there is maybe 
something out of the box?

> On 01 Apr 2014, at 21:59, William Antônio Siqueira 
>  wrote:
> 
> Hello,
> 
> have you thought about using an interceptor?
> 
> --
> William Antônio Siqueira
> Java Support Analyst
> 
> http://fxapps.blogspot.com
> http://www.williamantonio.wordpress.com
> http://williamprogrammer.com
> 
> 
> 2014-04-01 15:35 GMT-03:00 Marcel Overdijk :
>> 
>> 
>> 
>> I have a (Groovy) resteasy resource like:
>> 
>> @POST
>> @Consumes(MediaType.APPLICATION_JSON)
>> @Produces(MediaType.APPLICATION_JSON)
>> def create(CustomerRequestBody body) {
>> def customer = new Customer()
>> bindData(customer, body)
>> def violations = validate(customer)
>> if (violations) {
>> return 
>> Response.status(BAD_REQUEST).entity(toJSONArray(violations)).build()
>> } else {
>> customer.save()
>> return Response.status(OK).entity(toJSONObject(customer)).build()
>> }
>> }
>> 
>> The resource only accepts json requests.
>> The CustomerRequestBody is a simple POJO (or POGO in my case).
>> 
>> When I post a empty response to the this resource (even with content type 
>> set to json) I would expect a 415 unsupported media type.
>> 
>> However the actual is that the request ends up in the resource but the 
>> CustomerRequestBody body variable is null.
>> 
>> What is the best way to globally disallow the payload to be empty and return 
>> a 415?
>> Note that sending {} to the resource works as expected and the 
>> CustomerRequestBody body variable is not empty; only it's properties are 
>> empty as expected.
>> 
>> 
>> Cheers,
>> Marcel
>> 
>> 
>> 
>> --
>> 
>> ___
>> Resteasy-users mailing list
>> Resteasy-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/resteasy-users
> 
--
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] (no subject)

2014-04-01 Thread William Antônio Siqueira
Hello,

have you thought about using an interceptor?

--
*William Antônio Siqueira*
*Java Support Analyst*

*http://fxapps.blogspot.com *
*http://www.williamantonio.wordpress.com
*
*http://williamprogrammer.com *


2014-04-01 15:35 GMT-03:00 Marcel Overdijk :

>
>
>
> I have a (Groovy) resteasy resource like:
>
> @POST
> @Consumes(MediaType.APPLICATION_JSON)
> @Produces(MediaType.APPLICATION_JSON)
> def create(CustomerRequestBody body) {
> def customer = new Customer()
> bindData(customer, body)
> def violations = validate(customer)
> if (violations) {
> return
> Response.status(BAD_REQUEST).entity(toJSONArray(violations)).build()
> } else {
> customer.save()
> return
> Response.status(OK).entity(toJSONObject(customer)).build()
> }
> }
>
> The resource only accepts json requests.
> The CustomerRequestBody is a simple POJO (or POGO in my case).
>
> When I post a empty response to the this resource (even with content type
> set to json) I would expect a 415 unsupported media type.
>
> However the actual is that the request ends up in the resource but the
> CustomerRequestBody body variable is null.
>
> What is the best way to globally disallow the payload to be empty and
> return a 415?
> Note that sending {} to the resource works as expected and the
> CustomerRequestBody body variable is not empty; only it's properties are
> empty as expected.
>
>
> Cheers,
> Marcel
>
>
>
>
> --
>
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
>
--
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users