1

I'm working on my first GWT-based Java project for a school assignment. It's a chat application and the client polls the server for new events, while the server keeps an timer for each user to detect inactivity.

The following problem occurs at runtime:

Dec 8, 2009 7:41:17 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: /GAEChat/chat
java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:151)
    at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkAccess(DevAppServerFactory.java:176)
    at java.lang.ThreadGroup.checkAccess(Unknown Source)
    at java.lang.Thread.init(Unknown Source)
    at java.lang.Thread.<init>(Unknown Source)
    at java.util.TimerThread.<init>(Unknown Source)
    at java.util.Timer.<init>(Unknown Source)
    at java.util.Timer.<init>(Unknown Source)
    at gaechat.server.ChatServiceImpl.<init>(ChatServiceImpl.java:22)
    at sun.reflect.GeneratedConstructorAccessor14.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
    at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:463)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
    at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:121)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
    at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:352)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
    at org.mortbay.jetty.Server.handle(Server.java:313)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:844)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
    at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)

Here's the code repository. The problem seems to be in server/ChatServiceImpl.java.

Am I doing something wrong? I'm stuck.

antony.trupe
  • 10,640
  • 10
  • 57
  • 84
Dan
  • 9,912
  • 18
  • 49
  • 70

2 Answers2

2

As this is a school assignment try disabling the SecurityManager first.

Updated: It should be disabled unless you had a -Djava.security.manager set somewhere. See How to disable Java security manager?

BTW, you might be interested in this link ;) The page has the source code available for download.

Community
  • 1
  • 1
Iker Jimenez
  • 7,105
  • 9
  • 49
  • 46
  • Thanks for pointing me to the book. Seems like a wonderful resource! Now if I can only figure out how to disable the SecurityManager... :) – Dan Dec 08 '09 at 20:24
  • Are you getting that error when running in hosted mode? have you tried deploying the war folder in a standard tomcat installation to see if you are still getting the same error? – Iker Jimenez Dec 08 '09 at 20:31
  • Thanks for all the help. I've temporarily commented out the part with the timer so I can get something done. I will try to disable the security manager when I bring the inactivity timer back. – Dan Dec 08 '09 at 20:34
  • 1
    For extra points on your assignment instead of just sending a request every X seconds have a look at http://en.wikipedia.org/wiki/Push_technology#Long_polling I believe it is being used in the application I linked you before, it might be called hanging RPC request or something similar. – Iker Jimenez Dec 08 '09 at 20:49
0

If you are trying to run the servlet application on Google App Engine, which the stack trace seems to show that you are, then you cannot create new threads. App Engine does not allow it.

Luke
  • 931
  • 7
  • 4