Iframe streaming with Jruby and Atmosphere

26 messages Options
Embed this post
Permalink
1 2
Michal Hantl-2

Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
Hello Atmosphere users and devs!

I want to start using atmosphere so I downloaded the demo, but I am
not familiar with the Java technologies so my first question is what
server should i use?

What i want to build is a gomoku gameroom, which needs to be
responsive so i want to be doing streaming through iframe.

Also i would like to use jruby most of the time.

I came across this:
http://stackoverflow.com/questions/940143/how-can-i-create-a-servlet-with-jruby-running-with-jetty
Apparently I could run jetty from jruby, which means i might be able
to reload the ruby scripts while in dev mode so this would make me
very happy.

Is this possible? How can I start?

Is anyone doing jruby with atmosphere?


--
S pozdravem, Regards
Michal Hantl

gtalk/jabber: [hidden email]
icq: 241813215

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Jeanfrancois Arcand

Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
Salut,

(long email, but contains what you asked)

Michal Hantl wrote:
> Hello Atmosphere users and devs!
>
> I want to start using atmosphere so I downloaded the demo, but I am
> not familiar with the Java technologies so my first question is what
> server should i use?

Well I'm a little biased as I'm part of the team that designed/build
GlassFish :-)

>
> What i want to build is a gomoku gameroom, which needs to be
> responsive so i want to be doing streaming through iframe.
>
> Also i would like to use jruby most of the time.

Then definitively GlassFish could be used. Take a look @ Arun blogs[1],
which contains a lot of information about JRuby & GlassFish.

>
> I came across this:
> http://stackoverflow.com/questions/940143/how-can-i-create-a-servlet-with-jruby-running-with-jetty
> Apparently I could run jetty from jruby, which means i might be able
> to reload the ruby scripts while in dev mode so this would make me
> very happy.

I see. You need something embeddable in that case as demonstrated in the
link. GlassFish v3 is not yet ready to be used when embedded.

>
> Is this possible? How can I start?

Three solutions. My recommended solution is (3) but it may sound a
little bit complication (but really it's simple) but (1) is quite simple.

(1) Use the above link, and configure the AtmosphereServlet
programmatically by replacing:

>   context = Context.new(server, '/', 0)
>   servlet = TestServlet.new()
>   holder = ServletHolder.new(servlet)

with

servlet = AtmosphereServlet.new()
servlet.addAtmosphereHandler("/", new MyRubyHandler())

where MyRubyHandler() could either implement the AtmosphereHandler

   * http://is.gd/2BYr8

or extend the AbstractReflectorAtmosphereHandler

   * http://is.gd/2BYuq

I'm 100% sure that will works pretty well.

(2) Using jsr223/JDK 6, you can write an AtmosphereHandler which in turn
can invoke JRuby (an example below)

   * http://is.gd/2BYNc

(3) Use a framework like Rails, Goldspike or JRuby Rack on top of
Atmosphere:

   * http://is.gd/2BZoG

Let's say you are using GoldSpike. You can retrieve from the
java_servlet_request variable the AtmosphereEvent:

   * http://is.gd/2C0Rd

AtmosphereEvent e =
$java_servlet_request.getAttribute("org.atmosphere.cpr.AtmosphereEvent")

which will allow you to suspend/resume/broadcast using Atmosphere.

You need to deploy/build your Atmosphere application as described here:

   * http://is.gd/2C0ps

Mainly, your atmosphere.xml will need to have

> <atmosphere-handlers>
>     <atmosphere-handler context-root="/*" class-name="org.atmosphere.handler.ReflectorServletProcessor">
>         <property name="servletClass" value="GoldSpike|Rails|Rack Servlet's name"/>
>     </atmosphere-handler>
> </atmosphere-handlers>


>
> Is anyone doing jruby with atmosphere?
>

I saw some emails on the topic, but since the project is fairly new,
this is the first time I'm seeing a formal request like this one.

So let me know what you will do. I'm really interested to help!

Thanks!

-- Jeanfrancois

[1] http://blogs.sun.com/arungupta/tags/jruby

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Michal Hantl

Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
Thank you very much!

The email didnt find way to my mailbox yet, so thank you for putting it on tweeter too, i am following you:)

Will try jetty first and report how it went + some source code when i get it working.


Jeanfrancois Arcand wrote:
Salut,

(long email, but contains what you asked)

Michal Hantl wrote:
> Hello Atmosphere users and devs!
>
> I want to start using atmosphere so I downloaded the demo, but I am
> not familiar with the Java technologies so my first question is what
> server should i use?

Well I'm a little biased as I'm part of the team that designed/build
GlassFish :-)

>
> What i want to build is a gomoku gameroom, which needs to be
> responsive so i want to be doing streaming through iframe.
>
> Also i would like to use jruby most of the time.

Then definitively GlassFish could be used. Take a look @ Arun blogs[1],
which contains a lot of information about JRuby & GlassFish.

>
> I came across this:
> http://stackoverflow.com/questions/940143/how-can-i-create-a-servlet-with-jruby-running-with-jetty
> Apparently I could run jetty from jruby, which means i might be able
> to reload the ruby scripts while in dev mode so this would make me
> very happy.

I see. You need something embeddable in that case as demonstrated in the
link. GlassFish v3 is not yet ready to be used when embedded.

>
> Is this possible? How can I start?

Three solutions. My recommended solution is (3) but it may sound a
little bit complication (but really it's simple) but (1) is quite simple.

(1) Use the above link, and configure the AtmosphereServlet
programmatically by replacing:

>   context = Context.new(server, '/', 0)
>   servlet = TestServlet.new()
>   holder = ServletHolder.new(servlet)

with

servlet = AtmosphereServlet.new()
servlet.addAtmosphereHandler("/", new MyRubyHandler())

where MyRubyHandler() could either implement the AtmosphereHandler

   * http://is.gd/2BYr8

or extend the AbstractReflectorAtmosphereHandler

   * http://is.gd/2BYuq

I'm 100% sure that will works pretty well.

(2) Using jsr223/JDK 6, you can write an AtmosphereHandler which in turn
can invoke JRuby (an example below)

   * http://is.gd/2BYNc

(3) Use a framework like Rails, Goldspike or JRuby Rack on top of
Atmosphere:

   * http://is.gd/2BZoG

Let's say you are using GoldSpike. You can retrieve from the
java_servlet_request variable the AtmosphereEvent:

   * http://is.gd/2C0Rd

AtmosphereEvent e =
$java_servlet_request.getAttribute("org.atmosphere.cpr.AtmosphereEvent")

which will allow you to suspend/resume/broadcast using Atmosphere.

You need to deploy/build your Atmosphere application as described here:

   * http://is.gd/2C0ps

Mainly, your atmosphere.xml will need to have

> <atmosphere-handlers>
>     <atmosphere-handler context-root="/*" class-name="org.atmosphere.handler.ReflectorServletProcessor">
>         <property name="servletClass" value="GoldSpike|Rails|Rack Servlet's name"/>
>     </atmosphere-handler>
> </atmosphere-handlers>


>
> Is anyone doing jruby with atmosphere?
>

I saw some emails on the topic, but since the project is fairly new,
this is the first time I'm seeing a formal request like this one.

So let me know what you will do. I'm really interested to help!

Thanks!

-- Jeanfrancois

[1] http://blogs.sun.com/arungupta/tags/jruby

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@atmosphere.dev.java.net
For additional commands, e-mail: users-help@atmosphere.dev.java.net
Michal Hantl

Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink

Here is a report on my progress.

I got the jetty demo running, then i added atmosphere and changed the source.

It complained about session so i changed

And now i get this:
(so far no idea what to do with it, but still googling)

Problem accessing /. Reason:

    INTERNAL_SERVER_ERROR
Caused by:

java.lang.NullPointerException
        at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown Source)
        at org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
        at org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
        at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
        at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
        at org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
        at org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:662)
        at org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:647)
        at org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:634)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:324)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)


the source code of my attempt:

require 'java'

Dir["./Java/jetty/*.jar"].each { |jar| require jar }
Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
Dir["./Java/apache/*.jar"].each { |jar| require jar }

include_class 'javax.servlet.http.HttpServlet'
include_class 'org.mortbay.jetty.Server'
include_class 'org.mortbay.jetty.servlet.Context'
include_class 'org.mortbay.jetty.servlet.ServletHolder'
include_class 'org.mortbay.jetty.servlet.ServletHolder'
include_class 'org.atmosphere.cpr.AtmosphereHandler'
include_class 'org.atmosphere.cpr.AtmosphereServlet'
include_class 'org.apache.catalina.CometProcessor'

def main
  server = Server.new(8080)
  #context = Context.new(server, '/', 0)
  context = Context.new(server, '/', Context::SESSIONS)

  servlet = AtmosphereServlet.new()
  servlet.addAtmosphereHandler("/", MyRubyHandler.new())
 
  holder = ServletHolder.new(servlet)
  context.addServlet(holder, '/')
 
  server.start()
end



class MyRubyHandler
  include AtmosphereHandler

  BEGIN_SCRIPT_TAG = '<script>'
  END_SCRIPT_TAG = '</script>'

  def onEvent(event)
        req = event.getRequest();
        res = event.getResponse();

        res.setContentType("text/html")
        res.addHeader("Cache-Control", "private")
        res.addHeader("Pragma", "no-cache")
        res.getWriter().write("<html><body><h1>It works!</h1></body></html>\n");
        res.getWriter().flush();


#        if (req.getMethod().equalsIgnoreCase("GET"))
#            # for IE
#            res.getWriter().write("<!-- Comet is a programming technique that enables web " +
#                    "servers to send data to the client without having any need " +
#                    "for the client to request it. -->\n");
#            res.getWriter().flush();
#
#            #
#            # Mark this connection as suspended.
#            #
#            event.suspend();
#        elsif (req.getMethod().equalsIgnoreCase("POST"))
#            res.setCharacterEncoding("UTF-8");
#            String action = req.getParameterValues("action")[0];
#            String name = req.getParameterValues("name")[0];
#
#            if "login".equals(action)
#                event.getBroadcaster().broadcast(
#                  BEGIN_SCRIPT_TAG +
#                    toJsonp("System Message from " + event.getWebServerName(),
#                      name + " has joined.") +
#                  END_SCRIPT_TAG);
#
#                res.getWriter().write("success");
#                res.getWriter().flush();
#            elsif ("post".equals(action))
#                message = req.getParameterValues("message")[0];
#                event.getBroadcaster().broadcast(
#                  BEGIN_SCRIPT_TAG + toJsonp(name, message) + END_SCRIPT_TAG);
#                res.getWriter().write("success");
#                res.getWriter().flush();
#            else
#                res.setStatus(422);
#
#                res.getWriter().write("success");
#                res.getWriter().flush();
#            end
#        end
        return event;
    end

    def onMessage(event)
        req = event.getRequest();
        res = event.getResponse();

        if (event.isResuming() || event.isResumedOnTimedout())
            script = BEGIN_SCRIPT_TAG + "window.parent.app.listen();\n" + END_SCRIPT_TAG;
            res.getWriter().write(script);
            res.getWriter().flush();
        else
            res.getWriter().write(event.getMessage().toString());
            res.getWriter().flush();
        end
        return event;
    end
end


main

--end of ruby source--


Thank you very much for support.
Jeanfrancois Arcand

Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
Salut,

let me try to reproduce locally. Thanks for sharing!

Stay tuned!

-- Jeanfrancois

Michal Hantl wrote:

>
> Here is a report on my progress.
>
> I got the jetty demo running, then i added atmosphere and changed the
> source.
>
> It complained about session so i changed
>
> And now i get this:
> (so far no idea what to do with it, but still googling)
>
> Problem accessing /. Reason:
>
>     INTERNAL_SERVER_ERROR
> Caused by:
>
> java.lang.NullPointerException
> at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown Source)
> at org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
> at
> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
> at
> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
> at
> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
> at
> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
> at
> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:662)
> at org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:647)
> at org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:634)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
> at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
> at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
> at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
> at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
> at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> at org.mortbay.jetty.Server.handle(Server.java:324)
> at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
> at
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
> at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
> at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
> at
> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
> at
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>
>
> the source code of my attempt:
>
> require 'java'
>
> Dir["./Java/jetty/*.jar"].each { |jar| require jar }
> Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
> Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
> Dir["./Java/apache/*.jar"].each { |jar| require jar }
>
> include_class 'javax.servlet.http.HttpServlet'
> include_class 'org.mortbay.jetty.Server'
> include_class 'org.mortbay.jetty.servlet.Context'
> include_class 'org.mortbay.jetty.servlet.ServletHolder'
> include_class 'org.mortbay.jetty.servlet.ServletHolder'
> include_class 'org.atmosphere.cpr.AtmosphereHandler'
> include_class 'org.atmosphere.cpr.AtmosphereServlet'
> include_class 'org.apache.catalina.CometProcessor'
>
> def main
>   server = Server.new(8080)
>   #context = Context.new(server, '/', 0)
>   context = Context.new(server, '/', Context::SESSIONS)
>
>   servlet = AtmosphereServlet.new()
>   servlet.addAtmosphereHandler("/", MyRubyHandler.new())
>  
>   holder = ServletHolder.new(servlet)
>   context.addServlet(holder, '/')
>  
>   server.start()
> end
>
>
>
> class MyRubyHandler
>   include AtmosphereHandler
>
>   BEGIN_SCRIPT_TAG = '<script>'
>   END_SCRIPT_TAG = '</script>'
>
>   def onEvent(event)
>         req = event.getRequest();
>         res = event.getResponse();
>
>         res.setContentType("text/html")
>         res.addHeader("Cache-Control", "private")
>         res.addHeader("Pragma", "no-cache")
>         res.getWriter().write("<html><body><h1>It
> works!</h1></body></html>\n");
>         res.getWriter().flush();
>
>
> #        if (req.getMethod().equalsIgnoreCase("GET"))
> #            # for IE
> #            res.getWriter().write("<!-- Comet is a programming technique
> that enables web " +
> #                    "servers to send data to the client without having any
> need " +
> #                    "for the client to request it. -->\n");
> #            res.getWriter().flush();
> #
> #            #
> #            # Mark this connection as suspended.
> #            #
> #            event.suspend();
> #        elsif (req.getMethod().equalsIgnoreCase("POST"))
> #            res.setCharacterEncoding("UTF-8");
> #            String action = req.getParameterValues("action")[0];
> #            String name = req.getParameterValues("name")[0];
> #
> #            if "login".equals(action)
> #                event.getBroadcaster().broadcast(
> #                  BEGIN_SCRIPT_TAG +
> #                    toJsonp("System Message from " +
> event.getWebServerName(),
> #                      name + " has joined.") +
> #                  END_SCRIPT_TAG);
> #
> #                res.getWriter().write("success");
> #                res.getWriter().flush();
> #            elsif ("post".equals(action))
> #                message = req.getParameterValues("message")[0];
> #                event.getBroadcaster().broadcast(
> #                  BEGIN_SCRIPT_TAG + toJsonp(name, message) +
> END_SCRIPT_TAG);
> #                res.getWriter().write("success");
> #                res.getWriter().flush();
> #            else
> #                res.setStatus(422);
> #
> #                res.getWriter().write("success");
> #                res.getWriter().flush();
> #            end
> #        end
>         return event;
>     end
>
>     def onMessage(event)
>         req = event.getRequest();
>         res = event.getResponse();
>
>         if (event.isResuming() || event.isResumedOnTimedout())
>             script = BEGIN_SCRIPT_TAG + "window.parent.app.listen();\n" +
> END_SCRIPT_TAG;
>             res.getWriter().write(script);
>             res.getWriter().flush();
>         else
>             res.getWriter().write(event.getMessage().toString());
>             res.getWriter().flush();
>         end
>         return event;
>     end
> end
>
>
> main
>
> --end of ruby source--
>
>
> Thank you very much for support.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Jeanfrancois Arcand

Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
Salut,

Jeanfrancois Arcand wrote:
> Salut,
>
> let me try to reproduce locally. Thanks for sharing!

It seems loading a class using Class.forName doesn't work we ran in
JRuby. I'm attaching a patch to see if that will fix your issues. I'm
build the patch agains 0.3.1, so just replace the
atmosphere-portable-runtime.jar file.

Let me know the result!

A+

--Jeanfrancois

>
> Stay tuned!
>
> -- Jeanfrancois
>
> Michal Hantl wrote:
>>
>> Here is a report on my progress.
>>
>> I got the jetty demo running, then i added atmosphere and changed the
>> source.
>>
>> It complained about session so i changed
>> And now i get this:
>> (so far no idea what to do with it, but still googling)
>>
>> Problem accessing /. Reason:
>>
>>     INTERNAL_SERVER_ERROR
>> Caused by:
>>
>> java.lang.NullPointerException
>>     at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown Source)
>>     at
>> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>>     at
>> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>>
>>     at
>> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>>
>>     at
>> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>>
>>     at
>> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>>
>>     at
>> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:662)
>>
>>     at
>> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:647)
>>     at
>> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:634)
>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>     at
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>>     at
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>>     at
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>     at
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>     at
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>     at org.mortbay.jetty.Server.handle(Server.java:324)
>>     at
>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>>     at
>> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>>
>>     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>>     at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>     at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>     at
>> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>>
>>     at
>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>>
>>
>>
>> the source code of my attempt:
>>
>> require 'java'
>>
>> Dir["./Java/jetty/*.jar"].each { |jar| require jar }
>> Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
>> Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
>> Dir["./Java/apache/*.jar"].each { |jar| require jar }
>>
>> include_class 'javax.servlet.http.HttpServlet'
>> include_class 'org.mortbay.jetty.Server'
>> include_class 'org.mortbay.jetty.servlet.Context'
>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>> include_class 'org.atmosphere.cpr.AtmosphereHandler'
>> include_class 'org.atmosphere.cpr.AtmosphereServlet'
>> include_class 'org.apache.catalina.CometProcessor'
>>
>> def main
>>   server = Server.new(8080)
>>   #context = Context.new(server, '/', 0)
>>   context = Context.new(server, '/', Context::SESSIONS)
>>
>>   servlet = AtmosphereServlet.new()
>>   servlet.addAtmosphereHandler("/", MyRubyHandler.new())
>>     holder = ServletHolder.new(servlet)
>>   context.addServlet(holder, '/')
>>     server.start()
>> end
>>
>>
>>
>> class MyRubyHandler
>>   include AtmosphereHandler
>>
>>   BEGIN_SCRIPT_TAG = '<script>'
>>   END_SCRIPT_TAG = '</script>'
>>
>>   def onEvent(event)
>>         req = event.getRequest();
>>         res = event.getResponse();
>>
>>         res.setContentType("text/html")
>>         res.addHeader("Cache-Control", "private")
>>         res.addHeader("Pragma", "no-cache")
>>         res.getWriter().write("<html><body><h1>It
>> works!</h1></body></html>\n");
>>         res.getWriter().flush();
>>
>>
>> #        if (req.getMethod().equalsIgnoreCase("GET"))
>> #            # for IE
>> #            res.getWriter().write("<!-- Comet is a programming technique
>> that enables web " +
>> #                    "servers to send data to the client without
>> having any
>> need " +
>> #                    "for the client to request it. -->\n");
>> #            res.getWriter().flush();
>> #
>> #            #
>> #            # Mark this connection as suspended.
>> #            #
>> #            event.suspend();
>> #        elsif (req.getMethod().equalsIgnoreCase("POST"))
>> #            res.setCharacterEncoding("UTF-8");
>> #            String action = req.getParameterValues("action")[0];
>> #            String name = req.getParameterValues("name")[0];
>> #
>> #            if "login".equals(action)
>> #                event.getBroadcaster().broadcast(
>> #                  BEGIN_SCRIPT_TAG +
>> #                    toJsonp("System Message from " +
>> event.getWebServerName(),
>> #                      name + " has joined.") +
>> #                  END_SCRIPT_TAG);
>> #
>> #                res.getWriter().write("success");
>> #                res.getWriter().flush();
>> #            elsif ("post".equals(action))
>> #                message = req.getParameterValues("message")[0];
>> #                event.getBroadcaster().broadcast(
>> #                  BEGIN_SCRIPT_TAG + toJsonp(name, message) +
>> END_SCRIPT_TAG);
>> #                res.getWriter().write("success");
>> #                res.getWriter().flush();
>> #            else
>> #                res.setStatus(422);
>> #
>> #                res.getWriter().write("success");
>> #                res.getWriter().flush();
>> #            end
>> #        end
>>         return event;
>>     end
>>
>>     def onMessage(event)
>>         req = event.getRequest();
>>         res = event.getResponse();
>>
>>         if (event.isResuming() || event.isResumedOnTimedout())
>>             script = BEGIN_SCRIPT_TAG + "window.parent.app.listen();\n" +
>> END_SCRIPT_TAG;
>>             res.getWriter().write(script);
>>             res.getWriter().flush();
>>         else
>>             res.getWriter().write(event.getMessage().toString());
>>             res.getWriter().flush();
>>         end
>>         return event;
>>     end
>> end
>>
>>
>> main
>>
>> --end of ruby source--
>>
>>
>> Thank you very much for support.
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

atmosphere-portable-runtime-0.3.1.jar (117K) Download Attachment
Michal Hantl

Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
Thanks for sending a patch so quickly!

(And sorry for delayed reply, I wasn't home till now.)

I tried the patched version, but same error occurs.

Here is the full project, so you dont have to re-create: http://d.hantl.cz/jruby_atmosphere.rar

(Might be something I did wrong, since I am pretty new to this.)

Thanks!


Jeanfrancois Arcand wrote:
Salut,

Jeanfrancois Arcand wrote:
> Salut,
>
> let me try to reproduce locally. Thanks for sharing!

It seems loading a class using Class.forName doesn't work we ran in
JRuby. I'm attaching a patch to see if that will fix your issues. I'm
build the patch agains 0.3.1, so just replace the
atmosphere-portable-runtime.jar file.

Let me know the result!

A+

--Jeanfrancois

>
> Stay tuned!
>
> -- Jeanfrancois
>
> Michal Hantl wrote:
>>
>> Here is a report on my progress.
>>
>> I got the jetty demo running, then i added atmosphere and changed the
>> source.
>>
>> It complained about session so i changed
>> And now i get this:
>> (so far no idea what to do with it, but still googling)
>>
>> Problem accessing /. Reason:
>>
>>     INTERNAL_SERVER_ERROR
>> Caused by:
>>
>> java.lang.NullPointerException
>>     at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown Source)
>>     at
>> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>>     at
>> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>>
>>     at
>> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>>
>>     at
>> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>>
>>     at
>> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>>
>>     at
>> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:662)
>>
>>     at
>> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:647)
>>     at
>> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:634)
>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>     at
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>>     at
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>>     at
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>     at
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>     at
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>     at org.mortbay.jetty.Server.handle(Server.java:324)
>>     at
>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>>     at
>> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>>
>>     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>>     at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>     at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>     at
>> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>>
>>     at
>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>>
>>
>>
>> the source code of my attempt:
>>
>> require 'java'
>>
>> Dir["./Java/jetty/*.jar"].each { |jar| require jar }
>> Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
>> Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
>> Dir["./Java/apache/*.jar"].each { |jar| require jar }
>>
>> include_class 'javax.servlet.http.HttpServlet'
>> include_class 'org.mortbay.jetty.Server'
>> include_class 'org.mortbay.jetty.servlet.Context'
>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>> include_class 'org.atmosphere.cpr.AtmosphereHandler'
>> include_class 'org.atmosphere.cpr.AtmosphereServlet'
>> include_class 'org.apache.catalina.CometProcessor'
>>
>> def main
>>   server = Server.new(8080)
>>   #context = Context.new(server, '/', 0)
>>   context = Context.new(server, '/', Context::SESSIONS)
>>
>>   servlet = AtmosphereServlet.new()
>>   servlet.addAtmosphereHandler("/", MyRubyHandler.new())
>>     holder = ServletHolder.new(servlet)
>>   context.addServlet(holder, '/')
>>     server.start()
>> end
>>
>>
>>
>> class MyRubyHandler
>>   include AtmosphereHandler
>>
>>   BEGIN_SCRIPT_TAG = '<script>'
>>   END_SCRIPT_TAG = '</script>'
>>
>>   def onEvent(event)
>>         req = event.getRequest();
>>         res = event.getResponse();
>>
>>         res.setContentType("text/html")
>>         res.addHeader("Cache-Control", "private")
>>         res.addHeader("Pragma", "no-cache")
>>         res.getWriter().write("<html><body><h1>It
>> works!</h1></body></html>\n");
>>         res.getWriter().flush();
>>
>>
>> #        if (req.getMethod().equalsIgnoreCase("GET"))
>> #            # for IE
>> #            res.getWriter().write("<!-- Comet is a programming technique
>> that enables web " +
>> #                    "servers to send data to the client without
>> having any
>> need " +
>> #                    "for the client to request it. -->\n");
>> #            res.getWriter().flush();
>> #
>> #            #
>> #            # Mark this connection as suspended.
>> #            #
>> #            event.suspend();
>> #        elsif (req.getMethod().equalsIgnoreCase("POST"))
>> #            res.setCharacterEncoding("UTF-8");
>> #            String action = req.getParameterValues("action")[0];
>> #            String name = req.getParameterValues("name")[0];
>> #
>> #            if "login".equals(action)
>> #                event.getBroadcaster().broadcast(
>> #                  BEGIN_SCRIPT_TAG +
>> #                    toJsonp("System Message from " +
>> event.getWebServerName(),
>> #                      name + " has joined.") +
>> #                  END_SCRIPT_TAG);
>> #
>> #                res.getWriter().write("success");
>> #                res.getWriter().flush();
>> #            elsif ("post".equals(action))
>> #                message = req.getParameterValues("message")[0];
>> #                event.getBroadcaster().broadcast(
>> #                  BEGIN_SCRIPT_TAG + toJsonp(name, message) +
>> END_SCRIPT_TAG);
>> #                res.getWriter().write("success");
>> #                res.getWriter().flush();
>> #            else
>> #                res.setStatus(422);
>> #
>> #                res.getWriter().write("success");
>> #                res.getWriter().flush();
>> #            end
>> #        end
>>         return event;
>>     end
>>
>>     def onMessage(event)
>>         req = event.getRequest();
>>         res = event.getResponse();
>>
>>         if (event.isResuming() || event.isResumedOnTimedout())
>>             script = BEGIN_SCRIPT_TAG + "window.parent.app.listen();\n" +
>> END_SCRIPT_TAG;
>>             res.getWriter().write(script);
>>             res.getWriter().flush();
>>         else
>>             res.getWriter().write(event.getMessage().toString());
>>             res.getWriter().flush();
>>         end
>>         return event;
>>     end
>> end
>>
>>
>> main
>>
>> --end of ruby source--
>>
>>
>> Thank you very much for support.
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@atmosphere.dev.java.net
> For additional commands, e-mail: users-help@atmosphere.dev.java.net
>

 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@atmosphere.dev.java.net
For additional commands, e-mail: users-help@atmosphere.dev.java.net
Jeanfrancois Arcand

Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
Salut,

Michal Hantl wrote:

> Thanks for sending a patch so quickly!
>
> (And sorry for delayed reply, I wasn't home till now.)
>
> I tried the patched version, but same error occurs.
>
> Here is the full project, so you dont have to re-create:
> http://d.hantl.cz/jruby_atmosphere.rar
>
> (Might be something I did wrong, since I am pretty new to this.)

Can you cut & past the error? I'm installing your project as well.

Thanks

-- Jeanfrancois


>
> Thanks!
>
>
>
> Jeanfrancois Arcand wrote:
>> Salut,
>>
>> Jeanfrancois Arcand wrote:
>>> Salut,
>>>
>>> let me try to reproduce locally. Thanks for sharing!
>> It seems loading a class using Class.forName doesn't work we ran in
>> JRuby. I'm attaching a patch to see if that will fix your issues. I'm
>> build the patch agains 0.3.1, so just replace the
>> atmosphere-portable-runtime.jar file.
>>
>> Let me know the result!
>>
>> A+
>>
>> --Jeanfrancois
>>
>>> Stay tuned!
>>>
>>> -- Jeanfrancois
>>>
>>> Michal Hantl wrote:
>>>> Here is a report on my progress.
>>>>
>>>> I got the jetty demo running, then i added atmosphere and changed the
>>>> source.
>>>>
>>>> It complained about session so i changed
>>>> And now i get this:
>>>> (so far no idea what to do with it, but still googling)
>>>>
>>>> Problem accessing /. Reason:
>>>>
>>>>     INTERNAL_SERVER_ERROR
>>>> Caused by:
>>>>
>>>> java.lang.NullPointerException
>>>>     at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown Source)
>>>>     at
>>>> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>>>>     at
>>>> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>>>>
>>>>     at
>>>> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>>>>
>>>>     at
>>>> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>>>>
>>>>     at
>>>> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>>>>
>>>>     at
>>>> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:662)
>>>>
>>>>     at
>>>> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:647)
>>>>     at
>>>> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:634)
>>>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>>>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>>>     at
>>>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>>>>     at
>>>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>>>>     at
>>>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>>>     at
>>>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>>>     at
>>>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>>>     at org.mortbay.jetty.Server.handle(Server.java:324)
>>>>     at
>>>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>>>>     at
>>>> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>>>>
>>>>     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>>>>     at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>>>     at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>>>     at
>>>> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>>>>
>>>>     at
>>>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>>>>
>>>>
>>>>
>>>> the source code of my attempt:
>>>>
>>>> require 'java'
>>>>
>>>> Dir["./Java/jetty/*.jar"].each { |jar| require jar }
>>>> Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
>>>> Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
>>>> Dir["./Java/apache/*.jar"].each { |jar| require jar }
>>>>
>>>> include_class 'javax.servlet.http.HttpServlet'
>>>> include_class 'org.mortbay.jetty.Server'
>>>> include_class 'org.mortbay.jetty.servlet.Context'
>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>>>> include_class 'org.atmosphere.cpr.AtmosphereHandler'
>>>> include_class 'org.atmosphere.cpr.AtmosphereServlet'
>>>> include_class 'org.apache.catalina.CometProcessor'
>>>>
>>>> def main
>>>>   server = Server.new(8080)
>>>>   #context = Context.new(server, '/', 0)
>>>>   context = Context.new(server, '/', Context::SESSIONS)
>>>>
>>>>   servlet = AtmosphereServlet.new()
>>>>   servlet.addAtmosphereHandler("/", MyRubyHandler.new())
>>>>     holder = ServletHolder.new(servlet)
>>>>   context.addServlet(holder, '/')
>>>>     server.start()
>>>> end
>>>>
>>>>
>>>>
>>>> class MyRubyHandler
>>>>   include AtmosphereHandler
>>>>
>>>>   BEGIN_SCRIPT_TAG = '<script>'
>>>>   END_SCRIPT_TAG = '</script>'
>>>>
>>>>   def onEvent(event)
>>>>         req = event.getRequest();
>>>>         res = event.getResponse();
>>>>
>>>>         res.setContentType("text/html")
>>>>         res.addHeader("Cache-Control", "private")
>>>>         res.addHeader("Pragma", "no-cache")
>>>>         res.getWriter().write("<html><body><h1>It
>>>> works!</h1></body></html>\n");
>>>>         res.getWriter().flush();
>>>>
>>>>
>>>> #        if (req.getMethod().equalsIgnoreCase("GET"))
>>>> #            # for IE
>>>> #            res.getWriter().write("<!-- Comet is a programming
>>>> technique
>>>> that enables web " +
>>>> #                    "servers to send data to the client without
>>>> having any
>>>> need " +
>>>> #                    "for the client to request it. -->\n");
>>>> #            res.getWriter().flush();
>>>> #
>>>> #            #
>>>> #            # Mark this connection as suspended.
>>>> #            #
>>>> #            event.suspend();
>>>> #        elsif (req.getMethod().equalsIgnoreCase("POST"))
>>>> #            res.setCharacterEncoding("UTF-8");
>>>> #            String action = req.getParameterValues("action")[0];
>>>> #            String name = req.getParameterValues("name")[0];
>>>> #
>>>> #            if "login".equals(action)
>>>> #                event.getBroadcaster().broadcast(
>>>> #                  BEGIN_SCRIPT_TAG +
>>>> #                    toJsonp("System Message from " +
>>>> event.getWebServerName(),
>>>> #                      name + " has joined.") +
>>>> #                  END_SCRIPT_TAG);
>>>> #
>>>> #                res.getWriter().write("success");
>>>> #                res.getWriter().flush();
>>>> #            elsif ("post".equals(action))
>>>> #                message = req.getParameterValues("message")[0];
>>>> #                event.getBroadcaster().broadcast(
>>>> #                  BEGIN_SCRIPT_TAG + toJsonp(name, message) +
>>>> END_SCRIPT_TAG);
>>>> #                res.getWriter().write("success");
>>>> #                res.getWriter().flush();
>>>> #            else
>>>> #                res.setStatus(422);
>>>> #
>>>> #                res.getWriter().write("success");
>>>> #                res.getWriter().flush();
>>>> #            end
>>>> #        end
>>>>         return event;
>>>>     end
>>>>
>>>>     def onMessage(event)
>>>>         req = event.getRequest();
>>>>         res = event.getResponse();
>>>>
>>>>         if (event.isResuming() || event.isResumedOnTimedout())
>>>>             script = BEGIN_SCRIPT_TAG + "window.parent.app.listen();\n"
>>>> +
>>>> END_SCRIPT_TAG;
>>>>             res.getWriter().write(script);
>>>>             res.getWriter().flush();
>>>>         else
>>>>             res.getWriter().write(event.getMessage().toString());
>>>>             res.getWriter().flush();
>>>>         end
>>>>         return event;
>>>>     end
>>>> end
>>>>
>>>>
>>>> main
>>>>
>>>> --end of ruby source--
>>>>
>>>>
>>>> Thank you very much for support.
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>  
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Michal Hantl

Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
Hi,
 I didnt attach the error because it stayed the same.

Does my rar show you the same error?

2009/8/31 Jeanfrancois Arcand (via Nabble)
<[hidden email]>:

> Salut,
>
> Michal Hantl wrote:
>> Thanks for sending a patch so quickly!
>>
>> (And sorry for delayed reply, I wasn't home till now.)
>>
>> I tried the patched version, but same error occurs.
>>
>> Here is the full project, so you dont have to re-create:
>> http://d.hantl.cz/jruby_atmosphere.rar
>>
>> (Might be something I did wrong, since I am pretty new to this.)
> Can you cut & past the error? I'm installing your project as well.
>
> Thanks
>
> -- Jeanfrancois
>
>
>>
>> Thanks!
>>
>>
>>
>> Jeanfrancois Arcand wrote:
>>> Salut,
>>>
>>> Jeanfrancois Arcand wrote:
>>>> Salut,
>>>>
>>>> let me try to reproduce locally. Thanks for sharing!
>>> It seems loading a class using Class.forName doesn't work we ran in
>>> JRuby. I'm attaching a patch to see if that will fix your issues. I'm
>>> build the patch agains 0.3.1, so just replace the
>>> atmosphere-portable-runtime.jar file.
>>>
>>> Let me know the result!
>>>
>>> A+
>>>
>>> --Jeanfrancois
>>>
>>>> Stay tuned!
>>>>
>>>> -- Jeanfrancois
>>>>
>>>> Michal Hantl wrote:
>>>>> Here is a report on my progress.
>>>>>
>>>>> I got the jetty demo running, then i added atmosphere and changed the
>>>>> source.
>>>>>
>>>>> It complained about session so i changed
>>>>> And now i get this:
>>>>> (so far no idea what to do with it, but still googling)
>>>>>
>>>>> Problem accessing /. Reason:
>>>>>
>>>>>     INTERNAL_SERVER_ERROR
>>>>> Caused by:
>>>>>
>>>>> java.lang.NullPointerException
>>>>>     at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown Source)
>>>>>     at
>>>>> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>>>>>     at
>>>>>
>>>>> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>>>>>
>>>>>     at
>>>>>
>>>>> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>>>>>
>>>>>     at
>>>>>
>>>>> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>>>>>
>>>>>     at
>>>>>
>>>>> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>>>>>
>>>>>     at
>>>>>
>>>>> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:662)
>>>>>
>>>>>     at
>>>>> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:647)
>>>>>     at
>>>>> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:634)
>>>>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>>>>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>>>>     at
>>>>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>>>>>     at
>>>>>
>>>>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>>>>>     at
>>>>>
>>>>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>>>>     at
>>>>>
>>>>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>>>>     at
>>>>>
>>>>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>>>>     at org.mortbay.jetty.Server.handle(Server.java:324)
>>>>>     at
>>>>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>>>>>     at
>>>>>
>>>>> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>>>>>
>>>>>     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>>>>>     at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>>>>     at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>>>>     at
>>>>>
>>>>> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>>>>>
>>>>>     at
>>>>>
>>>>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>>>>>
>>>>>
>>>>>
>>>>> the source code of my attempt:
>>>>>
>>>>> require 'java'
>>>>>
>>>>> Dir["./Java/jetty/*.jar"].each { |jar| require jar }
>>>>> Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
>>>>> Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
>>>>> Dir["./Java/apache/*.jar"].each { |jar| require jar }
>>>>>
>>>>> include_class 'javax.servlet.http.HttpServlet'
>>>>> include_class 'org.mortbay.jetty.Server'
>>>>> include_class 'org.mortbay.jetty.servlet.Context'
>>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>>>>> include_class 'org.atmosphere.cpr.AtmosphereHandler'
>>>>> include_class 'org.atmosphere.cpr.AtmosphereServlet'
>>>>> include_class 'org.apache.catalina.CometProcessor'
>>>>>
>>>>> def main
>>>>>   server = Server.new(8080)
>>>>>   #context = Context.new(server, '/', 0)
>>>>>   context = Context.new(server, '/', Context::SESSIONS)
>>>>>
>>>>>   servlet = AtmosphereServlet.new()
>>>>>   servlet.addAtmosphereHandler("/", MyRubyHandler.new())
>>>>>     holder = ServletHolder.new(servlet)
>>>>>   context.addServlet(holder, '/')
>>>>>     server.start()
>>>>> end
>>>>>
>>>>>
>>>>>
>>>>> class MyRubyHandler
>>>>>   include AtmosphereHandler
>>>>>
>>>>>   BEGIN_SCRIPT_TAG = '<script>'
>>>>>   END_SCRIPT_TAG = '</script>'
>>>>>
>>>>>   def onEvent(event)
>>>>>         req = event.getRequest();
>>>>>         res = event.getResponse();
>>>>>
>>>>>         res.setContentType("text/html")
>>>>>         res.addHeader("Cache-Control", "private")
>>>>>         res.addHeader("Pragma", "no-cache")
>>>>>         res.getWriter().write("<html><body><h1>It
>>>>> works!</h1></body></html>\n");
>>>>>         res.getWriter().flush();
>>>>>
>>>>>
>>>>> #        if (req.getMethod().equalsIgnoreCase("GET"))
>>>>> #            # for IE
>>>>> #            res.getWriter().write("<!-- Comet is a programming
>>>>> technique
>>>>> that enables web " +
>>>>> #                    "servers to send data to the client without
>>>>> having any
>>>>> need " +
>>>>> #                    "for the client to request it. -->\n");
>>>>> #            res.getWriter().flush();
>>>>> #
>>>>> #            #
>>>>> #            # Mark this connection as suspended.
>>>>> #            #
>>>>> #            event.suspend();
>>>>> #        elsif (req.getMethod().equalsIgnoreCase("POST"))
>>>>> #            res.setCharacterEncoding("UTF-8");
>>>>> #            String action = req.getParameterValues("action")[0];
>>>>> #            String name = req.getParameterValues("name")[0];
>>>>> #
>>>>> #            if "login".equals(action)
>>>>> #                event.getBroadcaster().broadcast(
>>>>> #                  BEGIN_SCRIPT_TAG +
>>>>> #                    toJsonp("System Message from " +
>>>>> event.getWebServerName(),
>>>>> #                      name + " has joined.") +
>>>>> #                  END_SCRIPT_TAG);
>>>>> #
>>>>> #                res.getWriter().write("success");
>>>>> #                res.getWriter().flush();
>>>>> #            elsif ("post".equals(action))
>>>>> #                message = req.getParameterValues("message")[0];
>>>>> #                event.getBroadcaster().broadcast(
>>>>> #                  BEGIN_SCRIPT_TAG + toJsonp(name, message) +
>>>>> END_SCRIPT_TAG);
>>>>> #                res.getWriter().write("success");
>>>>> #                res.getWriter().flush();
>>>>> #            else
>>>>> #                res.setStatus(422);
>>>>> #
>>>>> #                res.getWriter().write("success");
>>>>> #                res.getWriter().flush();
>>>>> #            end
>>>>> #        end
>>>>>         return event;
>>>>>     end
>>>>>
>>>>>     def onMessage(event)
>>>>>         req = event.getRequest();
>>>>>         res = event.getResponse();
>>>>>
>>>>>         if (event.isResuming() || event.isResumedOnTimedout())
>>>>>             script = BEGIN_SCRIPT_TAG + "window.parent.app.listen();\n"
>>>>> +
>>>>> END_SCRIPT_TAG;
>>>>>             res.getWriter().write(script);
>>>>>             res.getWriter().flush();
>>>>>         else
>>>>>             res.getWriter().write(event.getMessage().toString());
>>>>>             res.getWriter().flush();
>>>>>         end
>>>>>         return event;
>>>>>     end
>>>>> end
>>>>>
>>>>>
>>>>> main
>>>>>
>>>>> --end of ruby source--
>>>>>
>>>>>
>>>>> Thank you very much for support.
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
> ________________________________
> View message @
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3553859.html
> To unsubscribe from Iframe streaming with Jruby and Atmosphere, click here.
>



--
S pozdravem, Regards
Michal Hantl

gtalk/jabber: [hidden email]
icq: 241813215
Jeanfrancois Arcand

Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
Salut,

Michal Hantl wrote:
> Hi,
>  I didnt attach the error because it stayed the same.

Same line? I was under the impression the new jar will changes that.

>
> Does my rar show you the same error?

Actually I haven't figured yet how to start it. I looked at
atmosphere.bat but I'm getting some errors. What is the easiest way to
reproduce it?

Thanks

-- Jeanfarncois

>
> 2009/8/31 Jeanfrancois Arcand (via Nabble)
> <[hidden email]
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0>>:
>
>  > Salut,
>  >
>  > Michal Hantl wrote:
>  >> Thanks for sending a patch so quickly!
>  >>
>  >> (And sorry for delayed reply, I wasn't home till now.)
>  >>
>  >> I tried the patched version, but same error occurs.
>  >>
>  >> Here is the full project, so you dont have to re-create:
>  >> http://d.hantl.cz/jruby_atmosphere.rar
>  >>
>  >> (Might be something I did wrong, since I am pretty new to this.)
>  > Can you cut & past the error? I'm installing your project as well.
>  >
>  > Thanks
>  >
>  > -- Jeanfrancois
>  >
>  >
>  >>
>  >> Thanks!
>  >>
>  >>
>  >>
>  >> Jeanfrancois Arcand wrote:
>  >>> Salut,
>  >>>
>  >>> Jeanfrancois Arcand wrote:
>  >>>> Salut,
>  >>>>
>  >>>> let me try to reproduce locally. Thanks for sharing!
>  >>> It seems loading a class using Class.forName doesn't work we ran in
>  >>> JRuby. I'm attaching a patch to see if that will fix your issues. I'm
>  >>> build the patch agains 0.3.1, so just replace the
>  >>> atmosphere-portable-runtime.jar file.
>  >>>
>  >>> Let me know the result!
>  >>>
>  >>> A+
>  >>>
>  >>> --Jeanfrancois
>  >>>
>  >>>> Stay tuned!
>  >>>>
>  >>>> -- Jeanfrancois
>  >>>>
>  >>>> Michal Hantl wrote:
>  >>>>> Here is a report on my progress.
>  >>>>>
>  >>>>> I got the jetty demo running, then i added atmosphere and changed
> the
>  >>>>> source.
>  >>>>>
>  >>>>> It complained about session so i changed
>  >>>>> And now i get this:
>  >>>>> (so far no idea what to do with it, but still googling)
>  >>>>>
>  >>>>> Problem accessing /. Reason:
>  >>>>>
>  >>>>>     INTERNAL_SERVER_ERROR
>  >>>>> Caused by:
>  >>>>>
>  >>>>> java.lang.NullPointerException
>  >>>>>     at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown
> Source)
>  >>>>>     at
>  >>>>> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>  >>>>>     at
>  >>>>>
>  >>>>>
> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>
>  >>>>>
>  >>>>>     at
>  >>>>>
>  >>>>>
> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>
>  >>>>>
>  >>>>>     at
>  >>>>>
>  >>>>>
> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>
>  >>>>>
>  >>>>>     at
>  >>>>>
>  >>>>>
> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>
>  >>>>>
>  >>>>>     at
>  >>>>>
>  >>>>>
> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:662)
>
>  >>>>>
>  >>>>>     at
>  >>>>>
> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:647)
>  >>>>>     at
>  >>>>>
> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:634)
>  >>>>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>  >>>>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>  >>>>>     at
>  >>>>>
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>  >>>>>     at
>  >>>>>
>  >>>>>
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>  >>>>>     at
>  >>>>>
>  >>>>>
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>  >>>>>     at
>  >>>>>
>  >>>>>
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>  >>>>>     at
>  >>>>>
>  >>>>>
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>  >>>>>     at org.mortbay.jetty.Server.handle(Server.java:324)
>  >>>>>     at
>  >>>>>
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>  >>>>>     at
>  >>>>>
>  >>>>>
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>
>  >>>>>
>  >>>>>     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>  >>>>>     at
> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>  >>>>>     at
> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>  >>>>>     at
>  >>>>>
>  >>>>>
> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>
>  >>>>>
>  >>>>>     at
>  >>>>>
>  >>>>>
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>
>  >>>>>
>  >>>>>
>  >>>>>
>  >>>>> the source code of my attempt:
>  >>>>>
>  >>>>> require 'java'
>  >>>>>
>  >>>>> Dir["./Java/jetty/*.jar"].each { |jar| require jar }
>  >>>>> Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
>  >>>>> Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
>  >>>>> Dir["./Java/apache/*.jar"].each { |jar| require jar }
>  >>>>>
>  >>>>> include_class 'javax.servlet.http.HttpServlet'
>  >>>>> include_class 'org.mortbay.jetty.Server'
>  >>>>> include_class 'org.mortbay.jetty.servlet.Context'
>  >>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>  >>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>  >>>>> include_class 'org.atmosphere.cpr.AtmosphereHandler'
>  >>>>> include_class 'org.atmosphere.cpr.AtmosphereServlet'
>  >>>>> include_class 'org.apache.catalina.CometProcessor'
>  >>>>>
>  >>>>> def main
>  >>>>>   server = Server.new(8080)
>  >>>>>   #context = Context.new(server, '/', 0)
>  >>>>>   context = Context.new(server, '/', Context::SESSIONS)
>  >>>>>
>  >>>>>   servlet = AtmosphereServlet.new()
>  >>>>>   servlet.addAtmosphereHandler("/", MyRubyHandler.new())
>  >>>>>     holder = ServletHolder.new(servlet)
>  >>>>>   context.addServlet(holder, '/')
>  >>>>>     server.start()
>  >>>>> end
>  >>>>>
>  >>>>>
>  >>>>>
>  >>>>> class MyRubyHandler
>  >>>>>   include AtmosphereHandler
>  >>>>>
>  >>>>>   BEGIN_SCRIPT_TAG = '<script>'
>  >>>>>   END_SCRIPT_TAG = '</script>'
>  >>>>>
>  >>>>>   def onEvent(event)
>  >>>>>         req = event.getRequest();
>  >>>>>         res = event.getResponse();
>  >>>>>
>  >>>>>         res.setContentType("text/html")
>  >>>>>         res.addHeader("Cache-Control", "private")
>  >>>>>         res.addHeader("Pragma", "no-cache")
>  >>>>>         res.getWriter().write("<html><body><h1>It
>  >>>>> works!</h1></body></html>\n");
>  >>>>>         res.getWriter().flush();
>  >>>>>
>  >>>>>
>  >>>>> #        if (req.getMethod().equalsIgnoreCase("GET"))
>  >>>>> #            # for IE
>  >>>>> #            res.getWriter().write("<!-- Comet is a programming
>  >>>>> technique
>  >>>>> that enables web " +
>  >>>>> #                    "servers to send data to the client without
>  >>>>> having any
>  >>>>> need " +
>  >>>>> #                    "for the client to request it. -->\n");
>  >>>>> #            res.getWriter().flush();
>  >>>>> #
>  >>>>> #            #
>  >>>>> #            # Mark this connection as suspended.
>  >>>>> #            #
>  >>>>> #            event.suspend();
>  >>>>> #        elsif (req.getMethod().equalsIgnoreCase("POST"))
>  >>>>> #            res.setCharacterEncoding("UTF-8");
>  >>>>> #            String action = req.getParameterValues("action")[0];
>  >>>>> #            String name = req.getParameterValues("name")[0];
>  >>>>> #
>  >>>>> #            if "login".equals(action)
>  >>>>> #                event.getBroadcaster().broadcast(
>  >>>>> #                  BEGIN_SCRIPT_TAG +
>  >>>>> #                    toJsonp("System Message from " +
>  >>>>> event.getWebServerName(),
>  >>>>> #                      name + " has joined.") +
>  >>>>> #                  END_SCRIPT_TAG);
>  >>>>> #
>  >>>>> #                res.getWriter().write("success");
>  >>>>> #                res.getWriter().flush();
>  >>>>> #            elsif ("post".equals(action))
>  >>>>> #                message = req.getParameterValues("message")[0];
>  >>>>> #                event.getBroadcaster().broadcast(
>  >>>>> #                  BEGIN_SCRIPT_TAG + toJsonp(name, message) +
>  >>>>> END_SCRIPT_TAG);
>  >>>>> #                res.getWriter().write("success");
>  >>>>> #                res.getWriter().flush();
>  >>>>> #            else
>  >>>>> #                res.setStatus(422);
>  >>>>> #
>  >>>>> #                res.getWriter().write("success");
>  >>>>> #                res.getWriter().flush();
>  >>>>> #            end
>  >>>>> #        end
>  >>>>>         return event;
>  >>>>>     end
>  >>>>>
>  >>>>>     def onMessage(event)
>  >>>>>         req = event.getRequest();
>  >>>>>         res = event.getResponse();
>  >>>>>
>  >>>>>         if (event.isResuming() || event.isResumedOnTimedout())
>  >>>>>             script = BEGIN_SCRIPT_TAG +
> "window.parent.app.listen();\n"
>  >>>>> +
>  >>>>> END_SCRIPT_TAG;
>  >>>>>             res.getWriter().write(script);
>  >>>>>             res.getWriter().flush();
>  >>>>>         else
>  >>>>>             res.getWriter().write(event.getMessage().toString());
>  >>>>>             res.getWriter().flush();
>  >>>>>         end
>  >>>>>         return event;
>  >>>>>     end
>  >>>>> end
>  >>>>>
>  >>>>>
>  >>>>> main
>  >>>>>
>  >>>>> --end of ruby source--
>  >>>>>
>  >>>>>
>  >>>>> Thank you very much for support.
>  >>>>>
>  >>>> ---------------------------------------------------------------------
>  >>>> To unsubscribe, e-mail: [hidden email]
>  >>>> For additional commands, e-mail: [hidden email]
>  >>>>
>  >>>
>  >>> ---------------------------------------------------------------------
>  >>> To unsubscribe, e-mail: [hidden email]
>  >>> For additional commands, e-mail: [hidden email]
>  >>>
>  >>
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: [hidden email]
>  > For additional commands, e-mail: [hidden email]
>  >
>  >
>  >
>  > ________________________________
>  > View message @
>  >
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3553859.html
>  > To unsubscribe from Iframe streaming with Jruby and Atmosphere, click
> here.
>  >
>
>
>
> --
> S pozdravem, Regards
> Michal Hantl
>
> gtalk/jabber: [hidden email]
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1>
> icq: 241813215
>
> ------------------------------------------------------------------------
> View this message in context: Re: Iframe streaming with Jruby and
> Atmosphere
> <http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3554785.html>
> Sent from the Atmosphere users mailling list mailing list archive
> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
> Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Michal Hantl

Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
2009/8/31 Jeanfrancois Arcand (via Nabble)
<[hidden email]>:
> Salut,
>
> Michal Hantl wrote:
>> Hi,
>>  I didnt attach the error because it stayed the same.
>
> Same line? I was under the impression the new jar will changes that.

Seems exactly the same:

HTTP ERROR 500

Problem accessing /. Reason:

    INTERNAL_SERVER_ERROR
Caused by:

java.lang.NullPointerException
        at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown Source)
        at org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
        at org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
        at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
        at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
        at org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
        at org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:665)
        at org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:650)
        at org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:324)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)



>
>>
>> Does my rar show you the same error?
>
> Actually I haven't figured yet how to start it. I looked at
> atmosphere.bat but I'm getting some errors. What is the easiest way to
> reproduce it?

Yes, atmosphere.bat should start it. Jruby and all other jars are
included so it should just work.

Are you using windows? I am running XP, not sure if that can be a
problem.. I havent tested it under linux (none installed right now).

What error are you getting? I will look into the jar to see where are
the lines of the problem, maybe i can google something.





>
> Thanks
>
> -- Jeanfarncois
>
>>
>> 2009/8/31 Jeanfrancois Arcand (via Nabble)
>> <[hidden email]
>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0>>:
>>
>>  > Salut,
>>  >
>>  > Michal Hantl wrote:
>>  >> Thanks for sending a patch so quickly!
>>  >>
>>  >> (And sorry for delayed reply, I wasn't home till now.)
>>  >>
>>  >> I tried the patched version, but same error occurs.
>>  >>
>>  >> Here is the full project, so you dont have to re-create:
>>  >> http://d.hantl.cz/jruby_atmosphere.rar
>>  >>
>>  >> (Might be something I did wrong, since I am pretty new to this.)
>>  > Can you cut & past the error? I'm installing your project as well.
>>  >
>>  > Thanks
>>  >
>>  > -- Jeanfrancois
>>  >
>>  >
>>  >>
>>  >> Thanks!
>>  >>
>>  >>
>>  >>
>>  >> Jeanfrancois Arcand wrote:
>>  >>> Salut,
>>  >>>
>>  >>> Jeanfrancois Arcand wrote:
>>  >>>> Salut,
>>  >>>>
>>  >>>> let me try to reproduce locally. Thanks for sharing!
>>  >>> It seems loading a class using Class.forName doesn't work we ran in
>>  >>> JRuby. I'm attaching a patch to see if that will fix your issues. I'm
>>  >>> build the patch agains 0.3.1, so just replace the
>>  >>> atmosphere-portable-runtime.jar file.
>>  >>>
>>  >>> Let me know the result!
>>  >>>
>>  >>> A+
>>  >>>
>>  >>> --Jeanfrancois
>>  >>>
>>  >>>> Stay tuned!
>>  >>>>
>>  >>>> -- Jeanfrancois
>>  >>>>
>>  >>>> Michal Hantl wrote:
>>  >>>>> Here is a report on my progress.
>>  >>>>>
>>  >>>>> I got the jetty demo running, then i added atmosphere and changed
>> the
>>  >>>>> source.
>>  >>>>>
>>  >>>>> It complained about session so i changed
>>  >>>>> And now i get this:
>>  >>>>> (so far no idea what to do with it, but still googling)
>>  >>>>>
>>  >>>>> Problem accessing /. Reason:
>>  >>>>>
>>  >>>>>     INTERNAL_SERVER_ERROR
>>  >>>>> Caused by:
>>  >>>>>
>>  >>>>> java.lang.NullPointerException
>>  >>>>>     at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown
>> Source)
>>  >>>>>     at
>>  >>>>>
>> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>>  >>>>>     at
>>  >>>>>
>>  >>>>>
>>
>> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>>
>>  >>>>>
>>  >>>>>     at
>>  >>>>>
>>  >>>>>
>>
>> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>>
>>  >>>>>
>>  >>>>>     at
>>  >>>>>
>>  >>>>>
>>
>> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>>
>>  >>>>>
>>  >>>>>     at
>>  >>>>>
>>  >>>>>
>>
>> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>>
>>  >>>>>
>>  >>>>>     at
>>  >>>>>
>>  >>>>>
>>
>> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:662)
>>
>>  >>>>>
>>  >>>>>     at
>>  >>>>>
>> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:647)
>>  >>>>>     at
>>  >>>>>
>> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:634)
>>  >>>>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>>  >>>>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>  >>>>>     at
>>  >>>>>
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>>  >>>>>     at
>>  >>>>>
>>  >>>>>
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>>  >>>>>     at
>>  >>>>>
>>  >>>>>
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>  >>>>>     at
>>  >>>>>
>>  >>>>>
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>  >>>>>     at
>>  >>>>>
>>  >>>>>
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>  >>>>>     at org.mortbay.jetty.Server.handle(Server.java:324)
>>  >>>>>     at
>>  >>>>>
>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>>  >>>>>     at
>>  >>>>>
>>  >>>>>
>>
>> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>>
>>  >>>>>
>>  >>>>>     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>>  >>>>>     at
>> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>  >>>>>     at
>> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>  >>>>>     at
>>  >>>>>
>>  >>>>>
>>
>> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>>
>>  >>>>>
>>  >>>>>     at
>>  >>>>>
>>  >>>>>
>>
>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>>
>>  >>>>>
>>  >>>>>
>>  >>>>>
>>  >>>>> the source code of my attempt:
>>  >>>>>
>>  >>>>> require 'java'
>>  >>>>>
>>  >>>>> Dir["./Java/jetty/*.jar"].each { |jar| require jar }
>>  >>>>> Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
>>  >>>>> Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
>>  >>>>> Dir["./Java/apache/*.jar"].each { |jar| require jar }
>>  >>>>>
>>  >>>>> include_class 'javax.servlet.http.HttpServlet'
>>  >>>>> include_class 'org.mortbay.jetty.Server'
>>  >>>>> include_class 'org.mortbay.jetty.servlet.Context'
>>  >>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>>  >>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>>  >>>>> include_class 'org.atmosphere.cpr.AtmosphereHandler'
>>  >>>>> include_class 'org.atmosphere.cpr.AtmosphereServlet'
>>  >>>>> include_class 'org.apache.catalina.CometProcessor'
>>  >>>>>
>>  >>>>> def main
>>  >>>>>   server = Server.new(8080)
>>  >>>>>   #context = Context.new(server, '/', 0)
>>  >>>>>   context = Context.new(server, '/', Context::SESSIONS)
>>  >>>>>
>>  >>>>>   servlet = AtmosphereServlet.new()
>>  >>>>>   servlet.addAtmosphereHandler("/", MyRubyHandler.new())
>>  >>>>>     holder = ServletHolder.new(servlet)
>>  >>>>>   context.addServlet(holder, '/')
>>  >>>>>     server.start()
>>  >>>>> end
>>  >>>>>
>>  >>>>>
>>  >>>>>
>>  >>>>> class MyRubyHandler
>>  >>>>>   include AtmosphereHandler
>>  >>>>>
>>  >>>>>   BEGIN_SCRIPT_TAG = '<script>'
>>  >>>>>   END_SCRIPT_TAG = '</script>'
>>  >>>>>
>>  >>>>>   def onEvent(event)
>>  >>>>>         req = event.getRequest();
>>  >>>>>         res = event.getResponse();
>>  >>>>>
>>  >>>>>         res.setContentType("text/html")
>>  >>>>>         res.addHeader("Cache-Control", "private")
>>  >>>>>         res.addHeader("Pragma", "no-cache")
>>  >>>>>         res.getWriter().write("<html><body><h1>It
>>  >>>>> works!</h1></body></html>\n");
>>  >>>>>         res.getWriter().flush();
>>  >>>>>
>>  >>>>>
>>  >>>>> #        if (req.getMethod().equalsIgnoreCase("GET"))
>>  >>>>> #            # for IE
>>  >>>>> #            res.getWriter().write("<!-- Comet is a programming
>>  >>>>> technique
>>  >>>>> that enables web " +
>>  >>>>> #                    "servers to send data to the client without
>>  >>>>> having any
>>  >>>>> need " +
>>  >>>>> #                    "for the client to request it. -->\n");
>>  >>>>> #            res.getWriter().flush();
>>  >>>>> #
>>  >>>>> #            #
>>  >>>>> #            # Mark this connection as suspended.
>>  >>>>> #            #
>>  >>>>> #            event.suspend();
>>  >>>>> #        elsif (req.getMethod().equalsIgnoreCase("POST"))
>>  >>>>> #            res.setCharacterEncoding("UTF-8");
>>  >>>>> #            String action = req.getParameterValues("action")[0];
>>  >>>>> #            String name = req.getParameterValues("name")[0];
>>  >>>>> #
>>  >>>>> #            if "login".equals(action)
>>  >>>>> #                event.getBroadcaster().broadcast(
>>  >>>>> #                  BEGIN_SCRIPT_TAG +
>>  >>>>> #                    toJsonp("System Message from " +
>>  >>>>> event.getWebServerName(),
>>  >>>>> #                      name + " has joined.") +
>>  >>>>> #                  END_SCRIPT_TAG);
>>  >>>>> #
>>  >>>>> #                res.getWriter().write("success");
>>  >>>>> #                res.getWriter().flush();
>>  >>>>> #            elsif ("post".equals(action))
>>  >>>>> #                message = req.getParameterValues("message")[0];
>>  >>>>> #                event.getBroadcaster().broadcast(
>>  >>>>> #                  BEGIN_SCRIPT_TAG + toJsonp(name, message) +
>>  >>>>> END_SCRIPT_TAG);
>>  >>>>> #                res.getWriter().write("success");
>>  >>>>> #                res.getWriter().flush();
>>  >>>>> #            else
>>  >>>>> #                res.setStatus(422);
>>  >>>>> #
>>  >>>>> #                res.getWriter().write("success");
>>  >>>>> #                res.getWriter().flush();
>>  >>>>> #            end
>>  >>>>> #        end
>>  >>>>>         return event;
>>  >>>>>     end
>>  >>>>>
>>  >>>>>     def onMessage(event)
>>  >>>>>         req = event.getRequest();
>>  >>>>>         res = event.getResponse();
>>  >>>>>
>>  >>>>>         if (event.isResuming() || event.isResumedOnTimedout())
>>  >>>>>             script = BEGIN_SCRIPT_TAG +
>> "window.parent.app.listen();\n"
>>  >>>>> +
>>  >>>>> END_SCRIPT_TAG;
>>  >>>>>             res.getWriter().write(script);
>>  >>>>>             res.getWriter().flush();
>>  >>>>>         else
>>  >>>>>             res.getWriter().write(event.getMessage().toString());
>>  >>>>>             res.getWriter().flush();
>>  >>>>>         end
>>  >>>>>         return event;
>>  >>>>>     end
>>  >>>>> end
>>  >>>>>
>>  >>>>>
>>  >>>>> main
>>  >>>>>
>>  >>>>> --end of ruby source--
>>  >>>>>
>>  >>>>>
>>  >>>>> Thank you very much for support.
>>  >>>>>
>>  >>>>
>> ---------------------------------------------------------------------
>>  >>>> To unsubscribe, e-mail: [hidden email]
>>  >>>> For additional commands, e-mail: [hidden email]
>>  >>>>
>>  >>>
>>  >>> ---------------------------------------------------------------------
>>  >>> To unsubscribe, e-mail: [hidden email]
>>  >>> For additional commands, e-mail: [hidden email]
>>  >>>
>>  >>
>>  > ---------------------------------------------------------------------
>>  > To unsubscribe, e-mail: [hidden email]
>>  > For additional commands, e-mail: [hidden email]
>>  >
>>  >
>>  >
>>  > ________________________________
>>  > View message @
>>  >
>>
>> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3553859.html
>>  > To unsubscribe from Iframe streaming with Jruby and Atmosphere, click
>> here.
>>  >
>>
>>
>>
>> --
>> S pozdravem, Regards
>> Michal Hantl
>>
>> gtalk/jabber: [hidden email]
>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1>
>> icq: 241813215
>>
>> ------------------------------------------------------------------------
>> View this message in context: Re: Iframe streaming with Jruby and
>> Atmosphere
>>
>> <http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3554785.html>
>> Sent from the Atmosphere users mailling list mailing list archive
>> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
>> Nabble.com.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
> ________________________________
> View message @
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555505.html
> To unsubscribe from Iframe streaming with Jruby and Atmosphere, click here.
>



--
S pozdravem, Regards
Michal Hantl

gtalk/jabber: [hidden email]
icq: 241813215
Jeanfrancois Arcand

Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
Salut,

Michal Hantl wrote:

> 2009/8/31 Jeanfrancois Arcand (via Nabble)
> <[hidden email]
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3555776&i=0>>:
>  > Salut,
>  >
>  > Michal Hantl wrote:
>  >> Hi,
>  >>  I didnt attach the error because it stayed the same.
>  >
>  > Same line? I was under the impression the new jar will changes that.
>
> Seems exactly the same:
>
> HTTP ERROR 500
>
> Problem accessing /. Reason:
>
>     INTERNAL_SERVER_ERROR
> Caused by:
>
> java.lang.NullPointerException
>         at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown Source)
>         at
> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>         at
> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>
>         at
> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>
>         at
> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>
>         at
> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>
>         at
> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:665)
>
>         at
> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:650)
>         at
> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:637)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>         at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>         at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>         at
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>         at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>         at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>         at org.mortbay.jetty.Server.handle(Server.java:324)
>         at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>         at
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>
>         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>         at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>         at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>         at
> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>
>         at
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>
>

Thanks

>
>
>  >
>  >>
>  >> Does my rar show you the same error?
>  >
>  > Actually I haven't figured yet how to start it. I looked at
>  > atmosphere.bat but I'm getting some errors. What is the easiest way to
>  > reproduce it?
>
> Yes, atmosphere.bat should start it. Jruby and all other jars are
> included so it should just work.

It complains about:

> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$ java -jar jruby.jar atmosphere.rb
> (eval):1:in `include_class': cannot load Java class javax.servlet.http.HttpServlet (NameError)

I did try:

> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$ java -cp /. -jar jruby.jar atmosphere.rb
> (eval):1:in `include_class': cannot load Java class javax.servlet.http.HttpServlet (NameError)


or

> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$ java -cp servlet-api.jar -jar jruby.jar atmosphere.rb
> (eval):1:in `include_class': cannot load Java class javax.servlet.http.HttpServlet (NameError)

or

> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$ java -cp *.jar -jar jruby.jar atmosphere.rb


What is the exact command line you are running? I'm under Ubuntu (but
will gives a try using XP).

A+

-- jeanfrancois


>
> Are you using windows? I am running XP, not sure if that can be a
> problem.. I havent tested it under linux (none installed right now).
>
> What error are you getting? I will look into the jar to see where are
> the lines of the problem, maybe i can google something.
>
>
>
>
>
>  >
>  > Thanks
>  >
>  > -- Jeanfarncois
>  >
>  >>
>  >> 2009/8/31 Jeanfrancois Arcand (via Nabble)
>  >> <[hidden email]
>  >> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0 
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0>>>:
>  >>
>  >>  > Salut,
>  >>  >
>  >>  > Michal Hantl wrote:
>  >>  >> Thanks for sending a patch so quickly!
>  >>  >>
>  >>  >> (And sorry for delayed reply, I wasn't home till now.)
>  >>  >>
>  >>  >> I tried the patched version, but same error occurs.
>  >>  >>
>  >>  >> Here is the full project, so you dont have to re-create:
>  >>  >> http://d.hantl.cz/jruby_atmosphere.rar
>  >>  >>
>  >>  >> (Might be something I did wrong, since I am pretty new to this.)
>  >>  > Can you cut & past the error? I'm installing your project as well.
>  >>  >
>  >>  > Thanks
>  >>  >
>  >>  > -- Jeanfrancois
>  >>  >
>  >>  >
>  >>  >>
>  >>  >> Thanks!
>  >>  >>
>  >>  >>
>  >>  >>
>  >>  >> Jeanfrancois Arcand wrote:
>  >>  >>> Salut,
>  >>  >>>
>  >>  >>> Jeanfrancois Arcand wrote:
>  >>  >>>> Salut,
>  >>  >>>>
>  >>  >>>> let me try to reproduce locally. Thanks for sharing!
>  >>  >>> It seems loading a class using Class.forName doesn't work we
> ran in
>  >>  >>> JRuby. I'm attaching a patch to see if that will fix your
> issues. I'm
>  >>  >>> build the patch agains 0.3.1, so just replace the
>  >>  >>> atmosphere-portable-runtime.jar file.
>  >>  >>>
>  >>  >>> Let me know the result!
>  >>  >>>
>  >>  >>> A+
>  >>  >>>
>  >>  >>> --Jeanfrancois
>  >>  >>>
>  >>  >>>> Stay tuned!
>  >>  >>>>
>  >>  >>>> -- Jeanfrancois
>  >>  >>>>
>  >>  >>>> Michal Hantl wrote:
>  >>  >>>>> Here is a report on my progress.
>  >>  >>>>>
>  >>  >>>>> I got the jetty demo running, then i added atmosphere and
> changed
>  >> the
>  >>  >>>>> source.
>  >>  >>>>>
>  >>  >>>>> It complained about session so i changed
>  >>  >>>>> And now i get this:
>  >>  >>>>> (so far no idea what to do with it, but still googling)
>  >>  >>>>>
>  >>  >>>>> Problem accessing /. Reason:
>  >>  >>>>>
>  >>  >>>>>     INTERNAL_SERVER_ERROR
>  >>  >>>>> Caused by:
>  >>  >>>>>
>  >>  >>>>> java.lang.NullPointerException
>  >>  >>>>>     at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown
>  >> Source)
>  >>  >>>>>     at
>  >>  >>>>>
>  >> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>  >>  >>>>>     at
>  >>  >>>>>
>  >>  >>>>>
>  >>
>  >>
> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>
>  >>
>  >>  >>>>>
>  >>  >>>>>     at
>  >>  >>>>>
>  >>  >>>>>
>  >>
>  >>
> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>
>  >>
>  >>  >>>>>
>  >>  >>>>>     at
>  >>  >>>>>
>  >>  >>>>>
>  >>
>  >>
> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>
>  >>
>  >>  >>>>>
>  >>  >>>>>     at
>  >>  >>>>>
>  >>  >>>>>
>  >>
>  >>
> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>
>  >>
>  >>  >>>>>
>  >>  >>>>>     at
>  >>  >>>>>
>  >>  >>>>>
>  >>
>  >>
> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:662)
>
>  >>
>  >>  >>>>>
>  >>  >>>>>     at
>  >>  >>>>>
>  >> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:647)
>  >>  >>>>>     at
>  >>  >>>>>
>  >> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:634)
>  >>  >>>>>     at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>  >>  >>>>>     at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>  >>  >>>>>     at
>  >>  >>>>>
>  >> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>  >>  >>>>>     at
>  >>  >>>>>
>  >>  >>>>>
>  >>
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>  >>  >>>>>     at
>  >>  >>>>>
>  >>  >>>>>
>  >>
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>  >>  >>>>>     at
>  >>  >>>>>
>  >>  >>>>>
>  >>
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>  >>  >>>>>     at
>  >>  >>>>>
>  >>  >>>>>
>  >>
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>  >>  >>>>>     at org.mortbay.jetty.Server.handle(Server.java:324)
>  >>  >>>>>     at
>  >>  >>>>>
>  >> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>  >>  >>>>>     at
>  >>  >>>>>
>  >>  >>>>>
>  >>
>  >>
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>
>  >>
>  >>  >>>>>
>  >>  >>>>>     at
> org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>  >>  >>>>>     at
>  >> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>  >>  >>>>>     at
>  >> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>  >>  >>>>>     at
>  >>  >>>>>
>  >>  >>>>>
>  >>
>  >>
> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>
>  >>
>  >>  >>>>>
>  >>  >>>>>     at
>  >>  >>>>>
>  >>  >>>>>
>  >>
>  >>
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>
>  >>
>  >>  >>>>>
>  >>  >>>>>
>  >>  >>>>>
>  >>  >>>>> the source code of my attempt:
>  >>  >>>>>
>  >>  >>>>> require 'java'
>  >>  >>>>>
>  >>  >>>>> Dir["./Java/jetty/*.jar"].each { |jar| require jar }
>  >>  >>>>> Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
>  >>  >>>>> Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
>  >>  >>>>> Dir["./Java/apache/*.jar"].each { |jar| require jar }
>  >>  >>>>>
>  >>  >>>>> include_class 'javax.servlet.http.HttpServlet'
>  >>  >>>>> include_class 'org.mortbay.jetty.Server'
>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.Context'
>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>  >>  >>>>> include_class 'org.atmosphere.cpr.AtmosphereHandler'
>  >>  >>>>> include_class 'org.atmosphere.cpr.AtmosphereServlet'
>  >>  >>>>> include_class 'org.apache.catalina.CometProcessor'
>  >>  >>>>>
>  >>  >>>>> def main
>  >>  >>>>>   server = Server.new(8080)
>  >>  >>>>>   #context = Context.new(server, '/', 0)
>  >>  >>>>>   context = Context.new(server, '/', Context::SESSIONS)
>  >>  >>>>>
>  >>  >>>>>   servlet = AtmosphereServlet.new()
>  >>  >>>>>   servlet.addAtmosphereHandler("/", MyRubyHandler.new())
>  >>  >>>>>     holder = ServletHolder.new(servlet)
>  >>  >>>>>   context.addServlet(holder, '/')
>  >>  >>>>>     server.start()
>  >>  >>>>> end
>  >>  >>>>>
>  >>  >>>>>
>  >>  >>>>>
>  >>  >>>>> class MyRubyHandler
>  >>  >>>>>   include AtmosphereHandler
>  >>  >>>>>
>  >>  >>>>>   BEGIN_SCRIPT_TAG = '<script>'
>  >>  >>>>>   END_SCRIPT_TAG = '</script>'
>  >>  >>>>>
>  >>  >>>>>   def onEvent(event)
>  >>  >>>>>         req = event.getRequest();
>  >>  >>>>>         res = event.getResponse();
>  >>  >>>>>
>  >>  >>>>>         res.setContentType("text/html")
>  >>  >>>>>         res.addHeader("Cache-Control", "private")
>  >>  >>>>>         res.addHeader("Pragma", "no-cache")
>  >>  >>>>>         res.getWriter().write("<html><body><h1>It
>  >>  >>>>> works!</h1></body></html>\n");
>  >>  >>>>>         res.getWriter().flush();
>  >>  >>>>>
>  >>  >>>>>
>  >>  >>>>> #        if (req.getMethod().equalsIgnoreCase("GET"))
>  >>  >>>>> #            # for IE
>  >>  >>>>> #            res.getWriter().write("<!-- Comet is a programming
>  >>  >>>>> technique
>  >>  >>>>> that enables web " +
>  >>  >>>>> #                    "servers to send data to the client without
>  >>  >>>>> having any
>  >>  >>>>> need " +
>  >>  >>>>> #                    "for the client to request it. -->\n");
>  >>  >>>>> #            res.getWriter().flush();
>  >>  >>>>> #
>  >>  >>>>> #            #
>  >>  >>>>> #            # Mark this connection as suspended.
>  >>  >>>>> #            #
>  >>  >>>>> #            event.suspend();
>  >>  >>>>> #        elsif (req.getMethod().equalsIgnoreCase("POST"))
>  >>  >>>>> #            res.setCharacterEncoding("UTF-8");
>  >>  >>>>> #            String action =
> req.getParameterValues("action")[0];
>  >>  >>>>> #            String name = req.getParameterValues("name")[0];
>  >>  >>>>> #
>  >>  >>>>> #            if "login".equals(action)
>  >>  >>>>> #                event.getBroadcaster().broadcast(
>  >>  >>>>> #                  BEGIN_SCRIPT_TAG +
>  >>  >>>>> #                    toJsonp("System Message from " +
>  >>  >>>>> event.getWebServerName(),
>  >>  >>>>> #                      name + " has joined.") +
>  >>  >>>>> #                  END_SCRIPT_TAG);
>  >>  >>>>> #
>  >>  >>>>> #                res.getWriter().write("success");
>  >>  >>>>> #                res.getWriter().flush();
>  >>  >>>>> #            elsif ("post".equals(action))
>  >>  >>>>> #                message = req.getParameterValues("message")[0];
>  >>  >>>>> #                event.getBroadcaster().broadcast(
>  >>  >>>>> #                  BEGIN_SCRIPT_TAG + toJsonp(name, message) +
>  >>  >>>>> END_SCRIPT_TAG);
>  >>  >>>>> #                res.getWriter().write("success");
>  >>  >>>>> #                res.getWriter().flush();
>  >>  >>>>> #            else
>  >>  >>>>> #                res.setStatus(422);
>  >>  >>>>> #
>  >>  >>>>> #                res.getWriter().write("success");
>  >>  >>>>> #                res.getWriter().flush();
>  >>  >>>>> #            end
>  >>  >>>>> #        end
>  >>  >>>>>         return event;
>  >>  >>>>>     end
>  >>  >>>>>
>  >>  >>>>>     def onMessage(event)
>  >>  >>>>>         req = event.getRequest();
>  >>  >>>>>         res = event.getResponse();
>  >>  >>>>>
>  >>  >>>>>         if (event.isResuming() || event.isResumedOnTimedout())
>  >>  >>>>>             script = BEGIN_SCRIPT_TAG +
>  >> "window.parent.app.listen();\n"
>  >>  >>>>> +
>  >>  >>>>> END_SCRIPT_TAG;
>  >>  >>>>>             res.getWriter().write(script);
>  >>  >>>>>             res.getWriter().flush();
>  >>  >>>>>         else
>  >>  >>>>>            
> res.getWriter().write(event.getMessage().toString());
>  >>  >>>>>             res.getWriter().flush();
>  >>  >>>>>         end
>  >>  >>>>>         return event;
>  >>  >>>>>     end
>  >>  >>>>> end
>  >>  >>>>>
>  >>  >>>>>
>  >>  >>>>> main
>  >>  >>>>>
>  >>  >>>>> --end of ruby source--
>  >>  >>>>>
>  >>  >>>>>
>  >>  >>>>> Thank you very much for support.
>  >>  >>>>>
>  >>  >>>>
>  >> ---------------------------------------------------------------------
>  >>  >>>> To unsubscribe, e-mail: [hidden email]
>  >>  >>>> For additional commands, e-mail: [hidden email]
>  >>  >>>>
>  >>  >>>
>  >>  >>>
> ---------------------------------------------------------------------
>  >>  >>> To unsubscribe, e-mail: [hidden email]
>  >>  >>> For additional commands, e-mail: [hidden email]
>  >>  >>>
>  >>  >>
>  >>  >
> ---------------------------------------------------------------------
>  >>  > To unsubscribe, e-mail: [hidden email]
>  >>  > For additional commands, e-mail: [hidden email]
>  >>  >
>  >>  >
>  >>  >
>  >>  > ________________________________
>  >>  > View message @
>  >>  >
>  >>
>  >>
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3553859.html
>  >>  > To unsubscribe from Iframe streaming with Jruby and Atmosphere,
> click
>  >> here.
>  >>  >
>  >>
>  >>
>  >>
>  >> --
>  >> S pozdravem, Regards
>  >> Michal Hantl
>  >>
>  >> gtalk/jabber: [hidden email]
>  >> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1 
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1>>
>  >> icq: 241813215
>  >>
>  >>
> ------------------------------------------------------------------------
>  >> View this message in context: Re: Iframe streaming with Jruby and
>  >> Atmosphere
>  >>
>  >>
> <http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3554785.html>
>
>  >> Sent from the Atmosphere users mailling list mailing list archive
>  >> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
>  >> Nabble.com.
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: [hidden email]
>  > For additional commands, e-mail: [hidden email]
>  >
>  >
>  >
>  > ________________________________
>  > View message @
>  >
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555505.html
>  > To unsubscribe from Iframe streaming with Jruby and Atmosphere, click
> here.
>  >
>
>
>
> --
> S pozdravem, Regards
> Michal Hantl
>
> gtalk/jabber: [hidden email]
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3555776&i=1>
> icq: 241813215
>
> ------------------------------------------------------------------------
> View this message in context: Re: Iframe streaming with Jruby and
> Atmosphere
> <http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555776.html>
> Sent from the Atmosphere users mailling list mailing list archive
> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
> Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Michal Hantl

Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
2009/8/31 Jeanfrancois Arcand (via Nabble)
<[hidden email]>:

> Salut,
>
> Michal Hantl wrote:
>> 2009/8/31 Jeanfrancois Arcand (via Nabble)
>> <[hidden email]
>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3555776&i=0>>:
>>  > Salut,
>>  >
>>  > Michal Hantl wrote:
>>  >> Hi,
>>  >>  I didnt attach the error because it stayed the same.
>>  >
>>  > Same line? I was under the impression the new jar will changes that.
>>
>> Seems exactly the same:
>>
>> HTTP ERROR 500
>>
>> Problem accessing /. Reason:
>>
>>     INTERNAL_SERVER_ERROR
>> Caused by:
>>
>> java.lang.NullPointerException
>>         at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown
>> Source)
>>         at
>> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>>         at
>>
>> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>>
>>         at
>>
>> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>>
>>         at
>>
>> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>>
>>         at
>>
>> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>>
>>         at
>>
>> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:665)
>>
>>         at
>> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:650)
>>         at
>> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:637)
>>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>         at
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>>         at
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>>         at
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>         at
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>         at
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>         at org.mortbay.jetty.Server.handle(Server.java:324)
>>         at
>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>>         at
>>
>> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>>
>>         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>>         at
>> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>         at
>> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>         at
>>
>> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>>
>>         at
>>
>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>>
>>
> Thanks
>
>>
>>
>>  >
>>  >>
>>  >> Does my rar show you the same error?
>>  >
>>  > Actually I haven't figured yet how to start it. I looked at
>>  > atmosphere.bat but I'm getting some errors. What is the easiest way to
>>  > reproduce it?
>>
>> Yes, atmosphere.bat should start it. Jruby and all other jars are
>> included so it should just work.
> It complains about:
>
>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$ java
>> -jar jruby.jar atmosphere.rb
>> (eval):1:in `include_class': cannot load Java class
>> javax.servlet.http.HttpServlet (NameError)
>
> I did try:
>
>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$ java
>> -cp /. -jar jruby.jar atmosphere.rb
>> (eval):1:in `include_class': cannot load Java class
>> javax.servlet.http.HttpServlet (NameError)
>
>
> or
>
>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$ java
>> -cp servlet-api.jar -jar jruby.jar atmosphere.rb
>> (eval):1:in `include_class': cannot load Java class
>> javax.servlet.http.HttpServlet (NameError)

This means he was not able to load the jar and now when importing, it
doesnt have the source for that class.

Must be some kind of difference between discovering paths on ubuntu.
Will install portable ubuntu and try.

>
> or
>
>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$ java
>> -cp *.jar -jar jruby.jar atmosphere.rb
>
>
> What is the exact command line you are running? I'm under Ubuntu (but
> will gives a try using XP).

I just run atmosphere.bat.

>
> A+
>
> -- jeanfrancois
>
>
>>
>> Are you using windows? I am running XP, not sure if that can be a
>> problem.. I havent tested it under linux (none installed right now).
>>
>> What error are you getting? I will look into the jar to see where are
>> the lines of the problem, maybe i can google something.
>>
>>
>>
>>
>>
>>  >
>>  > Thanks
>>  >
>>  > -- Jeanfarncois
>>  >
>>  >>
>>  >> 2009/8/31 Jeanfrancois Arcand (via Nabble)
>>  >> <[hidden email]
>>  >> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0
>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0>>>:
>>  >>
>>  >>  > Salut,
>>  >>  >
>>  >>  > Michal Hantl wrote:
>>  >>  >> Thanks for sending a patch so quickly!
>>  >>  >>
>>  >>  >> (And sorry for delayed reply, I wasn't home till now.)
>>  >>  >>
>>  >>  >> I tried the patched version, but same error occurs.
>>  >>  >>
>>  >>  >> Here is the full project, so you dont have to re-create:
>>  >>  >> http://d.hantl.cz/jruby_atmosphere.rar
>>  >>  >>
>>  >>  >> (Might be something I did wrong, since I am pretty new to this.)
>>  >>  > Can you cut & past the error? I'm installing your project as well.
>>  >>  >
>>  >>  > Thanks
>>  >>  >
>>  >>  > -- Jeanfrancois
>>  >>  >
>>  >>  >
>>  >>  >>
>>  >>  >> Thanks!
>>  >>  >>
>>  >>  >>
>>  >>  >>
>>  >>  >> Jeanfrancois Arcand wrote:
>>  >>  >>> Salut,
>>  >>  >>>
>>  >>  >>> Jeanfrancois Arcand wrote:
>>  >>  >>>> Salut,
>>  >>  >>>>
>>  >>  >>>> let me try to reproduce locally. Thanks for sharing!
>>  >>  >>> It seems loading a class using Class.forName doesn't work we
>> ran in
>>  >>  >>> JRuby. I'm attaching a patch to see if that will fix your
>> issues. I'm
>>  >>  >>> build the patch agains 0.3.1, so just replace the
>>  >>  >>> atmosphere-portable-runtime.jar file.
>>  >>  >>>
>>  >>  >>> Let me know the result!
>>  >>  >>>
>>  >>  >>> A+
>>  >>  >>>
>>  >>  >>> --Jeanfrancois
>>  >>  >>>
>>  >>  >>>> Stay tuned!
>>  >>  >>>>
>>  >>  >>>> -- Jeanfrancois
>>  >>  >>>>
>>  >>  >>>> Michal Hantl wrote:
>>  >>  >>>>> Here is a report on my progress.
>>  >>  >>>>>
>>  >>  >>>>> I got the jetty demo running, then i added atmosphere and
>> changed
>>  >> the
>>  >>  >>>>> source.
>>  >>  >>>>>
>>  >>  >>>>> It complained about session so i changed
>>  >>  >>>>> And now i get this:
>>  >>  >>>>> (so far no idea what to do with it, but still googling)
>>  >>  >>>>>
>>  >>  >>>>> Problem accessing /. Reason:
>>  >>  >>>>>
>>  >>  >>>>>     INTERNAL_SERVER_ERROR
>>  >>  >>>>> Caused by:
>>  >>  >>>>>
>>  >>  >>>>> java.lang.NullPointerException
>>  >>  >>>>>     at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown
>>  >> Source)
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>
>>  >>
>>
>> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>>
>>  >>
>>  >>  >>>>>
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>
>>  >>
>>
>> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>>
>>  >>
>>  >>  >>>>>
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>
>>  >>
>>
>> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>>
>>  >>
>>  >>  >>>>>
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>
>>  >>
>>
>> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>>
>>  >>
>>  >>  >>>>>
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>
>>  >>
>>
>> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:662)
>>
>>  >>
>>  >>  >>>>>
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >>
>> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:647)
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:634)
>>  >>  >>>>>     at
>> javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>>  >>  >>>>>     at
>> javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>  >>  >>>>>     at org.mortbay.jetty.Server.handle(Server.java:324)
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >>
>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>
>>  >>
>>
>> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>>
>>  >>
>>  >>  >>>>>
>>  >>  >>>>>     at
>> org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>>  >>  >>>>>     at
>>  >> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>  >>  >>>>>     at
>>  >> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>
>>  >>
>>
>> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>>
>>  >>
>>  >>  >>>>>
>>  >>  >>>>>     at
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>
>>  >>
>>
>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>>
>>  >>
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>  >>>>> the source code of my attempt:
>>  >>  >>>>>
>>  >>  >>>>> require 'java'
>>  >>  >>>>>
>>  >>  >>>>> Dir["./Java/jetty/*.jar"].each { |jar| require jar }
>>  >>  >>>>> Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
>>  >>  >>>>> Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
>>  >>  >>>>> Dir["./Java/apache/*.jar"].each { |jar| require jar }
>>  >>  >>>>>
>>  >>  >>>>> include_class 'javax.servlet.http.HttpServlet'
>>  >>  >>>>> include_class 'org.mortbay.jetty.Server'
>>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.Context'
>>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>>  >>  >>>>> include_class 'org.atmosphere.cpr.AtmosphereHandler'
>>  >>  >>>>> include_class 'org.atmosphere.cpr.AtmosphereServlet'
>>  >>  >>>>> include_class 'org.apache.catalina.CometProcessor'
>>  >>  >>>>>
>>  >>  >>>>> def main
>>  >>  >>>>>   server = Server.new(8080)
>>  >>  >>>>>   #context = Context.new(server, '/', 0)
>>  >>  >>>>>   context = Context.new(server, '/', Context::SESSIONS)
>>  >>  >>>>>
>>  >>  >>>>>   servlet = AtmosphereServlet.new()
>>  >>  >>>>>   servlet.addAtmosphereHandler("/", MyRubyHandler.new())
>>  >>  >>>>>     holder = ServletHolder.new(servlet)
>>  >>  >>>>>   context.addServlet(holder, '/')
>>  >>  >>>>>     server.start()
>>  >>  >>>>> end
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>  >>>>> class MyRubyHandler
>>  >>  >>>>>   include AtmosphereHandler
>>  >>  >>>>>
>>  >>  >>>>>   BEGIN_SCRIPT_TAG = '<script>'
>>  >>  >>>>>   END_SCRIPT_TAG = '</script>'
>>  >>  >>>>>
>>  >>  >>>>>   def onEvent(event)
>>  >>  >>>>>         req = event.getRequest();
>>  >>  >>>>>         res = event.getResponse();
>>  >>  >>>>>
>>  >>  >>>>>         res.setContentType("text/html")
>>  >>  >>>>>         res.addHeader("Cache-Control", "private")
>>  >>  >>>>>         res.addHeader("Pragma", "no-cache")
>>  >>  >>>>>         res.getWriter().write("<html><body><h1>It
>>  >>  >>>>> works!</h1></body></html>\n");
>>  >>  >>>>>         res.getWriter().flush();
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>  >>>>> #        if (req.getMethod().equalsIgnoreCase("GET"))
>>  >>  >>>>> #            # for IE
>>  >>  >>>>> #            res.getWriter().write("<!-- Comet is a programming
>>  >>  >>>>> technique
>>  >>  >>>>> that enables web " +
>>  >>  >>>>> #                    "servers to send data to the client
>> without
>>  >>  >>>>> having any
>>  >>  >>>>> need " +
>>  >>  >>>>> #                    "for the client to request it. -->\n");
>>  >>  >>>>> #            res.getWriter().flush();
>>  >>  >>>>> #
>>  >>  >>>>> #            #
>>  >>  >>>>> #            # Mark this connection as suspended.
>>  >>  >>>>> #            #
>>  >>  >>>>> #            event.suspend();
>>  >>  >>>>> #        elsif (req.getMethod().equalsIgnoreCase("POST"))
>>  >>  >>>>> #            res.setCharacterEncoding("UTF-8");
>>  >>  >>>>> #            String action =
>> req.getParameterValues("action")[0];
>>  >>  >>>>> #            String name = req.getParameterValues("name")[0];
>>  >>  >>>>> #
>>  >>  >>>>> #            if "login".equals(action)
>>  >>  >>>>> #                event.getBroadcaster().broadcast(
>>  >>  >>>>> #                  BEGIN_SCRIPT_TAG +
>>  >>  >>>>> #                    toJsonp("System Message from " +
>>  >>  >>>>> event.getWebServerName(),
>>  >>  >>>>> #                      name + " has joined.") +
>>  >>  >>>>> #                  END_SCRIPT_TAG);
>>  >>  >>>>> #
>>  >>  >>>>> #                res.getWriter().write("success");
>>  >>  >>>>> #                res.getWriter().flush();
>>  >>  >>>>> #            elsif ("post".equals(action))
>>  >>  >>>>> #                message =
>> req.getParameterValues("message")[0];
>>  >>  >>>>> #                event.getBroadcaster().broadcast(
>>  >>  >>>>> #                  BEGIN_SCRIPT_TAG + toJsonp(name, message) +
>>  >>  >>>>> END_SCRIPT_TAG);
>>  >>  >>>>> #                res.getWriter().write("success");
>>  >>  >>>>> #                res.getWriter().flush();
>>  >>  >>>>> #            else
>>  >>  >>>>> #                res.setStatus(422);
>>  >>  >>>>> #
>>  >>  >>>>> #                res.getWriter().write("success");
>>  >>  >>>>> #                res.getWriter().flush();
>>  >>  >>>>> #            end
>>  >>  >>>>> #        end
>>  >>  >>>>>         return event;
>>  >>  >>>>>     end
>>  >>  >>>>>
>>  >>  >>>>>     def onMessage(event)
>>  >>  >>>>>         req = event.getRequest();
>>  >>  >>>>>         res = event.getResponse();
>>  >>  >>>>>
>>  >>  >>>>>         if (event.isResuming() || event.isResumedOnTimedout())
>>  >>  >>>>>             script = BEGIN_SCRIPT_TAG +
>>  >> "window.parent.app.listen();\n"
>>  >>  >>>>> +
>>  >>  >>>>> END_SCRIPT_TAG;
>>  >>  >>>>>             res.getWriter().write(script);
>>  >>  >>>>>             res.getWriter().flush();
>>  >>  >>>>>         else
>>  >>  >>>>>
>> res.getWriter().write(event.getMessage().toString());
>>  >>  >>>>>             res.getWriter().flush();
>>  >>  >>>>>         end
>>  >>  >>>>>         return event;
>>  >>  >>>>>     end
>>  >>  >>>>> end
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>  >>>>> main
>>  >>  >>>>>
>>  >>  >>>>> --end of ruby source--
>>  >>  >>>>>
>>  >>  >>>>>
>>  >>  >>>>> Thank you very much for support.
>>  >>  >>>>>
>>  >>  >>>>
>>  >> ---------------------------------------------------------------------
>>  >>  >>>> To unsubscribe, e-mail: [hidden email]
>>  >>  >>>> For additional commands, e-mail: [hidden email]
>>  >>  >>>>
>>  >>  >>>
>>  >>  >>>
>> ---------------------------------------------------------------------
>>  >>  >>> To unsubscribe, e-mail: [hidden email]
>>  >>  >>> For additional commands, e-mail: [hidden email]
>>  >>  >>>
>>  >>  >>
>>  >>  >
>> ---------------------------------------------------------------------
>>  >>  > To unsubscribe, e-mail: [hidden email]
>>  >>  > For additional commands, e-mail: [hidden email]
>>  >>  >
>>  >>  >
>>  >>  >
>>  >>  > ________________________________
>>  >>  > View message @
>>  >>  >
>>  >>
>>  >>
>>
>> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3553859.html
>>  >>  > To unsubscribe from Iframe streaming with Jruby and Atmosphere,
>> click
>>  >> here.
>>  >>  >
>>  >>
>>  >>
>>  >>
>>  >> --
>>  >> S pozdravem, Regards
>>  >> Michal Hantl
>>  >>
>>  >> gtalk/jabber: [hidden email]
>>  >> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1
>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1>>
>>  >> icq: 241813215
>>  >>
>>  >>
>> ------------------------------------------------------------------------
>>  >> View this message in context: Re: Iframe streaming with Jruby and
>>  >> Atmosphere
>>  >>
>>  >>
>>
>> <http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3554785.html>
>>
>>  >> Sent from the Atmosphere users mailling list mailing list archive
>>  >> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
>>  >> Nabble.com.
>>  > ---------------------------------------------------------------------
>>  > To unsubscribe, e-mail: [hidden email]
>>  > For additional commands, e-mail: [hidden email]
>>  >
>>  >
>>  >
>>  > ________________________________
>>  > View message @
>>  >
>>
>> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555505.html
>>  > To unsubscribe from Iframe streaming with Jruby and Atmosphere, click
>> here.
>>  >
>>
>>
>>
>> --
>> S pozdravem, Regards
>> Michal Hantl
>>
>> gtalk/jabber: [hidden email]
>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3555776&i=1>
>> icq: 241813215
>>
>> ------------------------------------------------------------------------
>> View this message in context: Re: Iframe streaming with Jruby and
>> Atmosphere
>>
>> <http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555776.html>
>> Sent from the Atmosphere users mailling list mailing list archive
>> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
>> Nabble.com.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
> ________________________________
> View message @
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555881.html
> To unsubscribe from Iframe streaming with Jruby and Atmosphere, click here.
>



--
S pozdravem, Regards
Michal Hantl

gtalk/jabber: [hidden email]
icq: 241813215
Michal Hantl

Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
So in order to run under linux you need to replace few lines in the
atmosphere.rb

the file will then start with lines:

require 'java'

root = File.dirname(__FILE__)+'/../' #set the root dir and use it

Dir[root+"/Java/jetty/*.jar"].each { |jar| require jar }
Dir[root+"/Java/jsdk/*.jar"].each { |jar| require jar }
Dir[root+"/Java/atmosphere/*.jar"].each { |jar| require jar }

After that it runs on my portable ubuntu and i see the exception we
talked about.

2009/8/31 Michal Hantl (via Nabble) <[hidden email]>:

> 2009/8/31 Jeanfrancois Arcand (via Nabble)
> <[hidden email]>:
>> Salut,
>>
>> Michal Hantl wrote:
>>> 2009/8/31 Jeanfrancois Arcand (via Nabble)
>>> <[hidden email]
>>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3555776&i=0>>:
>>>  > Salut,
>>>  >
>>>  > Michal Hantl wrote:
>>>  >> Hi,
>>>  >>  I didnt attach the error because it stayed the same.
>>>  >
>>>  > Same line? I was under the impression the new jar will changes that.
>>>
>>> Seems exactly the same:
>>>
>>> HTTP ERROR 500
>>>
>>> Problem accessing /. Reason:
>>>
>>>     INTERNAL_SERVER_ERROR
>>> Caused by:
>>>
>>> java.lang.NullPointerException
>>>         at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown
>>> Source)
>>>         at
>>> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>>>         at
>>>
>>>
>>> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>>>
>>>         at
>>>
>>>
>>> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>>>
>>>         at
>>>
>>>
>>> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>>>
>>>         at
>>>
>>>
>>> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>>>
>>>         at
>>>
>>>
>>> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:665)
>>>
>>>         at
>>> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:650)
>>>         at
>>> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:637)
>>>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>>>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>>         at
>>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>>>         at
>>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>>>         at
>>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>>         at
>>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>>         at
>>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>>         at org.mortbay.jetty.Server.handle(Server.java:324)
>>>         at
>>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>>>         at
>>>
>>>
>>> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>>>
>>>         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>>>         at
>>> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>>         at
>>> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>>         at
>>>
>>>
>>> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>>>
>>>         at
>>>
>>>
>>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>>>
>>>
>> Thanks
>>
>>>
>>>
>>>  >
>>>  >>
>>>  >> Does my rar show you the same error?
>>>  >
>>>  > Actually I haven't figured yet how to start it. I looked at
>>>  > atmosphere.bat but I'm getting some errors. What is the easiest way to
>>>  > reproduce it?
>>>
>>> Yes, atmosphere.bat should start it. Jruby and all other jars are
>>> included so it should just work.
>> It complains about:
>>
>>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$ java
>>> -jar jruby.jar atmosphere.rb
>>> (eval):1:in `include_class': cannot load Java class
>>> javax.servlet.http.HttpServlet (NameError)
>>
>> I did try:
>>
>>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$ java
>>> -cp /. -jar jruby.jar atmosphere.rb
>>> (eval):1:in `include_class': cannot load Java class
>>> javax.servlet.http.HttpServlet (NameError)
>>
>>
>> or
>>
>>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$ java
>>> -cp servlet-api.jar -jar jruby.jar atmosphere.rb
>>> (eval):1:in `include_class': cannot load Java class
>>> javax.servlet.http.HttpServlet (NameError)
> This means he was not able to load the jar and now when importing, it
> doesnt have the source for that class.
>
> Must be some kind of difference between discovering paths on ubuntu.
> Will install portable ubuntu and try.
>
>>
>> or
>>
>>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$ java
>>> -cp *.jar -jar jruby.jar atmosphere.rb
>>
>>
>> What is the exact command line you are running? I'm under Ubuntu (but
>> will gives a try using XP).
>
> I just run atmosphere.bat.
>
>>
>> A+
>>
>> -- jeanfrancois
>>
>>
>>>
>>> Are you using windows? I am running XP, not sure if that can be a
>>> problem.. I havent tested it under linux (none installed right now).
>>>
>>> What error are you getting? I will look into the jar to see where are
>>> the lines of the problem, maybe i can google something.
>>>
>>>
>>>
>>>
>>>
>>>  >
>>>  > Thanks
>>>  >
>>>  > -- Jeanfarncois
>>>  >
>>>  >>
>>>  >> 2009/8/31 Jeanfrancois Arcand (via Nabble)
>>>  >> <[hidden email]
>>>  >> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0
>>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0>>>:
>>>  >>
>>>  >>  > Salut,
>>>  >>  >
>>>  >>  > Michal Hantl wrote:
>>>  >>  >> Thanks for sending a patch so quickly!
>>>  >>  >>
>>>  >>  >> (And sorry for delayed reply, I wasn't home till now.)
>>>  >>  >>
>>>  >>  >> I tried the patched version, but same error occurs.
>>>  >>  >>
>>>  >>  >> Here is the full project, so you dont have to re-create:
>>>  >>  >> http://d.hantl.cz/jruby_atmosphere.rar
>>>  >>  >>
>>>  >>  >> (Might be something I did wrong, since I am pretty new to this.)
>>>  >>  > Can you cut & past the error? I'm installing your project as well.
>>>  >>  >
>>>  >>  > Thanks
>>>  >>  >
>>>  >>  > -- Jeanfrancois
>>>  >>  >
>>>  >>  >
>>>  >>  >>
>>>  >>  >> Thanks!
>>>  >>  >>
>>>  >>  >>
>>>  >>  >>
>>>  >>  >> Jeanfrancois Arcand wrote:
>>>  >>  >>> Salut,
>>>  >>  >>>
>>>  >>  >>> Jeanfrancois Arcand wrote:
>>>  >>  >>>> Salut,
>>>  >>  >>>>
>>>  >>  >>>> let me try to reproduce locally. Thanks for sharing!
>>>  >>  >>> It seems loading a class using Class.forName doesn't work we
>>> ran in
>>>  >>  >>> JRuby. I'm attaching a patch to see if that will fix your
>>> issues. I'm
>>>  >>  >>> build the patch agains 0.3.1, so just replace the
>>>  >>  >>> atmosphere-portable-runtime.jar file.
>>>  >>  >>>
>>>  >>  >>> Let me know the result!
>>>  >>  >>>
>>>  >>  >>> A+
>>>  >>  >>>
>>>  >>  >>> --Jeanfrancois
>>>  >>  >>>
>>>  >>  >>>> Stay tuned!
>>>  >>  >>>>
>>>  >>  >>>> -- Jeanfrancois
>>>  >>  >>>>
>>>  >>  >>>> Michal Hantl wrote:
>>>  >>  >>>>> Here is a report on my progress.
>>>  >>  >>>>>
>>>  >>  >>>>> I got the jetty demo running, then i added atmosphere and
>>> changed
>>>  >> the
>>>  >>  >>>>> source.
>>>  >>  >>>>>
>>>  >>  >>>>> It complained about session so i changed
>>>  >>  >>>>> And now i get this:
>>>  >>  >>>>> (so far no idea what to do with it, but still googling)
>>>  >>  >>>>>
>>>  >>  >>>>> Problem accessing /. Reason:
>>>  >>  >>>>>
>>>  >>  >>>>>     INTERNAL_SERVER_ERROR
>>>  >>  >>>>> Caused by:
>>>  >>  >>>>>
>>>  >>  >>>>> java.lang.NullPointerException
>>>  >>  >>>>>     at
>>> java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown
>>>  >> Source)
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>
>>>  >>
>>>
>>>
>>> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>>>
>>>  >>
>>>  >>  >>>>>
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>
>>>  >>
>>>
>>>
>>> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>>>
>>>  >>
>>>  >>  >>>>>
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>
>>>  >>
>>>
>>>
>>> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>>>
>>>  >>
>>>  >>  >>>>>
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>
>>>  >>
>>>
>>>
>>> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>>>
>>>  >>
>>>  >>  >>>>>
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>
>>>  >>
>>>
>>>
>>> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:662)
>>>
>>>  >>
>>>  >>  >>>>>
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>
>>> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:647)
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>
>>> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:634)
>>>  >>  >>>>>     at
>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>>>  >>  >>>>>     at
>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>
>>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>
>>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>
>>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>
>>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>
>>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>>  >>  >>>>>     at org.mortbay.jetty.Server.handle(Server.java:324)
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>
>>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>
>>>  >>
>>>
>>>
>>> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>>>
>>>  >>
>>>  >>  >>>>>
>>>  >>  >>>>>     at
>>> org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>>>  >>  >>>>>     at
>>>  >> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>>  >>  >>>>>     at
>>>  >> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>
>>>  >>
>>>
>>>
>>> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>>>
>>>  >>
>>>  >>  >>>>>
>>>  >>  >>>>>     at
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>
>>>  >>
>>>
>>>
>>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>>>
>>>  >>
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>  >>>>> the source code of my attempt:
>>>  >>  >>>>>
>>>  >>  >>>>> require 'java'
>>>  >>  >>>>>
>>>  >>  >>>>> Dir["./Java/jetty/*.jar"].each { |jar| require jar }
>>>  >>  >>>>> Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
>>>  >>  >>>>> Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
>>>  >>  >>>>> Dir["./Java/apache/*.jar"].each { |jar| require jar }
>>>  >>  >>>>>
>>>  >>  >>>>> include_class 'javax.servlet.http.HttpServlet'
>>>  >>  >>>>> include_class 'org.mortbay.jetty.Server'
>>>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.Context'
>>>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>>>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>>>  >>  >>>>> include_class 'org.atmosphere.cpr.AtmosphereHandler'
>>>  >>  >>>>> include_class 'org.atmosphere.cpr.AtmosphereServlet'
>>>  >>  >>>>> include_class 'org.apache.catalina.CometProcessor'
>>>  >>  >>>>>
>>>  >>  >>>>> def main
>>>  >>  >>>>>   server = Server.new(8080)
>>>  >>  >>>>>   #context = Context.new(server, '/', 0)
>>>  >>  >>>>>   context = Context.new(server, '/', Context::SESSIONS)
>>>  >>  >>>>>
>>>  >>  >>>>>   servlet = AtmosphereServlet.new()
>>>  >>  >>>>>   servlet.addAtmosphereHandler("/", MyRubyHandler.new())
>>>  >>  >>>>>     holder = ServletHolder.new(servlet)
>>>  >>  >>>>>   context.addServlet(holder, '/')
>>>  >>  >>>>>     server.start()
>>>  >>  >>>>> end
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>  >>>>> class MyRubyHandler
>>>  >>  >>>>>   include AtmosphereHandler
>>>  >>  >>>>>
>>>  >>  >>>>>   BEGIN_SCRIPT_TAG = '<script>'
>>>  >>  >>>>>   END_SCRIPT_TAG = '</script>'
>>>  >>  >>>>>
>>>  >>  >>>>>   def onEvent(event)
>>>  >>  >>>>>         req = event.getRequest();
>>>  >>  >>>>>         res = event.getResponse();
>>>  >>  >>>>>
>>>  >>  >>>>>         res.setContentType("text/html")
>>>  >>  >>>>>         res.addHeader("Cache-Control", "private")
>>>  >>  >>>>>         res.addHeader("Pragma", "no-cache")
>>>  >>  >>>>>         res.getWriter().write("<html><body><h1>It
>>>  >>  >>>>> works!</h1></body></html>\n");
>>>  >>  >>>>>         res.getWriter().flush();
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>  >>>>> #        if (req.getMethod().equalsIgnoreCase("GET"))
>>>  >>  >>>>> #            # for IE
>>>  >>  >>>>> #            res.getWriter().write("<!-- Comet is a
>>> programming
>>>  >>  >>>>> technique
>>>  >>  >>>>> that enables web " +
>>>  >>  >>>>> #                    "servers to send data to the client
>>> without
>>>  >>  >>>>> having any
>>>  >>  >>>>> need " +
>>>  >>  >>>>> #                    "for the client to request it. -->\n");
>>>  >>  >>>>> #            res.getWriter().flush();
>>>  >>  >>>>> #
>>>  >>  >>>>> #            #
>>>  >>  >>>>> #            # Mark this connection as suspended.
>>>  >>  >>>>> #            #
>>>  >>  >>>>> #            event.suspend();
>>>  >>  >>>>> #        elsif (req.getMethod().equalsIgnoreCase("POST"))
>>>  >>  >>>>> #            res.setCharacterEncoding("UTF-8");
>>>  >>  >>>>> #            String action =
>>> req.getParameterValues("action")[0];
>>>  >>  >>>>> #            String name = req.getParameterValues("name")[0];
>>>  >>  >>>>> #
>>>  >>  >>>>> #            if "login".equals(action)
>>>  >>  >>>>> #                event.getBroadcaster().broadcast(
>>>  >>  >>>>> #                  BEGIN_SCRIPT_TAG +
>>>  >>  >>>>> #                    toJsonp("System Message from " +
>>>  >>  >>>>> event.getWebServerName(),
>>>  >>  >>>>> #                      name + " has joined.") +
>>>  >>  >>>>> #                  END_SCRIPT_TAG);
>>>  >>  >>>>> #
>>>  >>  >>>>> #                res.getWriter().write("success");
>>>  >>  >>>>> #                res.getWriter().flush();
>>>  >>  >>>>> #            elsif ("post".equals(action))
>>>  >>  >>>>> #                message =
>>> req.getParameterValues("message")[0];
>>>  >>  >>>>> #                event.getBroadcaster().broadcast(
>>>  >>  >>>>> #                  BEGIN_SCRIPT_TAG + toJsonp(name, message) +
>>>  >>  >>>>> END_SCRIPT_TAG);
>>>  >>  >>>>> #                res.getWriter().write("success");
>>>  >>  >>>>> #                res.getWriter().flush();
>>>  >>  >>>>> #            else
>>>  >>  >>>>> #                res.setStatus(422);
>>>  >>  >>>>> #
>>>  >>  >>>>> #                res.getWriter().write("success");
>>>  >>  >>>>> #                res.getWriter().flush();
>>>  >>  >>>>> #            end
>>>  >>  >>>>> #        end
>>>  >>  >>>>>         return event;
>>>  >>  >>>>>     end
>>>  >>  >>>>>
>>>  >>  >>>>>     def onMessage(event)
>>>  >>  >>>>>         req = event.getRequest();
>>>  >>  >>>>>         res = event.getResponse();
>>>  >>  >>>>>
>>>  >>  >>>>>         if (event.isResuming() || event.isResumedOnTimedout())
>>>  >>  >>>>>             script = BEGIN_SCRIPT_TAG +
>>>  >> "window.parent.app.listen();\n"
>>>  >>  >>>>> +
>>>  >>  >>>>> END_SCRIPT_TAG;
>>>  >>  >>>>>             res.getWriter().write(script);
>>>  >>  >>>>>             res.getWriter().flush();
>>>  >>  >>>>>         else
>>>  >>  >>>>>
>>> res.getWriter().write(event.getMessage().toString());
>>>  >>  >>>>>             res.getWriter().flush();
>>>  >>  >>>>>         end
>>>  >>  >>>>>         return event;
>>>  >>  >>>>>     end
>>>  >>  >>>>> end
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>  >>>>> main
>>>  >>  >>>>>
>>>  >>  >>>>> --end of ruby source--
>>>  >>  >>>>>
>>>  >>  >>>>>
>>>  >>  >>>>> Thank you very much for support.
>>>  >>  >>>>>
>>>  >>  >>>>
>>>  >> ---------------------------------------------------------------------
>>>  >>  >>>> To unsubscribe, e-mail: [hidden email]
>>>  >>  >>>> For additional commands, e-mail: [hidden email]
>>>  >>  >>>>
>>>  >>  >>>
>>>  >>  >>>
>>> ---------------------------------------------------------------------
>>>  >>  >>> To unsubscribe, e-mail: [hidden email]
>>>  >>  >>> For additional commands, e-mail: [hidden email]
>>>  >>  >>>
>>>  >>  >>
>>>  >>  >
>>> ---------------------------------------------------------------------
>>>  >>  > To unsubscribe, e-mail: [hidden email]
>>>  >>  > For additional commands, e-mail: [hidden email]
>>>  >>  >
>>>  >>  >
>>>  >>  >
>>>  >>  > ________________________________
>>>  >>  > View message @
>>>  >>  >
>>>  >>
>>>  >>
>>>
>>>
>>> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3553859.html
>>>  >>  > To unsubscribe from Iframe streaming with Jruby and Atmosphere,
>>> click
>>>  >> here.
>>>  >>  >
>>>  >>
>>>  >>
>>>  >>
>>>  >> --
>>>  >> S pozdravem, Regards
>>>  >> Michal Hantl
>>>  >>
>>>  >> gtalk/jabber: [hidden email]
>>>  >> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1
>>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1>>
>>>  >> icq: 241813215
>>>  >>
>>>  >>
>>> ------------------------------------------------------------------------
>>>  >> View this message in context: Re: Iframe streaming with Jruby and
>>>  >> Atmosphere
>>>  >>
>>>  >>
>>>
>>>
>>> <http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3554785.html>
>>>
>>>  >> Sent from the Atmosphere users mailling list mailing list archive
>>>  >> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html>
>>> at
>>>  >> Nabble.com.
>>>  > ---------------------------------------------------------------------
>>>  > To unsubscribe, e-mail: [hidden email]
>>>  > For additional commands, e-mail: [hidden email]
>>>  >
>>>  >
>>>  >
>>>  > ________________________________
>>>  > View message @
>>>  >
>>>
>>>
>>> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555505.html
>>>  > To unsubscribe from Iframe streaming with Jruby and Atmosphere, click
>>> here.
>>>  >
>>>
>>>
>>>
>>> --
>>> S pozdravem, Regards
>>> Michal Hantl
>>>
>>> gtalk/jabber: [hidden email]
>>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3555776&i=1>
>>> icq: 241813215
>>>
>>> ------------------------------------------------------------------------
>>> View this message in context: Re: Iframe streaming with Jruby and
>>> Atmosphere
>>>
>>>
>>> <http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555776.html>
>>> Sent from the Atmosphere users mailling list mailing list archive
>>> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
>>> Nabble.com.
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>
>> ________________________________
>> View message @
>>
>> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555881.html
>> To unsubscribe from Iframe streaming with Jruby and Atmosphere, click
>> here.
>>
>
>
> --
> S pozdravem, Regards
> Michal Hantl
>
> gtalk/jabber: [hidden email]
> icq: 241813215
>
>
> ________________________________
> View message @
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3556202.html
> To unsubscribe from Iframe streaming with Jruby and Atmosphere, click here.
>



--
S pozdravem, Regards
Michal Hantl

gtalk/jabber: [hidden email]
icq: 241813215
Jeanfrancois Arcand

(fixed) Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
Salut,

shame on me the error was ridiculous. This is now fixed with
0.4-SNAPSHOT. Apology for the delay...took me more time learning Jruby
than fixing the issue.

Do you need an official release? If yes, let me know I will cut 0.3.2.

A+

-Jeanfrancois

Michal Hantl wrote:

> So in order to run under linux you need to replace few lines in the
> atmosphere.rb
>
> the file will then start with lines:
>
> require 'java'
>
> root = File.dirname(__FILE__)+'/../' #set the root dir and use it
>
> Dir[root+"/Java/jetty/*.jar"].each { |jar| require jar }
> Dir[root+"/Java/jsdk/*.jar"].each { |jar| require jar }
> Dir[root+"/Java/atmosphere/*.jar"].each { |jar| require jar }
>
> After that it runs on my portable ubuntu and i see the exception we
> talked about.
>
> 2009/8/31 Michal Hantl (via Nabble) <[hidden email]
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3558520&i=0>>:
>
>  > 2009/8/31 Jeanfrancois Arcand (via Nabble)
>  > <[hidden email]>:
>  >> Salut,
>  >>
>  >> Michal Hantl wrote:
>  >>> 2009/8/31 Jeanfrancois Arcand (via Nabble)
>  >>> <[hidden email]
>  >>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3555776&i=0 
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3555776&i=0>>>:
>  >>>  > Salut,
>  >>>  >
>  >>>  > Michal Hantl wrote:
>  >>>  >> Hi,
>  >>>  >>  I didnt attach the error because it stayed the same.
>  >>>  >
>  >>>  > Same line? I was under the impression the new jar will changes
> that.
>  >>>
>  >>> Seems exactly the same:
>  >>>
>  >>> HTTP ERROR 500
>  >>>
>  >>> Problem accessing /. Reason:
>  >>>
>  >>>     INTERNAL_SERVER_ERROR
>  >>> Caused by:
>  >>>
>  >>> java.lang.NullPointerException
>  >>>         at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown
>  >>> Source)
>  >>>         at
>  >>> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>
>  >>>
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>
>  >>>
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>
>  >>>
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>
>  >>>
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:665)
>
>  >>>
>  >>>         at
>  >>>
> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:650)
>  >>>         at
>  >>> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:637)
>  >>>         at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>  >>>         at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>  >>>         at
>  >>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>  >>>         at
>  >>>
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>  >>>         at
>  >>>
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>  >>>         at
>  >>>
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>  >>>         at
>  >>>
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>  >>>         at org.mortbay.jetty.Server.handle(Server.java:324)
>  >>>         at
>  >>>
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>
>  >>>
>  >>>         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>  >>>         at
>  >>> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>  >>>         at
>  >>> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>
>  >>>
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>
>  >>>
>  >>>
>  >> Thanks
>  >>
>  >>>
>  >>>
>  >>>  >
>  >>>  >>
>  >>>  >> Does my rar show you the same error?
>  >>>  >
>  >>>  > Actually I haven't figured yet how to start it. I looked at
>  >>>  > atmosphere.bat but I'm getting some errors. What is the easiest
> way to
>  >>>  > reproduce it?
>  >>>
>  >>> Yes, atmosphere.bat should start it. Jruby and all other jars are
>  >>> included so it should just work.
>  >> It complains about:
>  >>
>  >>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$
> java
>  >>> -jar jruby.jar atmosphere.rb
>  >>> (eval):1:in `include_class': cannot load Java class
>  >>> javax.servlet.http.HttpServlet (NameError)
>  >>
>  >> I did try:
>  >>
>  >>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$
> java
>  >>> -cp /. -jar jruby.jar atmosphere.rb
>  >>> (eval):1:in `include_class': cannot load Java class
>  >>> javax.servlet.http.HttpServlet (NameError)
>  >>
>  >>
>  >> or
>  >>
>  >>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$
> java
>  >>> -cp servlet-api.jar -jar jruby.jar atmosphere.rb
>  >>> (eval):1:in `include_class': cannot load Java class
>  >>> javax.servlet.http.HttpServlet (NameError)
>  > This means he was not able to load the jar and now when importing, it
>  > doesnt have the source for that class.
>  >
>  > Must be some kind of difference between discovering paths on ubuntu.
>  > Will install portable ubuntu and try.
>  >
>  >>
>  >> or
>  >>
>  >>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$
> java
>  >>> -cp *.jar -jar jruby.jar atmosphere.rb
>  >>
>  >>
>  >> What is the exact command line you are running? I'm under Ubuntu (but
>  >> will gives a try using XP).
>  >
>  > I just run atmosphere.bat.
>  >
>  >>
>  >> A+
>  >>
>  >> -- jeanfrancois
>  >>
>  >>
>  >>>
>  >>> Are you using windows? I am running XP, not sure if that can be a
>  >>> problem.. I havent tested it under linux (none installed right now).
>  >>>
>  >>> What error are you getting? I will look into the jar to see where are
>  >>> the lines of the problem, maybe i can google something.
>  >>>
>  >>>
>  >>>
>  >>>
>  >>>
>  >>>  >
>  >>>  > Thanks
>  >>>  >
>  >>>  > -- Jeanfarncois
>  >>>  >
>  >>>  >>
>  >>>  >> 2009/8/31 Jeanfrancois Arcand (via Nabble)
>  >>>  >> <[hidden email]
>  >>>  >>
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0 
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0>
>  >>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0 
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0>>>>:
>  >>>  >>
>  >>>  >>  > Salut,
>  >>>  >>  >
>  >>>  >>  > Michal Hantl wrote:
>  >>>  >>  >> Thanks for sending a patch so quickly!
>  >>>  >>  >>
>  >>>  >>  >> (And sorry for delayed reply, I wasn't home till now.)
>  >>>  >>  >>
>  >>>  >>  >> I tried the patched version, but same error occurs.
>  >>>  >>  >>
>  >>>  >>  >> Here is the full project, so you dont have to re-create:
>  >>>  >>  >> http://d.hantl.cz/jruby_atmosphere.rar
>  >>>  >>  >>
>  >>>  >>  >> (Might be something I did wrong, since I am pretty new to
> this.)
>  >>>  >>  > Can you cut & past the error? I'm installing your project as
> well.
>  >>>  >>  >
>  >>>  >>  > Thanks
>  >>>  >>  >
>  >>>  >>  > -- Jeanfrancois
>  >>>  >>  >
>  >>>  >>  >
>  >>>  >>  >>
>  >>>  >>  >> Thanks!
>  >>>  >>  >>
>  >>>  >>  >>
>  >>>  >>  >>
>  >>>  >>  >> Jeanfrancois Arcand wrote:
>  >>>  >>  >>> Salut,
>  >>>  >>  >>>
>  >>>  >>  >>> Jeanfrancois Arcand wrote:
>  >>>  >>  >>>> Salut,
>  >>>  >>  >>>>
>  >>>  >>  >>>> let me try to reproduce locally. Thanks for sharing!
>  >>>  >>  >>> It seems loading a class using Class.forName doesn't work we
>  >>> ran in
>  >>>  >>  >>> JRuby. I'm attaching a patch to see if that will fix your
>  >>> issues. I'm
>  >>>  >>  >>> build the patch agains 0.3.1, so just replace the
>  >>>  >>  >>> atmosphere-portable-runtime.jar file.
>  >>>  >>  >>>
>  >>>  >>  >>> Let me know the result!
>  >>>  >>  >>>
>  >>>  >>  >>> A+
>  >>>  >>  >>>
>  >>>  >>  >>> --Jeanfrancois
>  >>>  >>  >>>
>  >>>  >>  >>>> Stay tuned!
>  >>>  >>  >>>>
>  >>>  >>  >>>> -- Jeanfrancois
>  >>>  >>  >>>>
>  >>>  >>  >>>> Michal Hantl wrote:
>  >>>  >>  >>>>> Here is a report on my progress.
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> I got the jetty demo running, then i added atmosphere and
>  >>> changed
>  >>>  >> the
>  >>>  >>  >>>>> source.
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> It complained about session so i changed
>  >>>  >>  >>>>> And now i get this:
>  >>>  >>  >>>>> (so far no idea what to do with it, but still googling)
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> Problem accessing /. Reason:
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     INTERNAL_SERVER_ERROR
>  >>>  >>  >>>>> Caused by:
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> java.lang.NullPointerException
>  >>>  >>  >>>>>     at
>  >>> java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown
>  >>>  >> Source)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>
> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:662)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>
> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:647)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>
>  >>> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:634)
>  >>>  >>  >>>>>     at
>  >>> javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>  >>>  >>  >>>>>     at
>  >>> javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>
>  >>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>  >>>  >>  >>>>>     at org.mortbay.jetty.Server.handle(Server.java:324)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     at
>  >>> org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>  >>>  >>  >>>>>     at
>  >>>  >> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>  >>>  >>  >>>>>     at
>  >>>  >> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> the source code of my attempt:
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> require 'java'
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> Dir["./Java/jetty/*.jar"].each { |jar| require jar }
>  >>>  >>  >>>>> Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
>  >>>  >>  >>>>> Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
>  >>>  >>  >>>>> Dir["./Java/apache/*.jar"].each { |jar| require jar }
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> include_class 'javax.servlet.http.HttpServlet'
>  >>>  >>  >>>>> include_class 'org.mortbay.jetty.Server'
>  >>>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.Context'
>  >>>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>  >>>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>  >>>  >>  >>>>> include_class 'org.atmosphere.cpr.AtmosphereHandler'
>  >>>  >>  >>>>> include_class 'org.atmosphere.cpr.AtmosphereServlet'
>  >>>  >>  >>>>> include_class 'org.apache.catalina.CometProcessor'
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> def main
>  >>>  >>  >>>>>   server = Server.new(8080)
>  >>>  >>  >>>>>   #context = Context.new(server, '/', 0)
>  >>>  >>  >>>>>   context = Context.new(server, '/', Context::SESSIONS)
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>   servlet = AtmosphereServlet.new()
>  >>>  >>  >>>>>   servlet.addAtmosphereHandler("/", MyRubyHandler.new())
>  >>>  >>  >>>>>     holder = ServletHolder.new(servlet)
>  >>>  >>  >>>>>   context.addServlet(holder, '/')
>  >>>  >>  >>>>>     server.start()
>  >>>  >>  >>>>> end
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> class MyRubyHandler
>  >>>  >>  >>>>>   include AtmosphereHandler
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>   BEGIN_SCRIPT_TAG = '<script>'
>  >>>  >>  >>>>>   END_SCRIPT_TAG = '</script>'
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>   def onEvent(event)
>  >>>  >>  >>>>>         req = event.getRequest();
>  >>>  >>  >>>>>         res = event.getResponse();
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>         res.setContentType("text/html")
>  >>>  >>  >>>>>         res.addHeader("Cache-Control", "private")
>  >>>  >>  >>>>>         res.addHeader("Pragma", "no-cache")
>  >>>  >>  >>>>>         res.getWriter().write("<html><body><h1>It
>  >>>  >>  >>>>> works!</h1></body></html>\n");
>  >>>  >>  >>>>>         res.getWriter().flush();
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> #        if (req.getMethod().equalsIgnoreCase("GET"))
>  >>>  >>  >>>>> #            # for IE
>  >>>  >>  >>>>> #            res.getWriter().write("<!-- Comet is a
>  >>> programming
>  >>>  >>  >>>>> technique
>  >>>  >>  >>>>> that enables web " +
>  >>>  >>  >>>>> #                    "servers to send data to the client
>  >>> without
>  >>>  >>  >>>>> having any
>  >>>  >>  >>>>> need " +
>  >>>  >>  >>>>> #                    "for the client to request it.
> -->\n");
>  >>>  >>  >>>>> #            res.getWriter().flush();
>  >>>  >>  >>>>> #
>  >>>  >>  >>>>> #            #
>  >>>  >>  >>>>> #            # Mark this connection as suspended.
>  >>>  >>  >>>>> #            #
>  >>>  >>  >>>>> #            event.suspend();
>  >>>  >>  >>>>> #        elsif (req.getMethod().equalsIgnoreCase("POST"))
>  >>>  >>  >>>>> #            res.setCharacterEncoding("UTF-8");
>  >>>  >>  >>>>> #            String action =
>  >>> req.getParameterValues("action")[0];
>  >>>  >>  >>>>> #            String name =
> req.getParameterValues("name")[0];
>  >>>  >>  >>>>> #
>  >>>  >>  >>>>> #            if "login".equals(action)
>  >>>  >>  >>>>> #                event.getBroadcaster().broadcast(
>  >>>  >>  >>>>> #                  BEGIN_SCRIPT_TAG +
>  >>>  >>  >>>>> #                    toJsonp("System Message from " +
>  >>>  >>  >>>>> event.getWebServerName(),
>  >>>  >>  >>>>> #                      name + " has joined.") +
>  >>>  >>  >>>>> #                  END_SCRIPT_TAG);
>  >>>  >>  >>>>> #
>  >>>  >>  >>>>> #                res.getWriter().write("success");
>  >>>  >>  >>>>> #                res.getWriter().flush();
>  >>>  >>  >>>>> #            elsif ("post".equals(action))
>  >>>  >>  >>>>> #                message =
>  >>> req.getParameterValues("message")[0];
>  >>>  >>  >>>>> #                event.getBroadcaster().broadcast(
>  >>>  >>  >>>>> #                  BEGIN_SCRIPT_TAG + toJsonp(name,
> message) +
>  >>>  >>  >>>>> END_SCRIPT_TAG);
>  >>>  >>  >>>>> #                res.getWriter().write("success");
>  >>>  >>  >>>>> #                res.getWriter().flush();
>  >>>  >>  >>>>> #            else
>  >>>  >>  >>>>> #                res.setStatus(422);
>  >>>  >>  >>>>> #
>  >>>  >>  >>>>> #                res.getWriter().write("success");
>  >>>  >>  >>>>> #                res.getWriter().flush();
>  >>>  >>  >>>>> #            end
>  >>>  >>  >>>>> #        end
>  >>>  >>  >>>>>         return event;
>  >>>  >>  >>>>>     end
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     def onMessage(event)
>  >>>  >>  >>>>>         req = event.getRequest();
>  >>>  >>  >>>>>         res = event.getResponse();
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>         if (event.isResuming() ||
> event.isResumedOnTimedout())
>  >>>  >>  >>>>>             script = BEGIN_SCRIPT_TAG +
>  >>>  >> "window.parent.app.listen();\n"
>  >>>  >>  >>>>> +
>  >>>  >>  >>>>> END_SCRIPT_TAG;
>  >>>  >>  >>>>>             res.getWriter().write(script);
>  >>>  >>  >>>>>             res.getWriter().flush();
>  >>>  >>  >>>>>         else
>  >>>  >>  >>>>>
>  >>> res.getWriter().write(event.getMessage().toString());
>  >>>  >>  >>>>>             res.getWriter().flush();
>  >>>  >>  >>>>>         end
>  >>>  >>  >>>>>         return event;
>  >>>  >>  >>>>>     end
>  >>>  >>  >>>>> end
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> main
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> --end of ruby source--
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> Thank you very much for support.
>  >>>  >>  >>>>>
>  >>>  >>  >>>>
>  >>>  >>
> ---------------------------------------------------------------------
>  >>>  >>  >>>> To unsubscribe, e-mail: [hidden email]
>  >>>  >>  >>>> For additional commands, e-mail: [hidden email]
>  >>>  >>  >>>>
>  >>>  >>  >>>
>  >>>  >>  >>>
>  >>> ---------------------------------------------------------------------
>  >>>  >>  >>> To unsubscribe, e-mail: [hidden email]
>  >>>  >>  >>> For additional commands, e-mail: [hidden email]
>  >>>  >>  >>>
>  >>>  >>  >>
>  >>>  >>  >
>  >>> ---------------------------------------------------------------------
>  >>>  >>  > To unsubscribe, e-mail: [hidden email]
>  >>>  >>  > For additional commands, e-mail: [hidden email]
>  >>>  >>  >
>  >>>  >>  >
>  >>>  >>  >
>  >>>  >>  > ________________________________
>  >>>  >>  > View message @
>  >>>  >>  >
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3553859.html
>  >>>  >>  > To unsubscribe from Iframe streaming with Jruby and Atmosphere,
>  >>> click
>  >>>  >> here.
>  >>>  >>  >
>  >>>  >>
>  >>>  >>
>  >>>  >>
>  >>>  >> --
>  >>>  >> S pozdravem, Regards
>  >>>  >> Michal Hantl
>  >>>  >>
>  >>>  >> gtalk/jabber: [hidden email]
>  >>>  >>
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1 
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1>
>  >>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1 
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1>>>
>  >>>  >> icq: 241813215
>  >>>  >>
>  >>>  >>
>  >>>
> ------------------------------------------------------------------------
>  >>>  >> View this message in context: Re: Iframe streaming with Jruby and
>  >>>  >> Atmosphere
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> <http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3554785.html>
>
>  >>>
>  >>>  >> Sent from the Atmosphere users mailling list mailing list archive
>  >>>  >>
> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html>
>  >>> at
>  >>>  >> Nabble.com.
>  >>>  >
> ---------------------------------------------------------------------
>  >>>  > To unsubscribe, e-mail: [hidden email]
>  >>>  > For additional commands, e-mail: [hidden email]
>  >>>  >
>  >>>  >
>  >>>  >
>  >>>  > ________________________________
>  >>>  > View message @
>  >>>  >
>  >>>
>  >>>
>  >>>
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555505.html
>  >>>  > To unsubscribe from Iframe streaming with Jruby and Atmosphere,
> click
>  >>> here.
>  >>>  >
>  >>>
>  >>>
>  >>>
>  >>> --
>  >>> S pozdravem, Regards
>  >>> Michal Hantl
>  >>>
>  >>> gtalk/jabber: [hidden email]
>  >>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3555776&i=1 
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3555776&i=1>>
>  >>> icq: 241813215
>  >>>
>  >>>
> ------------------------------------------------------------------------
>  >>> View this message in context: Re: Iframe streaming with Jruby and
>  >>> Atmosphere
>  >>>
>  >>>
>  >>>
> <http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555776.html>
>
>  >>> Sent from the Atmosphere users mailling list mailing list archive
>  >>> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
>  >>> Nabble.com.
>  >> ---------------------------------------------------------------------
>  >> To unsubscribe, e-mail: [hidden email]
>  >> For additional commands, e-mail: [hidden email]
>  >>
>  >>
>  >>
>  >> ________________________________
>  >> View message @
>  >>
>  >>
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555881.html
>  >> To unsubscribe from Iframe streaming with Jruby and Atmosphere, click
>  >> here.
>  >>
>  >
>  >
>  > --
>  > S pozdravem, Regards
>  > Michal Hantl
>  >
>  > gtalk/jabber: [hidden email]
>  > icq: 241813215
>  >
>  >
>  > ________________________________
>  > View message @
>  >
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3556202.html
>  > To unsubscribe from Iframe streaming with Jruby and Atmosphere, click
> here.
>  >
>
>
>
> --
> S pozdravem, Regards
> Michal Hantl
>
> gtalk/jabber: [hidden email]
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3558520&i=1>
> icq: 241813215
>
> ------------------------------------------------------------------------
> View this message in context: Re: Iframe streaming with Jruby and
> Atmosphere
> <http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3558520.html>
> Sent from the Atmosphere users mailling list mailing list archive
> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
> Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Michal Hantl

Re: (fixed) Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
Hello,
the snaphot works nicely, thank you very much!

I will do a little demo and post the source as well as the whole thing so other rubyists can enjoy too.

Jeanfrancois Arcand wrote:
Salut,

shame on me the error was ridiculous. This is now fixed with
0.4-SNAPSHOT. Apology for the delay...took me more time learning Jruby
than fixing the issue.

Do you need an official release? If yes, let me know I will cut 0.3.2.

A+

-Jeanfrancois

Michal Hantl wrote:
> So in order to run under linux you need to replace few lines in the
> atmosphere.rb
>
> the file will then start with lines:
>
> require 'java'
>
> root = File.dirname(__FILE__)+'/../' #set the root dir and use it
>
> Dir[root+"/Java/jetty/*.jar"].each { |jar| require jar }
> Dir[root+"/Java/jsdk/*.jar"].each { |jar| require jar }
> Dir[root+"/Java/atmosphere/*.jar"].each { |jar| require jar }
>
> After that it runs on my portable ubuntu and i see the exception we
> talked about.
>
> 2009/8/31 Michal Hantl (via Nabble) <[hidden email]
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3558520&i=0>>:
>
>  > 2009/8/31 Jeanfrancois Arcand (via Nabble)
>  > <[hidden email]>:
>  >> Salut,
>  >>
>  >> Michal Hantl wrote:
>  >>> 2009/8/31 Jeanfrancois Arcand (via Nabble)
>  >>> <[hidden email]
>  >>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3555776&i=0 
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3555776&i=0>>>:
>  >>>  > Salut,
>  >>>  >
>  >>>  > Michal Hantl wrote:
>  >>>  >> Hi,
>  >>>  >>  I didnt attach the error because it stayed the same.
>  >>>  >
>  >>>  > Same line? I was under the impression the new jar will changes
> that.
>  >>>
>  >>> Seems exactly the same:
>  >>>
>  >>> HTTP ERROR 500
>  >>>
>  >>> Problem accessing /. Reason:
>  >>>
>  >>>     INTERNAL_SERVER_ERROR
>  >>> Caused by:
>  >>>
>  >>> java.lang.NullPointerException
>  >>>         at java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown
>  >>> Source)
>  >>>         at
>  >>> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>
>  >>>
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>
>  >>>
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>
>  >>>
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>
>  >>>
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:665)
>
>  >>>
>  >>>         at
>  >>>
> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:650)
>  >>>         at
>  >>> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:637)
>  >>>         at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>  >>>         at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>  >>>         at
>  >>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>  >>>         at
>  >>>
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>  >>>         at
>  >>>
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>  >>>         at
>  >>>
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>  >>>         at
>  >>>
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>  >>>         at org.mortbay.jetty.Server.handle(Server.java:324)
>  >>>         at
>  >>>
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>
>  >>>
>  >>>         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>  >>>         at
>  >>> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>  >>>         at
>  >>> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>
>  >>>
>  >>>         at
>  >>>
>  >>>
>  >>>
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>
>  >>>
>  >>>
>  >> Thanks
>  >>
>  >>>
>  >>>
>  >>>  >
>  >>>  >>
>  >>>  >> Does my rar show you the same error?
>  >>>  >
>  >>>  > Actually I haven't figured yet how to start it. I looked at
>  >>>  > atmosphere.bat but I'm getting some errors. What is the easiest
> way to
>  >>>  > reproduce it?
>  >>>
>  >>> Yes, atmosphere.bat should start it. Jruby and all other jars are
>  >>> included so it should just work.
>  >> It complains about:
>  >>
>  >>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$
> java
>  >>> -jar jruby.jar atmosphere.rb
>  >>> (eval):1:in `include_class': cannot load Java class
>  >>> javax.servlet.http.HttpServlet (NameError)
>  >>
>  >> I did try:
>  >>
>  >>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$
> java
>  >>> -cp /. -jar jruby.jar atmosphere.rb
>  >>> (eval):1:in `include_class': cannot load Java class
>  >>> javax.servlet.http.HttpServlet (NameError)
>  >>
>  >>
>  >> or
>  >>
>  >>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$
> java
>  >>> -cp servlet-api.jar -jar jruby.jar atmosphere.rb
>  >>> (eval):1:in `include_class': cannot load Java class
>  >>> javax.servlet.http.HttpServlet (NameError)
>  > This means he was not able to load the jar and now when importing, it
>  > doesnt have the source for that class.
>  >
>  > Must be some kind of difference between discovering paths on ubuntu.
>  > Will install portable ubuntu and try.
>  >
>  >>
>  >> or
>  >>
>  >>> jfarcand@jfarcand-desktop:~/appserv80/atmosphere/jruby-integration$
> java
>  >>> -cp *.jar -jar jruby.jar atmosphere.rb
>  >>
>  >>
>  >> What is the exact command line you are running? I'm under Ubuntu (but
>  >> will gives a try using XP).
>  >
>  > I just run atmosphere.bat.
>  >
>  >>
>  >> A+
>  >>
>  >> -- jeanfrancois
>  >>
>  >>
>  >>>
>  >>> Are you using windows? I am running XP, not sure if that can be a
>  >>> problem.. I havent tested it under linux (none installed right now).
>  >>>
>  >>> What error are you getting? I will look into the jar to see where are
>  >>> the lines of the problem, maybe i can google something.
>  >>>
>  >>>
>  >>>
>  >>>
>  >>>
>  >>>  >
>  >>>  > Thanks
>  >>>  >
>  >>>  > -- Jeanfarncois
>  >>>  >
>  >>>  >>
>  >>>  >> 2009/8/31 Jeanfrancois Arcand (via Nabble)
>  >>>  >> <[hidden email]
>  >>>  >>
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0 
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0>
>  >>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0 
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=0>>>>:
>  >>>  >>
>  >>>  >>  > Salut,
>  >>>  >>  >
>  >>>  >>  > Michal Hantl wrote:
>  >>>  >>  >> Thanks for sending a patch so quickly!
>  >>>  >>  >>
>  >>>  >>  >> (And sorry for delayed reply, I wasn't home till now.)
>  >>>  >>  >>
>  >>>  >>  >> I tried the patched version, but same error occurs.
>  >>>  >>  >>
>  >>>  >>  >> Here is the full project, so you dont have to re-create:
>  >>>  >>  >> http://d.hantl.cz/jruby_atmosphere.rar
>  >>>  >>  >>
>  >>>  >>  >> (Might be something I did wrong, since I am pretty new to
> this.)
>  >>>  >>  > Can you cut & past the error? I'm installing your project as
> well.
>  >>>  >>  >
>  >>>  >>  > Thanks
>  >>>  >>  >
>  >>>  >>  > -- Jeanfrancois
>  >>>  >>  >
>  >>>  >>  >
>  >>>  >>  >>
>  >>>  >>  >> Thanks!
>  >>>  >>  >>
>  >>>  >>  >>
>  >>>  >>  >>
>  >>>  >>  >> Jeanfrancois Arcand wrote:
>  >>>  >>  >>> Salut,
>  >>>  >>  >>>
>  >>>  >>  >>> Jeanfrancois Arcand wrote:
>  >>>  >>  >>>> Salut,
>  >>>  >>  >>>>
>  >>>  >>  >>>> let me try to reproduce locally. Thanks for sharing!
>  >>>  >>  >>> It seems loading a class using Class.forName doesn't work we
>  >>> ran in
>  >>>  >>  >>> JRuby. I'm attaching a patch to see if that will fix your
>  >>> issues. I'm
>  >>>  >>  >>> build the patch agains 0.3.1, so just replace the
>  >>>  >>  >>> atmosphere-portable-runtime.jar file.
>  >>>  >>  >>>
>  >>>  >>  >>> Let me know the result!
>  >>>  >>  >>>
>  >>>  >>  >>> A+
>  >>>  >>  >>>
>  >>>  >>  >>> --Jeanfrancois
>  >>>  >>  >>>
>  >>>  >>  >>>> Stay tuned!
>  >>>  >>  >>>>
>  >>>  >>  >>>> -- Jeanfrancois
>  >>>  >>  >>>>
>  >>>  >>  >>>> Michal Hantl wrote:
>  >>>  >>  >>>>> Here is a report on my progress.
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> I got the jetty demo running, then i added atmosphere and
>  >>> changed
>  >>>  >> the
>  >>>  >>  >>>>> source.
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> It complained about session so i changed
>  >>>  >>  >>>>> And now i get this:
>  >>>  >>  >>>>> (so far no idea what to do with it, but still googling)
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> Problem accessing /. Reason:
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     INTERNAL_SERVER_ERROR
>  >>>  >>  >>>>> Caused by:
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> java.lang.NullPointerException
>  >>>  >>  >>>>>     at
>  >>> java.util.concurrent.ConcurrentLinkedQueue.offer(Unknown
>  >>>  >> Source)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>
> org.atmosphere.util.BroadcasterLookup.add(BroadcasterLookup.java:91)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AsynchronousProcessor.map(AsynchronousProcessor.java:149)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:116)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:102)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:79)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.atmosphere.cpr.AtmosphereServlet.doCometSupport(AtmosphereServlet.java:662)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>
> org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:647)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>
>  >>> org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:634)
>  >>>  >>  >>>>>     at
>  >>> javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
>  >>>  >>  >>>>>     at
>  >>> javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>
>  >>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>  >>>  >>  >>>>>     at org.mortbay.jetty.Server.handle(Server.java:324)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     at
>  >>> org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
>  >>>  >>  >>>>>     at
>  >>>  >> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>  >>>  >>  >>>>>     at
>  >>>  >> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     at
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
>
>  >>>
>  >>>  >>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> the source code of my attempt:
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> require 'java'
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> Dir["./Java/jetty/*.jar"].each { |jar| require jar }
>  >>>  >>  >>>>> Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
>  >>>  >>  >>>>> Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
>  >>>  >>  >>>>> Dir["./Java/apache/*.jar"].each { |jar| require jar }
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> include_class 'javax.servlet.http.HttpServlet'
>  >>>  >>  >>>>> include_class 'org.mortbay.jetty.Server'
>  >>>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.Context'
>  >>>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>  >>>  >>  >>>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>  >>>  >>  >>>>> include_class 'org.atmosphere.cpr.AtmosphereHandler'
>  >>>  >>  >>>>> include_class 'org.atmosphere.cpr.AtmosphereServlet'
>  >>>  >>  >>>>> include_class 'org.apache.catalina.CometProcessor'
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> def main
>  >>>  >>  >>>>>   server = Server.new(8080)
>  >>>  >>  >>>>>   #context = Context.new(server, '/', 0)
>  >>>  >>  >>>>>   context = Context.new(server, '/', Context::SESSIONS)
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>   servlet = AtmosphereServlet.new()
>  >>>  >>  >>>>>   servlet.addAtmosphereHandler("/", MyRubyHandler.new())
>  >>>  >>  >>>>>     holder = ServletHolder.new(servlet)
>  >>>  >>  >>>>>   context.addServlet(holder, '/')
>  >>>  >>  >>>>>     server.start()
>  >>>  >>  >>>>> end
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> class MyRubyHandler
>  >>>  >>  >>>>>   include AtmosphereHandler
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>   BEGIN_SCRIPT_TAG = '<script>'
>  >>>  >>  >>>>>   END_SCRIPT_TAG = '</script>'
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>   def onEvent(event)
>  >>>  >>  >>>>>         req = event.getRequest();
>  >>>  >>  >>>>>         res = event.getResponse();
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>         res.setContentType("text/html")
>  >>>  >>  >>>>>         res.addHeader("Cache-Control", "private")
>  >>>  >>  >>>>>         res.addHeader("Pragma", "no-cache")
>  >>>  >>  >>>>>         res.getWriter().write("<html><body><h1>It
>  >>>  >>  >>>>> works!</h1></body></html>\n");
>  >>>  >>  >>>>>         res.getWriter().flush();
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> #        if (req.getMethod().equalsIgnoreCase("GET"))
>  >>>  >>  >>>>> #            # for IE
>  >>>  >>  >>>>> #            res.getWriter().write("<!-- Comet is a
>  >>> programming
>  >>>  >>  >>>>> technique
>  >>>  >>  >>>>> that enables web " +
>  >>>  >>  >>>>> #                    "servers to send data to the client
>  >>> without
>  >>>  >>  >>>>> having any
>  >>>  >>  >>>>> need " +
>  >>>  >>  >>>>> #                    "for the client to request it.
> -->\n");
>  >>>  >>  >>>>> #            res.getWriter().flush();
>  >>>  >>  >>>>> #
>  >>>  >>  >>>>> #            #
>  >>>  >>  >>>>> #            # Mark this connection as suspended.
>  >>>  >>  >>>>> #            #
>  >>>  >>  >>>>> #            event.suspend();
>  >>>  >>  >>>>> #        elsif (req.getMethod().equalsIgnoreCase("POST"))
>  >>>  >>  >>>>> #            res.setCharacterEncoding("UTF-8");
>  >>>  >>  >>>>> #            String action =
>  >>> req.getParameterValues("action")[0];
>  >>>  >>  >>>>> #            String name =
> req.getParameterValues("name")[0];
>  >>>  >>  >>>>> #
>  >>>  >>  >>>>> #            if "login".equals(action)
>  >>>  >>  >>>>> #                event.getBroadcaster().broadcast(
>  >>>  >>  >>>>> #                  BEGIN_SCRIPT_TAG +
>  >>>  >>  >>>>> #                    toJsonp("System Message from " +
>  >>>  >>  >>>>> event.getWebServerName(),
>  >>>  >>  >>>>> #                      name + " has joined.") +
>  >>>  >>  >>>>> #                  END_SCRIPT_TAG);
>  >>>  >>  >>>>> #
>  >>>  >>  >>>>> #                res.getWriter().write("success");
>  >>>  >>  >>>>> #                res.getWriter().flush();
>  >>>  >>  >>>>> #            elsif ("post".equals(action))
>  >>>  >>  >>>>> #                message =
>  >>> req.getParameterValues("message")[0];
>  >>>  >>  >>>>> #                event.getBroadcaster().broadcast(
>  >>>  >>  >>>>> #                  BEGIN_SCRIPT_TAG + toJsonp(name,
> message) +
>  >>>  >>  >>>>> END_SCRIPT_TAG);
>  >>>  >>  >>>>> #                res.getWriter().write("success");
>  >>>  >>  >>>>> #                res.getWriter().flush();
>  >>>  >>  >>>>> #            else
>  >>>  >>  >>>>> #                res.setStatus(422);
>  >>>  >>  >>>>> #
>  >>>  >>  >>>>> #                res.getWriter().write("success");
>  >>>  >>  >>>>> #                res.getWriter().flush();
>  >>>  >>  >>>>> #            end
>  >>>  >>  >>>>> #        end
>  >>>  >>  >>>>>         return event;
>  >>>  >>  >>>>>     end
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>     def onMessage(event)
>  >>>  >>  >>>>>         req = event.getRequest();
>  >>>  >>  >>>>>         res = event.getResponse();
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>         if (event.isResuming() ||
> event.isResumedOnTimedout())
>  >>>  >>  >>>>>             script = BEGIN_SCRIPT_TAG +
>  >>>  >> "window.parent.app.listen();\n"
>  >>>  >>  >>>>> +
>  >>>  >>  >>>>> END_SCRIPT_TAG;
>  >>>  >>  >>>>>             res.getWriter().write(script);
>  >>>  >>  >>>>>             res.getWriter().flush();
>  >>>  >>  >>>>>         else
>  >>>  >>  >>>>>
>  >>> res.getWriter().write(event.getMessage().toString());
>  >>>  >>  >>>>>             res.getWriter().flush();
>  >>>  >>  >>>>>         end
>  >>>  >>  >>>>>         return event;
>  >>>  >>  >>>>>     end
>  >>>  >>  >>>>> end
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> main
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> --end of ruby source--
>  >>>  >>  >>>>>
>  >>>  >>  >>>>>
>  >>>  >>  >>>>> Thank you very much for support.
>  >>>  >>  >>>>>
>  >>>  >>  >>>>
>  >>>  >>
> ---------------------------------------------------------------------
>  >>>  >>  >>>> To unsubscribe, e-mail: [hidden email]
>  >>>  >>  >>>> For additional commands, e-mail: [hidden email]
>  >>>  >>  >>>>
>  >>>  >>  >>>
>  >>>  >>  >>>
>  >>> ---------------------------------------------------------------------
>  >>>  >>  >>> To unsubscribe, e-mail: [hidden email]
>  >>>  >>  >>> For additional commands, e-mail: [hidden email]
>  >>>  >>  >>>
>  >>>  >>  >>
>  >>>  >>  >
>  >>> ---------------------------------------------------------------------
>  >>>  >>  > To unsubscribe, e-mail: [hidden email]
>  >>>  >>  > For additional commands, e-mail: [hidden email]
>  >>>  >>  >
>  >>>  >>  >
>  >>>  >>  >
>  >>>  >>  > ________________________________
>  >>>  >>  > View message @
>  >>>  >>  >
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3553859.html
>  >>>  >>  > To unsubscribe from Iframe streaming with Jruby and Atmosphere,
>  >>> click
>  >>>  >> here.
>  >>>  >>  >
>  >>>  >>
>  >>>  >>
>  >>>  >>
>  >>>  >> --
>  >>>  >> S pozdravem, Regards
>  >>>  >> Michal Hantl
>  >>>  >>
>  >>>  >> gtalk/jabber: [hidden email]
>  >>>  >>
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1 
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1>
>  >>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1 
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3554785&i=1>>>
>  >>>  >> icq: 241813215
>  >>>  >>
>  >>>  >>
>  >>>
> ------------------------------------------------------------------------
>  >>>  >> View this message in context: Re: Iframe streaming with Jruby and
>  >>>  >> Atmosphere
>  >>>  >>
>  >>>  >>
>  >>>
>  >>>
>  >>>
> <http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3554785.html>
>
>  >>>
>  >>>  >> Sent from the Atmosphere users mailling list mailing list archive
>  >>>  >>
> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html>
>  >>> at
>  >>>  >> Nabble.com.
>  >>>  >
> ---------------------------------------------------------------------
>  >>>  > To unsubscribe, e-mail: [hidden email]
>  >>>  > For additional commands, e-mail: [hidden email]
>  >>>  >
>  >>>  >
>  >>>  >
>  >>>  > ________________________________
>  >>>  > View message @
>  >>>  >
>  >>>
>  >>>
>  >>>
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555505.html
>  >>>  > To unsubscribe from Iframe streaming with Jruby and Atmosphere,
> click
>  >>> here.
>  >>>  >
>  >>>
>  >>>
>  >>>
>  >>> --
>  >>> S pozdravem, Regards
>  >>> Michal Hantl
>  >>>
>  >>> gtalk/jabber: [hidden email]
>  >>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3555776&i=1 
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3555776&i=1>>
>  >>> icq: 241813215
>  >>>
>  >>>
> ------------------------------------------------------------------------
>  >>> View this message in context: Re: Iframe streaming with Jruby and
>  >>> Atmosphere
>  >>>
>  >>>
>  >>>
> <http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555776.html>
>
>  >>> Sent from the Atmosphere users mailling list mailing list archive
>  >>> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
>  >>> Nabble.com.
>  >> ---------------------------------------------------------------------
>  >> To unsubscribe, e-mail: [hidden email]
>  >> For additional commands, e-mail: [hidden email]
>  >>
>  >>
>  >>
>  >> ________________________________
>  >> View message @
>  >>
>  >>
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3555881.html
>  >> To unsubscribe from Iframe streaming with Jruby and Atmosphere, click
>  >> here.
>  >>
>  >
>  >
>  > --
>  > S pozdravem, Regards
>  > Michal Hantl
>  >
>  > gtalk/jabber: [hidden email]
>  > icq: 241813215
>  >
>  >
>  > ________________________________
>  > View message @
>  >
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3556202.html
>  > To unsubscribe from Iframe streaming with Jruby and Atmosphere, click
> here.
>  >
>
>
>
> --
> S pozdravem, Regards
> Michal Hantl
>
> gtalk/jabber: [hidden email]
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3558520&i=1>
> icq: 241813215
>
> ------------------------------------------------------------------------
> View this message in context: Re: Iframe streaming with Jruby and
> Atmosphere
> <http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3558520.html>
> Sent from the Atmosphere users mailling list mailing list archive
> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
> Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@atmosphere.dev.java.net
For additional commands, e-mail: users-help@atmosphere.dev.java.net
Michal Hantl

Re: (fixed) Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
So i did a little chat app with iframe streaming and no js-library.

Its a bit rough but its exactly what i needed - quick and dirty example.

There were some problem though.

Sometimes the messages appear in bursts. First two may not arrive in realtime and when the third one is sent, they all are sent.

Wonder if thats even server side problem? Seems to me that if the app sends messages frequently, they should be more snappy.

Also note that the client script reloads when the page is reloaded (so i can play with it without restarting the server).

Thank you very much for your support Jeanfrancois!


-- atmosphere.rb: ----------------------------------------------------------

require 'java'

Dir["./Java/jetty/*.jar"].each { |jar| require jar }
Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }

include_class 'javax.servlet.http.HttpServlet'
include_class 'org.mortbay.jetty.Server'
include_class 'org.mortbay.jetty.servlet.Context'
include_class 'org.mortbay.jetty.servlet.ServletHolder'
include_class 'org.atmosphere.cpr.AtmosphereHandler'
include_class 'org.atmosphere.cpr.AtmosphereServlet'


#setup and start the server
def main
  server = Server.new(80)
  #context = Context.new(server, '/', 0)
  context = Context.new(server, '/', Context::SESSIONS)

  servlet = AtmosphereServlet.new()
  servlet.addAtmosphereHandler("/chat-stream", ChatStream.new())
  servlet.addAtmosphereHandler("/", ChatPage.new())
 
  context.addServlet(ServletHolder.new(servlet), '/')
 
  server.start()
end


#serve the chat page
class ChatPage
  include AtmosphereHandler

  def onEvent(event)
    Kernel.load(__FILE__)
    res = event.getResponse()

    res.setContentType("text/html")
    res.addHeader("Cache-Control", "private")
    res.addHeader("Pragma", "no-cache")
    File.open(File.dirname(__FILE__)+'/chat.html').each { |line|
      res.getWriter().write(line)
    }
    res.getWriter().flush()
    event
  end
end

#serve the chat stream and post messages
class ChatStream
  include AtmosphereHandler

  BEGIN_SCRIPT_TAG = '<script>'
  END_SCRIPT_TAG = '</script>'

  def onEvent(event)
    #reload the source so we can work on it
    #Kernel.load(__FILE__)
    req = event.getRequest();
    res = event.getResponse();

    res.setContentType("text/html")
    res.addHeader("Cache-Control", "private")
    res.addHeader("Pragma", "no-cache")
    res.setCharacterEncoding("UTF-8");

    if (req.getMethod().upcase === "GET")
      # for IE
      res.getWriter().write("<!-- Comet is a programming technique that enables web " +
              "servers to send data to the client without having any need " +
              "for the client to request it. -->\n");
      res.getWriter().flush();
      event.suspend();

    elsif (req.getMethod().upcase === "POST")
      message = req.getParameterValues("message")[0].to_s
      ip = req.getRemoteAddr().to_s

        event.getBroadcaster().broadcast(
          BEGIN_SCRIPT_TAG +
            "window.parent.say('<small>#{ip} - #{req.getHeader("User-Agent").to_s}:</small><br>#{message}')" +
          END_SCRIPT_TAG);

        res.getWriter().write('success')
        res.getWriter().flush();
    end

    event
  end

  def onMessage(event)
      writer = event.getResponse().getWriter()
      writer.write(event.getMessage().to_s.ljust(1*1024))
      writer.flush()
      event
  end
end



if !$once
  main
  $once = true
end





-- chat.html: ----------------------------------------------------------------

<html>
  <head>
    <title>Atmosphere + Jetty + Jruby Chat demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <style>
      #messages {
        height:35em;
        width:40em;
        border:2px inset;
        background:#ff8;
        padding:0.2em;
        overflow:auto;
      }
    </style>
  </head>
  <body>
    <h1>Atmosphere + Jetty + Jruby Chat demo</h1>

    <div id="messages">
    </div>

    <form action="/chat-stream" target="send_message" method="POST" onsubmit="setTimeout('document.getElementById(\'message-input\').value = \'\'',10);">
      <input name="message" id="message-input"/>
    </form>

    <script>
      function say(what) {
        var chat_log = document.getElementById('messages');
        message = document.createElement('div');
        message.innerHTML = what;
        chat_log.appendChild(message);
        message.scrollIntoView();
      }
      say("the chat may begin");
      document.getElementById('message-input').focus();

      function send_message(field, form) {
        form.submit();
        field.value = '';
      }
    </script>

    <!-- this iframe gets the stream of chat events -->
    <iframe src="/chat-stream" style="display:none"></iframe>

    <!-- this iframe just sends messages with no ajax needed -->
    <iframe name="send_message" style="display:none"></iframe>
  </body>
</html>

Michal Hantl

Re: (fixed) Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
Oh and btw, here is the whole thing so folks don't have to look for those jars: http://d.hantl.cz/atmosphere_jetty_jruby.zip


Michal Hantl wrote:
So i did a little chat app with iframe streaming and no js-library.

Its a bit rough but its exactly what i needed - quick and dirty example.

There were some problem though.

Sometimes the messages appear in bursts. First two may not arrive in realtime and when the third one is sent, they all are sent.

Wonder if thats even server side problem? Seems to me that if the app sends messages frequently, they should be more snappy.

Also note that the client script reloads when the page is reloaded (so i can play with it without restarting the server).

Thank you very much for your support Jeanfrancois!


-- atmosphere.rb: ----------------------------------------------------------

require 'java'

Dir["./Java/jetty/*.jar"].each { |jar| require jar }
Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }

include_class 'javax.servlet.http.HttpServlet'
include_class 'org.mortbay.jetty.Server'
include_class 'org.mortbay.jetty.servlet.Context'
include_class 'org.mortbay.jetty.servlet.ServletHolder'
include_class 'org.atmosphere.cpr.AtmosphereHandler'
include_class 'org.atmosphere.cpr.AtmosphereServlet'


#setup and start the server
def main
  server = Server.new(80)
  #context = Context.new(server, '/', 0)
  context = Context.new(server, '/', Context::SESSIONS)

  servlet = AtmosphereServlet.new()
  servlet.addAtmosphereHandler("/chat-stream", ChatStream.new())
  servlet.addAtmosphereHandler("/", ChatPage.new())
 
  context.addServlet(ServletHolder.new(servlet), '/')
 
  server.start()
end


#serve the chat page
class ChatPage
  include AtmosphereHandler

  def onEvent(event)
    Kernel.load(__FILE__)
    res = event.getResponse()

    res.setContentType("text/html")
    res.addHeader("Cache-Control", "private")
    res.addHeader("Pragma", "no-cache")
    File.open(File.dirname(__FILE__)+'/chat.html').each { |line|
      res.getWriter().write(line)
    }
    res.getWriter().flush()
    event
  end
end

#serve the chat stream and post messages
class ChatStream
  include AtmosphereHandler

  BEGIN_SCRIPT_TAG = '<script>'
  END_SCRIPT_TAG = '</script>'

  def onEvent(event)
    #reload the source so we can work on it
    #Kernel.load(__FILE__)
    req = event.getRequest();
    res = event.getResponse();

    res.setContentType("text/html")
    res.addHeader("Cache-Control", "private")
    res.addHeader("Pragma", "no-cache")
    res.setCharacterEncoding("UTF-8");

    if (req.getMethod().upcase === "GET")
      # for IE
      res.getWriter().write("<!-- Comet is a programming technique that enables web " +
              "servers to send data to the client without having any need " +
              "for the client to request it. -->\n");
      res.getWriter().flush();
      event.suspend();

    elsif (req.getMethod().upcase === "POST")
      message = req.getParameterValues("message")[0].to_s
      ip = req.getRemoteAddr().to_s

        event.getBroadcaster().broadcast(
          BEGIN_SCRIPT_TAG +
            "window.parent.say('<small>#{ip} - #{req.getHeader("User-Agent").to_s}:</small><br>#{message}')" +
          END_SCRIPT_TAG);

        res.getWriter().write('success')
        res.getWriter().flush();
    end

    event
  end

  def onMessage(event)
      writer = event.getResponse().getWriter()
      writer.write(event.getMessage().to_s.ljust(1*1024))
      writer.flush()
      event
  end
end



if !$once
  main
  $once = true
end





-- chat.html: ----------------------------------------------------------------

<html>
  <head>
    <title>Atmosphere + Jetty + Jruby Chat demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <style>
      #messages {
        height:35em;
        width:40em;
        border:2px inset;
        background:#ff8;
        padding:0.2em;
        overflow:auto;
      }
    </style>
  </head>
  <body>
    <h1>Atmosphere + Jetty + Jruby Chat demo</h1>

    <div id="messages">
    </div>

    <form action="/chat-stream" target="send_message" method="POST" onsubmit="setTimeout('document.getElementById(\'message-input\').value = \'\'',10);">
      <input name="message" id="message-input"/>
    </form>

    <script>
      function say(what) {
        var chat_log = document.getElementById('messages');
        message = document.createElement('div');
        message.innerHTML = what;
        chat_log.appendChild(message);
        message.scrollIntoView();
      }
      say("the chat may begin");
      document.getElementById('message-input').focus();

      function send_message(field, form) {
        form.submit();
        field.value = '';
      }
    </script>

    <!-- this iframe gets the stream of chat events -->
    <iframe src="/chat-stream" style="display:none"></iframe>

    <!-- this iframe just sends messages with no ajax needed -->
    <iframe name="send_message" style="display:none"></iframe>
  </body>
</html>
Jeanfrancois Arcand

Re: (fixed) Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
Salut

Michal Hantl wrote:
> Oh and btw, here is the whole thing so folks don't have to look for those
> jars: http://d.hantl.cz/atmosphere_jetty_jruby.zip

Thanks!. I can't reproduce the issue. What step exactly are you
following? Digging....

BTW I recommend you install ngrep.sourceforge.net and snoop the traffic
between the browser and the server. That should tell us where the
problem is, e.g. the server or client not displaying.

   % sudo ngrep -d eth0 -q -W byline port 80

Thanks

-- Jeanfrancois

>
>
>
> Michal Hantl wrote:
>> So i did a little chat app with iframe streaming and no js-library.
>>
>> Its a bit rough but its exactly what i needed - quick and dirty example.
>>
>> There were some problem though.
>>
>> Sometimes the messages appear in bursts. First two may not arrive in
>> realtime and when the third one is sent, they all are sent.
>>
>> Wonder if thats even server side problem? Seems to me that if the app
>> sends messages frequently, they should be more snappy.
>>
>> Also note that the client script reloads when the page is reloaded (so i
>> can play with it without restarting the server).
>>
>> Thank you very much for your support Jeanfrancois!
>>
>>
>> -- atmosphere.rb:
>> ----------------------------------------------------------
>>
>> require 'java'
>>
>> Dir["./Java/jetty/*.jar"].each { |jar| require jar }
>> Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
>> Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
>>
>> include_class 'javax.servlet.http.HttpServlet'
>> include_class 'org.mortbay.jetty.Server'
>> include_class 'org.mortbay.jetty.servlet.Context'
>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>> include_class 'org.atmosphere.cpr.AtmosphereHandler'
>> include_class 'org.atmosphere.cpr.AtmosphereServlet'
>>
>>
>> #setup and start the server
>> def main
>>   server = Server.new(80)
>>   #context = Context.new(server, '/', 0)
>>   context = Context.new(server, '/', Context::SESSIONS)
>>
>>   servlet = AtmosphereServlet.new()
>>   servlet.addAtmosphereHandler("/chat-stream", ChatStream.new())
>>   servlet.addAtmosphereHandler("/", ChatPage.new())
>>  
>>   context.addServlet(ServletHolder.new(servlet), '/')
>>  
>>   server.start()
>> end
>>
>>
>> #serve the chat page
>> class ChatPage
>>   include AtmosphereHandler
>>
>>   def onEvent(event)
>>     Kernel.load(__FILE__)
>>     res = event.getResponse()
>>
>>     res.setContentType("text/html")
>>     res.addHeader("Cache-Control", "private")
>>     res.addHeader("Pragma", "no-cache")
>>     File.open(File.dirname(__FILE__)+'/chat.html').each { |line|
>>       res.getWriter().write(line)
>>     }
>>     res.getWriter().flush()
>>     event
>>   end
>> end
>>
>> #serve the chat stream and post messages
>> class ChatStream
>>   include AtmosphereHandler
>>
>>   BEGIN_SCRIPT_TAG = '<script>'
>>   END_SCRIPT_TAG = '</script>'
>>
>>   def onEvent(event)
>>     #reload the source so we can work on it
>>     #Kernel.load(__FILE__)
>>     req = event.getRequest();
>>     res = event.getResponse();
>>
>>     res.setContentType("text/html")
>>     res.addHeader("Cache-Control", "private")
>>     res.addHeader("Pragma", "no-cache")
>>     res.setCharacterEncoding("UTF-8");
>>
>>     if (req.getMethod().upcase === "GET")
>>       # for IE
>>       res.getWriter().write("<!-- Comet is a programming technique that
>> enables web " +
>>               "servers to send data to the client without having any need
>> " +
>>               "for the client to request it. -->\n");
>>       res.getWriter().flush();
>>       event.suspend();
>>
>>     elsif (req.getMethod().upcase === "POST")
>>       message = req.getParameterValues("message")[0].to_s
>>       ip = req.getRemoteAddr().to_s
>>
>>         event.getBroadcaster().broadcast(
>>           BEGIN_SCRIPT_TAG +
>>             "window.parent.say('<small>#{ip} -
>> #{req.getHeader("User-Agent").to_s}:</small><br>#{message}')" +
>>           END_SCRIPT_TAG);
>>
>>         res.getWriter().write('success')
>>         res.getWriter().flush();
>>     end
>>
>>     event
>>   end
>>
>>   def onMessage(event)
>>       writer = event.getResponse().getWriter()
>>       writer.write(event.getMessage().to_s.ljust(1*1024))
>>       writer.flush()
>>       event
>>   end
>> end
>>
>>
>>
>> if !$once
>>   main
>>   $once = true
>> end
>>
>>
>>
>>
>>
>> -- chat.html:
>> ----------------------------------------------------------------
>>
>> <html>
>>   <head>
>>     <title>Atmosphere + Jetty + Jruby Chat demo</title>
>>     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
>>     <style>
>>       #messages {
>>         height:35em;
>>         width:40em;
>>         border:2px inset;
>>         background:#ff8;
>>         padding:0.2em;
>>         overflow:auto;
>>       }
>>     </style>
>>   </head>
>>   <body>
>>     <h1>Atmosphere + Jetty + Jruby Chat demo</h1>
>>
>>     <div id="messages">
>>     </div>
>>
>>     <form action="/chat-stream" target="send_message" method="POST"
>> onsubmit="setTimeout('document.getElementById(\'message-input\').value =
>> \'\'',10);">
>>       <input name="message" id="message-input"/>
>>     </form>
>>
>>     <script>
>>       function say(what) {
>>         var chat_log = document.getElementById('messages');
>>         message = document.createElement('div');
>>         message.innerHTML = what;
>>         chat_log.appendChild(message);
>>         message.scrollIntoView();
>>       }
>>       say("the chat may begin");
>>       document.getElementById('message-input').focus();
>>
>>       function send_message(field, form) {
>>         form.submit();
>>         field.value = '';
>>       }
>>     </script>
>>
>>     <!-- this iframe gets the stream of chat events -->
>>     <iframe src="/chat-stream" style="display:none"></iframe>
>>
>>     <!-- this iframe just sends messages with no ajax needed -->
>>     <iframe name="send_message" style="display:none"></iframe>
>>   </body>
>> </html>
>>
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Michal Hantl

Re: (fixed) Re: Iframe streaming with Jruby and Atmosphere

Reply Threaded More More options
Print post
Permalink
2009/9/3 Jeanfrancois Arcand (via Nabble)
<[hidden email]>:
> Salut
>
> Michal Hantl wrote:
>> Oh and btw, here is the whole thing so folks don't have to look for those
>> jars: http://d.hantl.cz/atmosphere_jetty_jruby.zip
>
> Thanks!. I can't reproduce the issue. What step exactly are you
> following? Digging....

The event burst?

I will definetly look into this with some tool and also prepare
automated test and report.

Thank you very much for the care, now I will probably play with bayeux
or something and prepare the test.

>
> BTW I recommend you install ngrep.sourceforge.net and snoop the traffic
> between the browser and the server. That should tell us where the
> problem is, e.g. the server or client not displaying.
>
>    % sudo ngrep -d eth0 -q -W byline port 80
>
> Thanks
>
> -- Jeanfrancois
>
>>
>>
>>
>> Michal Hantl wrote:
>>> So i did a little chat app with iframe streaming and no js-library.
>>>
>>> Its a bit rough but its exactly what i needed - quick and dirty example.
>>>
>>> There were some problem though.
>>>
>>> Sometimes the messages appear in bursts. First two may not arrive in
>>> realtime and when the third one is sent, they all are sent.
>>>
>>> Wonder if thats even server side problem? Seems to me that if the app
>>> sends messages frequently, they should be more snappy.
>>>
>>> Also note that the client script reloads when the page is reloaded (so i
>>> can play with it without restarting the server).
>>>
>>> Thank you very much for your support Jeanfrancois!
>>>
>>>
>>> -- atmosphere.rb:
>>> ----------------------------------------------------------
>>>
>>> require 'java'
>>>
>>> Dir["./Java/jetty/*.jar"].each { |jar| require jar }
>>> Dir["./Java/jsdk/*.jar"].each { |jar| require jar }
>>> Dir["./Java/atmosphere/*.jar"].each { |jar| require jar }
>>>
>>> include_class 'javax.servlet.http.HttpServlet'
>>> include_class 'org.mortbay.jetty.Server'
>>> include_class 'org.mortbay.jetty.servlet.Context'
>>> include_class 'org.mortbay.jetty.servlet.ServletHolder'
>>> include_class 'org.atmosphere.cpr.AtmosphereHandler'
>>> include_class 'org.atmosphere.cpr.AtmosphereServlet'
>>>
>>>
>>> #setup and start the server
>>> def main
>>>   server = Server.new(80)
>>>   #context = Context.new(server, '/', 0)
>>>   context = Context.new(server, '/', Context::SESSIONS)
>>>
>>>   servlet = AtmosphereServlet.new()
>>>   servlet.addAtmosphereHandler("/chat-stream", ChatStream.new())
>>>   servlet.addAtmosphereHandler("/", ChatPage.new())
>>>
>>>   context.addServlet(ServletHolder.new(servlet), '/')
>>>
>>>   server.start()
>>> end
>>>
>>>
>>> #serve the chat page
>>> class ChatPage
>>>   include AtmosphereHandler
>>>
>>>   def onEvent(event)
>>>     Kernel.load(__FILE__)
>>>     res = event.getResponse()
>>>
>>>     res.setContentType("text/html")
>>>     res.addHeader("Cache-Control", "private")
>>>     res.addHeader("Pragma", "no-cache")
>>>     File.open(File.dirname(__FILE__)+'/chat.html').each { |line|
>>>       res.getWriter().write(line)
>>>     }
>>>     res.getWriter().flush()
>>>     event
>>>   end
>>> end
>>>
>>> #serve the chat stream and post messages
>>> class ChatStream
>>>   include AtmosphereHandler
>>>
>>>   BEGIN_SCRIPT_TAG = '<script>'
>>>   END_SCRIPT_TAG = '</script>'
>>>
>>>   def onEvent(event)
>>>     #reload the source so we can work on it
>>>     #Kernel.load(__FILE__)
>>>     req = event.getRequest();
>>>     res = event.getResponse();
>>>
>>>     res.setContentType("text/html")
>>>     res.addHeader("Cache-Control", "private")
>>>     res.addHeader("Pragma", "no-cache")
>>>     res.setCharacterEncoding("UTF-8");
>>>
>>>     if (req.getMethod().upcase === "GET")
>>>       # for IE
>>>       res.getWriter().write("<!-- Comet is a programming technique that
>>> enables web " +
>>>               "servers to send data to the client without having any need
>>> " +
>>>               "for the client to request it. -->\n");
>>>       res.getWriter().flush();
>>>       event.suspend();
>>>
>>>     elsif (req.getMethod().upcase === "POST")
>>>       message = req.getParameterValues("message")[0].to_s
>>>       ip = req.getRemoteAddr().to_s
>>>
>>>         event.getBroadcaster().broadcast(
>>>           BEGIN_SCRIPT_TAG +
>>>             "window.parent.say('<small>#{ip} -
>>> #{req.getHeader("User-Agent").to_s}:</small><br>#{message}')" +
>>>           END_SCRIPT_TAG);
>>>
>>>         res.getWriter().write('success')
>>>         res.getWriter().flush();
>>>     end
>>>
>>>     event
>>>   end
>>>
>>>   def onMessage(event)
>>>       writer = event.getResponse().getWriter()
>>>       writer.write(event.getMessage().to_s.ljust(1*1024))
>>>       writer.flush()
>>>       event
>>>   end
>>> end
>>>
>>>
>>>
>>> if !$once
>>>   main
>>>   $once = true
>>> end
>>>
>>>
>>>
>>>
>>>
>>> -- chat.html:
>>> ----------------------------------------------------------------
>>>
>>> <html>
>>>   <head>
>>>     <title>Atmosphere + Jetty + Jruby Chat demo</title>
>>>     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
>>>     <style>
>>>       #messages {
>>>         height:35em;
>>>         width:40em;
>>>         border:2px inset;
>>>         background:#ff8;
>>>         padding:0.2em;
>>>         overflow:auto;
>>>       }
>>>     </style>
>>>   </head>
>>>   <body>
>>>     <h1>Atmosphere + Jetty + Jruby Chat demo</h1>
>>>
>>>     <div id="messages">
>>>     </div>
>>>
>>>     <form action="/chat-stream" target="send_message" method="POST"
>>> onsubmit="setTimeout('document.getElementById(\'message-input\').value =
>>> \'\'',10);">
>>>       <input name="message" id="message-input"/>
>>>     </form>
>>>
>>>     <script>
>>>       function say(what) {
>>>         var chat_log = document.getElementById('messages');
>>>         message = document.createElement('div');
>>>         message.innerHTML = what;
>>>         chat_log.appendChild(message);
>>>         message.scrollIntoView();
>>>       }
>>>       say("the chat may begin");
>>>       document.getElementById('message-input').focus();
>>>
>>>       function send_message(field, form) {
>>>         form.submit();
>>>         field.value = '';
>>>       }
>>>     </script>
>>>
>>>     <!-- this iframe gets the stream of chat events -->
>>>     <iframe src="/chat-stream" style="display:none"></iframe>
>>>
>>>     <!-- this iframe just sends messages with no ajax needed -->
>>>     <iframe name="send_message" style="display:none"></iframe>
>>>   </body>
>>> </html>
>>>
>>>
>>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
> ________________________________
> View message @
> http://n2.nabble.com/Iframe-streaming-with-Jruby-and-Atmosphere-tp3525131p3573772.html
> To unsubscribe from Iframe streaming with Jruby and Atmosphere, click here.
>



--
S pozdravem, Regards
Michal Hantl

gtalk/jabber: [hidden email]
icq: 241813215
1 2