users@grizzly.java.net

SEVERE error thrown with grizzly-http-webserver-1.7.2

From: Danijel <danijel.bjelajac_at_gmail.com>
Date: Fri, 7 Mar 2008 08:44:39 -0800 (PST)

Hello all,

I've been using grizzly for some time now, since version 1.5.X
I was developing an app that was suppose to receive data over http and then
using ARP return response later or after expiration of some time interval.
My app did not need a full web app running, meaning I did not have a need
for any web pages, servlets, filters, web.xml or anything like that.
First I tried jetty continuations and that did not work for me.
Then I found grizzly, embedded it with it and it worked great. I was able to
receive data on port via http protocol and eventually I figured out your
AsyncFilter stuff and completed the app.

First for my getting to know grizzly purpose I created this simple
EmbeddedServer class just to figure out how to initialy receive data.

With all the different jars before complete http bundle that was published
and with 1.7.1 version of
grizzly-http-webserver jar this simple class works fine.
But when I wanted to update to 1.7.2 version this SEVERE error shows up,
even though everything still works.

Here is my EmbeddedServer server code and outputs running first 1.7.1 jar
and then output of 1.7.2 jar
In both cases response get written to the web browser when I go to
http://localhost:8282/test

import java.net.HttpURLConnection;
import com.sun.grizzly.http.SelectorThread;
import com.sun.grizzly.tcp.Adapter;
import com.sun.grizzly.tcp.OutputBuffer;
import com.sun.grizzly.tcp.Request;
import com.sun.grizzly.tcp.Response;
import com.sun.grizzly.util.buf.ByteChunk;

public class EmbeddedServer implements Adapter {
        public static void main( String[] args ) {
                SelectorThread selectorThread = new SelectorThread();
                selectorThread.setPort( 8282 );
                selectorThread.setAdapter( new EmbeddedServer() );
                selectorThread.setDisplayConfiguration( true );
                try {
                        selectorThread.initEndpoint();
                        selectorThread.startEndpoint();
                } catch ( Exception e ) {
                        System.out.println( "Exception in SelectorThread: " + e );
                } finally {
                        if ( selectorThread.isRunning() ) {
                                selectorThread.stopEndpoint();
                        }
                }
        }

        public void service( Request request, Response response ) throws Exception
{
                String requestURI = request.requestURI().toString();
                System.out.println( "New incoming request with URI: " + requestURI );
                response.setStatus( HttpURLConnection.HTTP_OK );
                byte[] bytes = "Here is my response text".getBytes();
                ByteChunk chunk = new ByteChunk();
                response.setContentLength( bytes.length );
                response.setContentType( "text/plain" );
                chunk.append( bytes, 0, bytes.length );
                OutputBuffer buffer = response.getOutputBuffer();
                buffer.doWrite( chunk, response );
                response.finish();
                // }
        }

        public void afterService( Request request, Response response ) throws
Exception {
                request.recycle();
                response.recycle();
        }

        @Override
        public void fireAdapterEvent( String arg0, Object arg1 ) {
                // TODO Auto-generated method stub
        }
}


Output using grizzly-http-webserver-1.7.1.jar :

Mar 7, 2008 5:21:05 PM com.sun.grizzly.http.SelectorThread
displayConfiguration
INFO:
 Grizzly configuration for port 8282
         maxThreads: 20
         minThreads: 5
         ByteBuffer size: 8192
         useDirectByteBuffer: false
         useByteBufferView: false
         maxHttpHeaderSize: 8192
         maxKeepAliveRequests: 256
         keepAliveTimeoutInSeconds: 30
         Static File Cache enabled: true
         Stream Algorithm : com.sun.grizzly.http.algorithms.NoParsingAlgorithm
         Pipeline : com.sun.grizzly.http.LinkedListPipeline
         Round Robin Selector Algorithm enabled: false
         Round Robin Selector pool size: 0
         recycleTasks: true
         Asynchronous Request Processing enabled: false
New incoming request with URI: /test


Output using grizzly-http-webserver-1.7.2.jar :

Mar 7, 2008 5:24:53 PM com.sun.grizzly.http.SelectorThread initEndpoint
SEVERE: File Cache is not enabled. Make sure the setWebAppRootPath() is
invoked before starting this SelectorThread
Mar 7, 2008 5:24:53 PM com.sun.grizzly.http.SelectorThread
displayConfiguration
INFO:
 Grizzly configuration for port 8282
         maxThreads: 5
         minThreads: 5
         ByteBuffer size: 8192
         useDirectByteBuffer: false
         useByteBufferView: false
         maxHttpHeaderSize: 8192
         maxKeepAliveRequests: 256
         keepAliveTimeoutInSeconds: 30
         Static File Cache enabled: true
         Stream Algorithm : com.sun.grizzly.http.algorithms.NoParsingAlgorithm
         Pipeline : com.sun.grizzly.http.LinkedListPipeline
         Round Robin Selector Algorithm enabled: false
         Round Robin Selector pool size: 0
         recycleTasks: true
         Asynchronous Request Processing enabled: false
New incoming request with URI: /test

Notice second line in this last 1.7.2 output, what changed?
Do I need to worry about it?

Also now I need to extend my app to support https, I tried using
SSLSelectorThread,
I set SSLConfig to it, and pretty much first wanted to try same thing like
with this EmbeddedServer

But event though when I go to https://localhost:8282/test I get prompted
about unsigned certificate, service method never gets called.

Can someone help me with HTTPS support?
I can not find some example of using Grizzly as HTTPS server, does anyone
has one?

Thanks and sorry for such a long post

-----
--
Danijel
-- 
View this message in context: http://www.nabble.com/SEVERE-error-thrown-with-grizzly-http-webserver-1.7.2-tp15900600p15900600.html
Sent from the Grizzly - Users mailing list archive at Nabble.com.