I am trying to create a chat application using grails. I am using grails 3.0.9 and tomcat-8.0.28
Sorry for the duplicate
I read this question and this ... but this does not solve my problem.
I am already modifying javax.websocket-api so that it is:
provided 'javax.websocket:javax.websocket-api:1.0'
but I still get this error:
Firefox : Firefox cannot establish a connection to the server at http://103.56.148.50/chat/chatEndPoint/C001D939F2564251C86E646B9127495D "
Chrome : WebSocket handshake error: Unexpected response code: 404
you can see this site ...
this is my code
package com.akiong import grails.util.Environment import grails.util.Holders import javax.servlet.ServletContext import javax.servlet.ServletContextEvent import javax.servlet.ServletContextListener import javax.servlet.annotation.WebListener import javax.websocket.EndpointConfig import javax.websocket.OnClose import javax.websocket.OnError import javax.websocket.OnMessage import javax.websocket.OnOpen import javax.websocket.Session import javax.websocket.server.PathParam import javax.websocket.server.ServerContainer import javax.websocket.server.ServerEndpoint import com.akiong.services.ChatService import javax.websocket.EncodeException
this is in javascript
var wsUri = "ws://103.56.148.50/chat/chatEndPoint/"+room; var webSocket = new WebSocket(wsUri); webSocket.onopen = function(message) {OnOpen(message);}; webSocket.onclose = function(message) {OnClose(message);}; webSocket.onerror = function(message) {OnError(message);}; webSocket.onmessage = function(message) {OnMessage(message);}; function OnOpen(message){ console.log("Open Socket"); } function OnClose(message){ console.log("Close = "+message); webSocket.close(); } function OnError(message){ console.log("ERROR = "+message); } function OnMessage(message){ webSocket.send("success"); }
these are my dependencies in the build.gradle file
dependencies { compile "org.springframework.boot:spring-boot-starter-logging" compile "org.springframework.boot:spring-boot-starter-actuator" compile "org.springframework.boot:spring-boot-autoconfigure" provided "org.springframework.boot:spring-boot-starter-tomcat" compile "org.grails:grails-dependencies" compile "org.grails:grails-web-boot" compile "org.grails.plugins:hibernate" compile "org.grails.plugins:cache" compile "org.hibernate:hibernate-ehcache" compile "org.grails.plugins:scaffolding" runtime "org.grails.plugins:asset-pipeline" testCompile "org.grails:grails-plugin-testing" testCompile "org.grails.plugins:geb" console "org.grails:grails-console" //-----------------------------------here i add my code------------------- compile 'org.grails.plugins:spring-security-core:3.0.0.M1' runtime 'mysql:mysql-connector-java:5.1.20' compile "org.grails.plugins:mail:2.0.0.RC2" compile 'org.grails.plugins:jms:2.0.0.M1' //http://gpc.imtqy.com/jms/snapshot/guide/introduction.html runtime 'org.apache.activemq:activemq-spring:5.11.1' provided 'javax.websocket:javax.websocket-api:1.0' }
==================================================== ==================
I tried to run: grails prod run-app
my websocket is not working ...
but it works if I run grails run-app
is that since ServerEndPointDemo.groovy am I placed in /src/main/groovy/com.akiong/ServerEndPointDemo.groovy ?
==================================================== ==============================
I get this error after removing if (Environment.current == Environment.DEVELOPMENT)
Configuring Spring Security Core ... ... finished configuring Spring Security Core anc Environment.current = PRODUCTION Environment.DEVELOPMENT = DEVELOPMENT Environment.current = PRODUCTION Environment.DEVELOPMENT = DEVELOPMENT 26-Nov-2015 23:29:40.407 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file 26-Nov-2015 23:29:40.420 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors 26-Nov-2015 23:29:40.769 SEVERE [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [org.grails.web.converters.configuration.ConvertersConfigurationHolder$2] (value [org.grai ls.web.converters.configuration.ConvertersConfigurationHolder$2@ 5ce7a180]) and a value of type [java.util.HashMap] (value [{}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. 26-Nov-2015 23:29:40.794 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /root/apache-tomcat-8.0.28/webapps/ROOT.war has finished in 94,084 ms 26-Nov-2015 23:29:40.796 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-80"] 26-Nov-2015 23:29:40.802 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"] 26-Nov-2015 23:29:40.803 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 94281 ms