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