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 <seandawson2...@gmail.com>
>> 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<Object> singletons = new HashSet<Object>();
>>>
>>>     public RootApplication()
>>>     {
>>>         singletons.add(new HelloWorld());
>>>     }
>>>
>>>     @Override
>>>     public Set<Object> 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();
>>>     }
>>> }
>>>
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <web-app xmlns="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">
>>>
>>>     <servlet>
>>>         <servlet-name>resteasy-servlet</servlet-name>
>>>         <servlet-class>
>>>             org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
>>>         </servlet-class>
>>>         <init-param>
>>>             <param-name>javax.ws.rs.Application</param-name>
>>>             <param-value>RootApplication</param-value>
>>>         </init-param>
>>>     </servlet>
>>>
>>>     <servlet-mapping>
>>>         <servlet-name>resteasy-servlet</servlet-name>
>>>         <url-pattern>/*</url-pattern>
>>>     </servlet-mapping>
>>>
>>> </web-app>
>>>
>>>
>>> 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/305295220;132659582;e
>>>> _______________________________________________
>>>> Resteasy-users mailing list
>>>> Resteasy-users@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>>>>
>>>>
>>>
>>
>
------------------------------------------------------------------------------
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

Reply via email to