7 Replies Latest reply on Jun 4, 2010 12:24 PM by Mike Brock

    Errai-cdi integration in glassfish

    Pablo Fonseca Newbie

      Hi everyone,

       

      First I want to congratulate all of you that works on Errai project, I have tested a lot of "comet like" implementations as atmosphere, gwt-comet, grizzly-comet and now Im very happy with errai-bus with gwt.

       

      I have it working fine using guice, but I need to use the errai-cdi package, because I need to integrate it better the whole project, that is a complete javaee project using JCA, MDB, EJB, JPA, Weld, Servlets and GWT.

       

      Im having problems using errai-cdi on my project, what Im using:

       

      Glassfish v3.0.1 - http://download.java.net/glassfish/v3.0.1/promoted/glassfish-3.0.1-b18-unix.sh

      errai-bus 1.1-SNAPSHOT

      errai-cdi 1.1-SNAPSHOT constructed from svn source

       

      What I've tried:

      --------------------------------------

      Scenario 1:

       

      in my web.xml:

      <servlet>

          <servlet-name>ErraiServlet</servlet-name>
          <servlet-class>org.jboss.errai.bus.server.servlet.GrizzlyCometServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
          <servlet-name>ErraiServlet</servlet-name>
          <url-pattern>*.erraiBus</url-pattern>
        </servlet-mapping>
        <listener>
          <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
        </listener>
        <resource-env-ref>
          <description>Object factory for the Errai Service</description>
          <resource-env-ref-name>Errai</resource-env-ref-name>
          <resource-env-ref-type>org.jboss.errai.bus.server.service.ErraiService</resource-env-ref-type>
        </resource-env-ref>

       

      sun-web.xml:

        <resource-env-ref>

          <resource-env-ref-name>Errai</resource-env-ref-name>

          <jndi-name>java:comp/env/Errai</jndi-name>

        </resource-env-ref>

       

      ErraiService.properties:

      errai.dispatcher_implementation=org.jboss.errai.bus.server.AsyncDispatcher

      read_pool_size=5

      errai.async.worker.timeout=5

      errai.auto_discover_services=false

       

      with this configuration I got:

      Exception while loading the app : java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.jboss.weld.exceptions.DefinitionException: Exception #0 :null

       

      ---------------------------------------------

       

      Scenario 2: (showing only diferences)

       

      n my web.xml:

      <servlet>

          <servlet-name>ErraiServlet</servlet-name>
          <servlet-class>com.something.server.DelegatingServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
        </servlet>
        <!--listener>
          <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
        </listener-->

       

       

      DelegatinServelet.java:

      same as http://anonsvn.jboss.org/repos/errai/projects/weld-integration/trunk/examples/gui/src/main/java/org/jboss/errai/cdi/server/DelegatingServlet.java

       

       

      with this config I got:

      Exception while loading the app : java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.StackOverflowError

       

      a lot of these:

      java.lang.StackOverflowError

              at java.util.logging.Logger.fine(Logger.java:1051)

              at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:639)

              at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:148)

              at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:428)

              at javax.naming.InitialContext.lookup(InitialContext.java:392)

              at com.sun.enterprise.naming.util.JndiNamingObjectFactory.create(JndiNamingObjectFactory.java:87)

              at com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$1.create(ComponentEnvManagerImpl.java:596)

              at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:688)

              at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:657)

              at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:148)

              at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:428)

       

      ------------------------------------------------

       

      Ive made this config scenarios based on the example/gui found here http://anonsvn.jboss.org/repos/errai/projects/weld-integration/trunk/examples/gui/ , jetty uses the web.xml listener configuration, jboss dont, and so on...

       

      I will be very pleased if someone could help me on this.

       

      Thanks in advance, if you need more info, please ask.

        • 1. Re: Errai-cdi integration in glassfish
          Heiko Braun Master

          The current integration code comes in two flavours:

           

          - jetty hosted mode CDI (includes the weld servlet init)

          - jboss 6 integration (runs as jboss services, bound to JNDI)

           

          Both of these options wouldn't work for you. First thing I recommend is to

          make sure CDI is available within the glassfish web container.

           

          problem is that the current code does a lookup on JNDI to find the errai service.

          (Hence the DelegatingServlet implementation). This means you would need to

          find an equivalent within glassfish (bootstrapping errai service outside the webcontainer and bind it to JNDI.

          Or simply use the jboss application server

          1 of 1 people found this helpful
          • 2. Re: Errai-cdi integration in glassfish
            Pablo Fonseca Newbie

            Thanks, I think everyone here is expert with Jboss, so I will try another things to get CDI working with errai at glassfish.

             

            CDI is enabled and I'm using it in my project, the problem is only how to create this Errai service outside the webcontainer, because glassfish does not have sas support and I dont know yet how to similar thing with glassfish.

             

            Btw, thanks for the info.

            • 3. Re: Errai-cdi integration in glassfish
              mariqn nenchev Novice

              Hi,  so you tested all comet like implementations and you decided to go with errai bus? Could you please be more specific how exactly you will use the comet feature? I mean you will stream updates to the browser or just need update events that do not happen often? I am currently investigating comet solutions too. Only atmosphere supports real server push. I do not know how good is errai bus implementation, but errai bus use long polling, so for many updates per second i do not know how it will behave. Any experience?  Regards.

              • 4. Re: Errai-cdi integration in glassfish
                Mike Brock Master

                It is true that Errai does not currently support WebSockets, although support will be available in the coming months.  We have not prioritized WebSocket support because server and browser support at this time is poor.  In fact, Google Chrome is the only browser with a relatively good implementation at this time.

                 

                Considering that Firefox and Internet Explorer support for WebSockets is lacking, we are continuing to focus on long-polling for the time being.  We believe this is the best solution for general compatibility at this time.  But as I said, WebSocket support is definitely coming.

                1 of 1 people found this helpful
                • 5. Re: Errai-cdi integration in glassfish
                  Heiko Braun Master
                  Only atmosphere supports real server push. I do not know how good is errai bus implementation, but errai bus use long polling, so for many updates per second i do not know how it will behave. Any experience?  Regards.

                   

                  there is no such thing as "real server push", apart from maybe web sockets. But don't worry, we've been pushing several hundreds of messages per millisecond using the current long poll approach. BTW, it's the same approach Google Wave uses.

                  • 6. Re: Errai-cdi integration in glassfish
                    mariqn nenchev Novice

                    Hi,  I didn't say errai is bad, on the contrary from the samples i see that it is very good, the code is clean and nice, every thing looks easy. You guys stand behind it, so it is serious project. I am planning to use it in my next project for sure. About web sockets and real data stream pushing. I don't know how the guys that develop Lightstreamer have done this, but they really push data. We are using lightstreamer server for our current project and it is really great, but it is also paid :).  One other question, you say you develop stream pushing right now, will it be easy project developed with older version of errai(with long polling) to switch automatically to stream pushing when it is released and when all major browsers begin to support web sockets?  Regards.

                    • 7. Re: Errai-cdi integration in glassfish
                      Mike Brock Master

                      Supporting graceful degradation and promotion to/from WebSockets based on capabilities of the browser is definitely something that is on our agenda.   So the answer is yes.