I don't even know how to name this discusion,
I am sorry if my english is not enough to explain this problem

I have a gwt rpc service in one module that just return the size of a
static final concurrenthashmap for showing it in the webpage.
I have the same functional thing done in a manual servlet that I've
configured in jetty.
And in the console, from the mains end part, a while that also prints
the value staticmap.keyset.size.

Somehow, the value that the rcp serverside implementation thread can
see is always zero. Behaves like if a fork have been done and no value
updates can be seen from the other processes.

Please, just see the code or execute the code I posted, you'll
immediately see the problem

Please help me to understand this problem, here are links of the
eclipse project zipped, and the runnable jars that you can try out of
the box.

Thanks for your help in advance.

--------------------------------
Tested on jre 1.5u16 and 1.6u10
1.5.3 version of GWT
6.1.11 version of Jetty
--------------------------------
http://hofmanndavid.googlepages.com/TestProject.zip // Eclipse 3.4
generated project
http://hofmanndavid.googlepages.com/TestModule.war // compiled war of
the GWT module
http://hofmanndavid.googlepages.com/TestProject.jar  // runnableJar
that deploys the war and exposes one sevlet and the other stuff showed
in MainTest.main(...)

put TestProject.jar and Module.war in the same directory and
java -jar TestProject.jar
http://localhost:8081/ServletTest/
http://localhost:8081/TestModule/TestModule.html
-----------------
Involved clases ...
-----------------
public class ServerSideImpl extends RemoteServiceServlet implements
ServerSide {

   public String getListSize() {
      System.out.println("from servlet !! problematicMap.keySet().size
() = "+ UselessClass.problematicMap.keySet().size());
      return "problematicMap.keySet().size() = "+
UselessClass.problematicMap.keySet().size();
   }
}
----------------
public class ServletTest extends HttpServlet {
      public ServletTest() {
         super();
      }
      @Override
      protected void doGet(HttpServletRequest req, HttpServletResponse
resp) throws ServletException, IOException {
         resp.setContentType("text/html");
         resp.setStatus(HttpServletResponse.SC_OK);
         resp.getWriter().println("<h1>Hello SimpleServlet</h1>");
         resp.getWriter().println("session="+req.getSession(true).getId
());
         resp.getWriter().println("problematicMap.keySet().size() = "
+ UselessClass.problematicMap.keySet().size());
      }
   }
---------------
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class UselessClass {

   public static final Map<String, String> problematicMap = new
ConcurrentHashMap<String, String>();

}
-------------
public class MainTest {

   public static void main(String[] args) throws Exception {

      new Thread() {
         @Override
         public void run() {
            while (true) {
               UselessClass.problematicMap.put(System.currentTimeMillis
() + "", System.currentTimeMillis() + "");

               try {
                  Thread.sleep(3000L);
               } catch (InterruptedException e) {
               }
            }
         }
      }.start();

      Server server = new Server(8081);

      WebAppContext webapp = new WebAppContext();
      webapp.setContextPath("/TestModule");
      webapp.setWar("TestModule.war");
      server.addHandler(webapp);

      Context context = new Context(Context.SESSIONS);
      context.setContextPath("/ServletTest");
      context.addServlet(new ServletHolder(new ServletTest()), "/*");
      server.addHandler(context);

      server.start();

      while (true) {
         Thread.sleep(2000L);
         System.out.println("problematicMap.keySet().size() = " +
UselessClass.problematicMap.keySet().size());
      }

   }
}
------------------------


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to