users@jersey.java.net

[Jersey] Re: Where to put code that should be called at deployment time?

From: Edward Burns <edward.burns_at_oracle.com>
Date: Mon, 6 Jan 2014 08:07:33 -0800

Hello Michal,

Thanks for your prompt reply.

>>>>> On Mon, 06 Jan 2014 15:46:13 +0100, Michal Gajdos <michal.gajdos_at_oracle.com> said:

MG> Hi Ed,
MG> are you registering your FaceletMvcFeature in your application and it's
MG> still not invoked?

Yes, my application does the following.

package helloWorld;

import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.mvc.facelets.FaceletsMvcFeature;

@javax.ws.rs.ApplicationPath("webresources")
public class ApplicationConfig extends ResourceConfig {
    
    public ApplicationConfig() {
        packages(HelloWorld.class.getPackage().getName());
        
        register(FaceletsMvcFeature.class);
    }

}

I know this is working, because the FaceletsMvcFeature is just the
jersey-mvc-jsp module that I cp -r'd and renamed and repackaged. My
sample app, which does this:

@Path("helloworld")
public class HelloWorld {

    /**
     * Creates a new instance of HelloWorld
     */
    public HelloWorld() {
    }

    /**
     * Retrieves representation of an instance of helloWorld.HelloWorld
     * @return an instance of java.lang.String
     */
    @GET
    @Produces("text/html")
    public Viewable getHtml() {
        return new Viewable("index.jsp", "INDEX");
    }

    /**
     * PUT method for updating or creating an instance of HelloWorld
     * @param content representation for the resource
     * @return an HTTP response with content of the updated or created resource.
     */
    @PUT
    @Consumes("text/html")
    public void putHtml(String content) {
    }
}

*does* work still. FWIW, this is on 2.4.1 with GlassFish 4.0. I want
to stick with what ships in GlassFish 4.0 if possible.

Ed