Gregor,

Thanks, A LOT ! ... really

A whole new world now makes sense to me.
Any way, from an arch point of view what I was trying to do wasn't the
best idea. But as I saw this problem I decided to understand what was
going on.

And it is now clear.

Thank you again.

On Jan 2, 1:42 pm, gregor <[email protected]> wrote:
> Hi David,
>
> Each web application is assigned its own classloader. Because you are
> running two different applications that use two different classloaders
> that each instantiate a separate version of UselessClass. Only one of
> them (the non-GWT one) is updating its version of UselessClass.
>
> I don't know what you are actually trying to do here but you should be
> aware that sharing a resource like that between two different web
> applications deployed on your server is not straight forward and
> unless you know what you are doing you will get unexpected results (as
> is the case here). A quick fix that might work is to put UselessClass
> in a jar that lives in the app servers global lib directory and remove
> it from your applications wars. Even if that did work, it is a dodgy
> not-recommended approach.
>
> Application servers have various mechanisms available for this sort of
> thing, in JBoss for instance you might use an MBean, or if
> UselessClass is just a marker for some substantial resource, you could
> consider using a Resource Archive (RAR) for the real thing. I would
> consult Jetty docs and forums about this.
>
> regards
> gregor
>
> On Jan 2, 3:20 pm, hofmanndavid <[email protected]> wrote:
>
> > 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 
> > projecthttp://hofmanndavid.googlepages.com/TestModule.war//compiled war of
> > the GWT modulehttp://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.jarhttp://localhost:8081/ServletTest/http://localhost:8081/TestModule/Te...
> > -----------------
> > 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