users@grizzly.java.net

Re: Changing default error page

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Fri, 23 May 2014 10:52:14 -0700

Please use this method:
server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI),
rc, false);

to not start the HttpServer.

WBR,
Alexey.

On 23.05.14 08:58, Dave Trombley wrote:
>
> I'm starting the server after trying to configure it:
>
> server =
> GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
> ErrorPageGenerator epg = new ErrorPageGenerator(){
> @Override
> public String generate(Request request, int status, String
> reasonPhrase,
> String description,
> Throwable exception) {
> StringBuilder sb = new StringBuilder();
> ByteArrayOutputStream baos = new ByteArrayOutputStream();
> PrintStream ps = new PrintStream(baos);
> exception.printStackTrace(ps);
> ps.close();
> sb.append(new String(baos.toByteArray()));
> System.out.println(sb.toString());
> return sb.toString();
> }
> };
> server.getServerConfiguration().setDefaultErrorPageGenerator(epg);
> server.start();
>
>
> I've also tried setting the default error page generator of the
> NetworkListener:
>
> server.getListener("grizzly").setDefaultErrorPageGenerator(epg);
>
> Sill getting the default error page "Request Failed".
>
> I can't get to look at that exception with any logging
> configurations I've tried, either - is there documentation on any of
> this somewhere?
>
> Thanks again,
> -David
>
>
>
> On 05/23/2014 01:19 AM, Oleksiy Stashok wrote:
>> Hi David,
>>
>> I guess it's because the server is started at the time you try to
>> assign error page generator.
>> Try to initialize non-started Grizzly HttpServer (it should be
>> possible to do in Jersey 2.x via GrizzlyHttpServerFactory), set the
>> default error page generator and then start the server.
>> Let us know if it worked.
>>
>> Thanks.
>>
>> WBR,
>> Alexey.
>>
>> On 22.05.14 21:21, Dave Trombley wrote:
>>>
>>> Hi all -
>>>
>>> Can someone explain how to change the default error message
>>> (yellow/brown "Request Failed")? Several of the classes in the API
>>> have .setDefaultErrorPageGenerator(), and none of them seem to have
>>> any effect...
>>>
>>> I'm using Jersey and creating the server via
>>> GrizzlyHttpServerFactory.createHttpServer(uri, rc);
>>>
>>> Thanks,
>>> -David
>>
>