users@jersey.java.net

[Jersey] Re: Running jersey-test under Maven

From: Ryan Stewart <rds6235_at_gmail.com>
Date: Wed, 23 Mar 2011 12:05:15 -0500

On the contrary, I can have the jmaki sample run with a
ClasspathResourceConfig just fine. Just change this:
    public JMakiBackendWebappTest() throws Exception {
         super(new WebAppDescriptor.Builder("com.sun.jersey.samples.jmaki")
                .contextPath("/jMakiBackend")
                .servletPath("/webresources")
                .build());
    }

to this:
    public JMakiBackendWebappTest() throws Exception {
         super(new WebAppDescriptor.Builder()
                 .initParam(ServletContainer.RESOURCE_CONFIG_CLASS,
ClasspathResourceConfig.class.getName())
                 .initParam(ClasspathResourceConfig.PROPERTY_CLASSPATH,
"target/classes")
                 .contextPath("/jMakiBackend")
                 .servletPath("/webresources")
                 .build());
    }

I'm not sure why you'd want to do this instead of just using a
PackagesResourceConfig, though. It seems much less intuitive and binds you
to the file system instead of using the classpath directly, as is normally
done in Java.

On Tue, Mar 22, 2011 at 4:27 PM, Gili <cowwoc_at_bbs.darktech.org> wrote:

>
> Srinivas Naresh Bhimisetty wrote:
> >
> > Gili,
> >
> > jersey-test should run without any issues under Maven, when you invoke
> > the package goal which creates the war file.
> >
> > May be you can refer the jmaki-backend jersey sample, which has some
> > Provider classes. The test which runs on the Grizzly web container does
> > run
> > without any issue. BTW, which test container are you trying this with?
> Did
> > you try that with the grizzly web test container?
>
> Hi Naresh,
>
> I am using the Grizzly web container. The JMaki sample you referred to
> isn't
> the best example because it uses the package ResourceConfig. What I am
> saying is that if you try using the ClasspathResourceConfig it will not
> find
> the built-in Jersey providers. In fact, the JMaki example suffers from the
> same problem. If you run it, you will notice it says:
>
> INFO: Provider classes found:
> class com.sun.jersey.samples.jmaki.config.JAXBContextResolver
>
> Notice how none of the built-in providers show up.
>
> Gili
>
> --
> View this message in context:
> http://jersey.576304.n2.nabble.com/Running-jersey-test-under-Maven-tp6191134p6198030.html
> Sent from the Jersey mailing list archive at Nabble.com.
>