users@jersey.java.net

[Jersey] Re: Jersey REST Resource Config

From: Robert Middleton <osfan6313_at_gmail.com>
Date: Fri, 11 Dec 2015 11:43:26 -0500

Hi Jennifer,

I think I was a little unclear in my question. I don't want to actually
turn on logging, that was just a convenient example. I'm attempting to
configure Genson for use with Jersey, but whenever I call the register()
method on my Application class I always get a 404 error when attempting to
get a value from a REST endpoint. I just tried it again, and even doing
the following causes the REST endpoints to no longer work:

    public MyApplication(){
        register( new Object() );
        property( ServerProperties.PROVIDER_CLASSPATH,
"com.rm5248.testmavenjersey" );
    }

Is there something that I am configuring incorrectly in this case?

The code that I based it off of is the following:

new ResourceConfig().register(new GensonJaxRSFeature().use(myCustomGenson));

-Robert Middleton

On Fri, Dec 11, 2015 at 9:49 AM, Jennifer Sears <jsears_at_galtech.net> wrote:

> You need to provide a logging filter class to use depending on which
> loggging framework you're using i.e.:
> Logger jerseyLogger =
> org.apache.logging.log4j.jul.LogManager.getLogManager().getLogger(IdentityRestApplication.class.getName());
> registerInstances(new LoggingFilter(jerseyLogger, false));
>
> On Fri, Dec 11, 2015 at 8:55 AM, Robert Middleton <osfan6313_at_gmail.com>
> wrote:
>
>> Hello,
>>
>> I'm using Jersey to create a REST-based web service, and I've got a
>> question as to how to set Jersey up.
>>
>> My situtation is that I'm using jersey-container-servlet(2.22.1) from
>> maven central on Tomcat 8. I have an application that looks like the
>> following:
>>
>> @ApplicationPath( "foo" )
>> public class MyApplication extends ResourceConfig {
>>
>> public MyApplication(){
>> //register( new LoggingFilter() );
>> property( ServerProperties.PROVIDER_CLASSPATH,
>> "com.rm5248.testmavenjersey" );
>> }
>> }
>>
>> This works fine, until I un-comment the first line in the constructor(
>> the call to register() ). At that point, I get a 404 error whenever I try
>> to hit any of the REST endpoints. Am I doing something wrong here? From
>> the documentation that I have read, it seems like this should work.
>>
>> -Robert Middleton
>>
>
>