Atmosphere plug-in not working in Grails 2.0.1

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Atmosphere plug-in not working in Grails 2.0.1

glalejos
Hello everyone,

I'm having trouble with the atmosphere plug-in when upgrading my Grails 1.3.7 application to Grails 2.0.1 (the problem happens both on Grails 2.0.0 and Grails 2.0.1).

Whenever I visit a page that uses atmosphere, the following exception is dumped to the logs:

| Error 2012-02-16 16:13:33,092 [http-bio-8080-exec-10] ERROR cpr.AtmosphereServlet - AtmosphereServlet exception
Message: Not supported.
Line | Method
->> 126 | suspend in org.atmosphere.container.Servlet30CometSupport
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 90 | service in ''
| 1217 | doCometSupport in org.atmosphere.cpr.AtmosphereServlet
| 1176 | doPost in ''
| 1162 | doGet . . . . in ''
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run . . . . . in ''
^ 662 | run in java.lang.Thread
| Error 2012-02-16 16:13:33,093 [http-bio-8080-exec-10] ERROR [/myApp].[StratosphereServlet] - Servlet.service() for servlet [StratosphereServlet] in context with path [/myApp] threw exception
Message: Not supported.
Line | Method
->> 126 | suspend in org.atmosphere.container.Servlet30CometSupport
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 90 | service in ''
| 1217 | doCometSupport in org.atmosphere.cpr.AtmosphereServlet
| 1176 | doPost in ''
| 1162 | doGet . . . . in ''
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run . . . . . in ''
^ 662 | run in java.lang.Thread
 
The console of Google Chrome shows the following messages:

Invoking executeWebSocket
:8080:1Unexpected response code: 501
jquery.atmosphere.js:957Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent).
jquery.atmosphere.js:957Websocket closed, wasClean: false
jquery.atmosphere.js:957Websocket failed. Downgrading to Comet and resending
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Invoking 1 callbacks
jquery.atmosphere.js:957Max re-connection reached.
jquery.atmosphere.js:957Invoking 1 callbacks

It's clear that the service is unavailable, but I can't figure out why the AtmosphereServlet stopped working when I upgraded Grails to the latest version.

My development environment is composed by the latest software versions: Grails 2.0.1, Groovy 1.8.4, Java 1.6, Atmosphere 0.4.2.1, Chrome 17.0.963.46, SpringSource Tool Suite 2.8.1.RELEASE.

Any help would be welcome.

Thanks in advance,

Guillermo
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Atmosphere plug-in not working in Grails 2.0.1

glalejos
Hello again,

My bet is that atmosphere is configured to use websocket in Grails 2.0, but Tomcat doesn't support this technology (https://issues.apache.org/bugzilla/show_bug.cgi?id=51181, usage of Tomcat is a requirement in our project). It seems that the previous version of the atmosphere Grails plug-in was configured to use comet by default, but the current isn't. Am I right?

So, how can I configure the atmosphere Grails plug-in to use comet?

Thanks very much,

Guillermo
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Atmosphere plug-in not working in Grails 2.0.1

smaldini
Hi

Can you provide some code ? The default behavior is :

*Atmosphere core scans your classpath to search for Servlet3, Tomcat7 Blocking/NIO, Glassfish etc.
*If you subscribe with jquery, use streaming / long-polling

You can also compare with the following sample to see if something has been missed :
https://github.com/smaldini/atmosphere-sample-grails2

Check list :
* Javascript subscription
* Enabled NIO connector (in BuildConfig)
* Force Tomcat7 support in AtmosphereConfig
* Servlet : tested with 2.5 (Servlet3 support is slightly different)
* Suspend() on request, write/flush() on stateChange, don't resume if you use streaming, resume if you use long-polling (will force a reconnect)

I will release soon a newer version of atmosphere with some goodies to help simple patterns and updated libraries.

Cheers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Atmosphere plug-in not working in Grails 2.0.1

glalejos
Hello smaldini,

Thanks for your answer.

I'm sorry I cannot provide any code. We have suspended migration tasks to Grails 2.0.1 since they have turn out to be more complex than expected. I'll keep you updated if we manage to solve this issue in the future.

Thanks again for your support.

Kind regards,

Guillermo
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Atmosphere plug-in not working in Grails 2.0.1

Ozren
In reply to this post by smaldini
Hi Stephane,

I'm having problems running your sample app. I'm testing it out of the box, with no changes being made to sample app. I've tested it with grails 2.0.0 and 2.0.1, on WinXP, Firefox 10.0.2 and Chrome 17.0.963.56.

When opening user list in firefox, I can see GET http://localhost:8080/atmo-sample2/atmosphere/sample?_=1330683419375 and spinner in console. Browser subscribes in regular intervals to atmosphere service:
2012-03-02 11:16:59,390 [http-nio-8080-exec-2] INFO  sample.SampleHandlerService  - onRequest, AtmosphereResourceImpl{, hasCode-263605858,
 action=org.atmosphere.cpr.AtmosphereServlet$Action@215571,
 broadcaster=org.atmosphere.cpr.DefaultBroadcaster,
 cometSupport=org.atmosphere.container.Tomcat7CometSupport@7090a8,
 serializer=null,
 isInScope=true,
 useWriter=true,
 listeners=[]}

When I create a user in another browser, this is logged to grails console:
2012-03-02 11:19:25,312 [http-nio-8080-exec-7] INFO  sample.UserController  - broadcasting
2012-03-02 11:19:25,343 [Atmosphere-AsyncWrite-0] INFO  sample.SampleHandlerService  - onStateChange, message: fsd : 1 created

However, response callback function is not called in first browser where user list is opened.

Any idea what might be the issue here?

Cheers
Ozren

P.S. I'm also adding startup log from grails console:

2012-03-02 11:13:04,906 [main] INFO  webxml.WebxmlGrailsPlugin  - Loading default config file: class DefaultWebXmlConfig
2012-03-02 11:13:04,937 [main] WARN  webxml.WebxmlGrailsPlugin  - Did not find application config file: WebXmlConfig
2012-03-02 11:13:05,406 [main] INFO  webxml.WebxmlGrailsPlugin  - Loading default config file: class DefaultWebXmlConfig
2012-03-02 11:13:05,406 [main] WARN  webxml.WebxmlGrailsPlugin  - Did not find application config file: WebXmlConfig
| Running Grails application
| Enabling Tomcat NIO connector
2012-03-02 11:13:06,281 [main] INFO  http11.Http11NioProtocol  - Initializing ProtocolHandler ["http-nio-8080"]
2012-03-02 11:13:06,359 [main] INFO  net.NioSelectorPool  - Using a shared selector for servlet write/read
2012-03-02 11:13:06,390 [main] INFO  core.StandardService  - Starting service Tomcat
2012-03-02 11:13:06,390 [main] INFO  core.StandardEngine  - Starting Servlet Engine: Apache Tomcat/7.0.25
2012-03-02 11:13:06,625 [pool-5-thread-1] INFO  startup.ContextConfig  - No global web.xml found
2012-03-02 11:13:07,109 [pool-5-thread-1] INFO  [localhost].[/atmo-sample2]  - Initializing Spring root WebApplicationContext
2012-03-02 11:13:11,281 [pool-5-thread-1] WARN  config.ConfigurationFactory  - No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the classpath: jar:file:/C:/Documents%20and%20Settings/Korisnik/.grails/ivy-cache/net.sf.ehcache/ehcache-core/jars/ehcache-core-2.4.6.jar!/ehcache-failsafe.xml
2012-03-02 11:13:12,890 [pool-5-thread-1] INFO  scaffolding.DefaultGrailsTemplateGenerator  - Scaffolding template generator set to use resource loader org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@d15e01: startup date [Fri Mar 02 11:13:10 CET 2012]; parent: Root WebApplicationContext
2012-03-02 11:13:14,515 [pool-5-thread-1] INFO  resource.ResourceProcessor  - Performing a full reload
2012-03-02 11:13:15,296 [pool-5-thread-1] INFO  resource.ResourceProcessor  - Loading resource declarations...
2012-03-02 11:13:15,296 [pool-5-thread-1] INFO  resource.ResourceProcessor  - Forgetting all known modules...
2012-03-02 11:13:15,312 [pool-5-thread-1] INFO  resource.ResourceProcessor  - Forgetting all known resources...
2012-03-02 11:13:15,734 [pool-5-thread-1] WARN  module.ModuleDeclarationsFactory  - 'grails.resources.modules' in config does not define any modules
2012-03-02 11:13:18,109 [pool-5-thread-1] WARN  util.GrailsUtil  - [DEPRECATED] Method ConfigurationHolder.getConfig() is deprecated and will be removed in a future version of Grails.
2012-03-02 11:13:18,171 [pool-5-thread-1] WARN  util.GrailsUtil  - [DEPRECATED] Method ApplicationHolder.getApplication() is deprecated and will be removed in a future version of Grails.
2012-03-02 11:13:18,187 [pool-5-thread-1] WARN  util.GrailsUtil  - [DEPRECATED] Method ApplicationHolder.getApplication() is deprecated and will be removed in a future version of Grails.
2012-03-02 11:13:18,281 [pool-5-thread-1] INFO  context.GrailsConfigUtils  - [GrailsContextLoader] Grails application loaded.
2012-03-02 11:13:18,531 [pool-5-thread-1] INFO  cpr.AtmosphereServlet  - Using BroadcasterFactory class: org.atmosphere.cpr.DefaultBroadcasterFactory
2012-03-02 11:13:18,609 [pool-5-thread-1] INFO  cpr.AtmosphereServlet  - Installed AtmosphereHandler com.odelia.grails.plugins.atmosphere.GrailsHandler mapped to context-path: /atmosphere/sample
2012-03-02 11:13:18,625 [pool-5-thread-1] INFO  cpr.AtmosphereServlet  - Atmosphere is using async support: org.atmosphere.container.Tomcat7CometSupport running under container: Apache Tomcat/7.0.25
2012-03-02 11:13:18,625 [pool-5-thread-1] INFO  cpr.AtmosphereServlet  - Using broadcaster class: org.atmosphere.cpr.DefaultBroadcaster
2012-03-02 11:13:18,625 [pool-5-thread-1] INFO  cpr.AtmosphereServlet  - Atmosphere Framework 0.8.4 started.
2012-03-02 11:13:18,625 [pool-5-thread-1] INFO  [localhost].[/atmo-sample2]  - Initializing Spring FrameworkServlet 'grails'
2012-03-02 11:13:18,687 [main] INFO  http11.Http11NioProtocol  - Starting ProtocolHandler ["http-nio-8080"]
| Server running. Browse to http://localhost:8080/atmo-sample2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Atmosphere plug-in not working in Grails 2.0.1

genuinefafa
In reply to this post by glalejos
Are you running grails command line or inside a Tomcat7?

If grails run-app, you need to enable nio connector in BuildConfig.groovy - http://grails.org/plugin/tomcat
If Tomcat7, you should use protocol NIO but there are some limitations - https://github.com/Atmosphere/atmosphere/wiki/WebServer-Issues

If you are using the "old" version of the plugin, remember that Tomcat 7 is bundle with Grails 2.x so you need to use the latest version of atmosphere 0.9+

Loading...