Oh, I see what the problem is. You're extracting the application context
path from an internal context handler that knows nothing of the configured
context path. Requests for routed by path to this handler by a
ContextRoutingHandler
<http://www.dropwizard.io/1.0.0/dropwizard-jetty/apidocs/io/dropwizard/jetty/ContextRoutingHandler.html>,
which wraps this internal context handler.

What you could do is select the applicationContextPath field from the
Configuration argument to your application's `run` method. Unfortunately,
`Configuration#getServerFactory()` returns a ServerFactory interface, so
you'd have to cast it to a SimpleServerFactory
<http://www.dropwizard.io/1.0.0/dropwizard-core/apidocs/io/dropwizard/server/SimpleServerFactory.html>
and then invoke `SimpleServerFactory#getApplicationContextPath()`.

On Mon, Sep 12, 2016 at 11:42 PM, Anurag Sharma <[email protected]>
wrote:

> Hi Evan
>
> I had the yml file already indented as you mentioned.
>
> thanks
> Anurag
>
> On Tuesday, 13 September 2016 06:08:20 UTC+5:30, Evan Meagher wrote:
>>
>> You need to indent the YAML lines so that they're nested according to the
>> Dropwizard configuration format
>> <http://www.dropwizard.io/1.0.0/docs/manual/configuration.html#servers>.
>>
>> Try this:
>>
>> server:
>>   type: simple
>>   applicationContextPath: /administration
>>   adminContextPath: /admin
>>   connector:
>>     type: http
>>     port: 8061
>>   registerDefaultExceptionMappers: false
>>
>>
>> On Mon, Sep 12, 2016 at 1:28 AM, Anurag Sharma <[email protected]>
>> wrote:
>>
>>> I am using server configuration in yml file which looks like as below
>>>
>>> server:
>>> type: simple
>>>
>>> connector:
>>>   type: http
>>>   port: 8061
>>>
>>> applicationContextPath: /administration
>>> adminContextPath: /admin
>>> #disable the registration of default Jersey ExceptionMappers
>>> registerDefaultExceptionMappers: false
>>>
>>> I want to get "applicationContextPath" when I start my dropwizard
>>> service.
>>>
>>> I am trying to get it using
>>>
>>> environment.getApplicationContext().getContextPath();
>>>
>>> but I am getting "/" i.e. default value. Is there anyway to get this.
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "dropwizard-user" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Evan Meagher
>>
> --
> You received this message because you are subscribed to the Google Groups
> "dropwizard-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Evan Meagher

-- 
You received this message because you are subscribed to the Google Groups 
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to