glassfish
  1. glassfish
  2. GLASSFISH-20932

Error occurs when default-web-module is set.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.1
    • Fix Version/s: 4.1.1
    • Component/s: web_container
    • Labels:
      None
    • Environment:

      Description

      Reproducible operational steps:

      1) deploy a web application e.g. HelloServlet.war
      asadmin deploy c:\tmp\HelloServlet.war
      Application deployed with name HelloServlet.
      Command deploy executed successfully.

      2) set default-web-module to HelloServlet
      asadmin set server.http-service.virtual-server.server.default-web-module=HelloServlet
      server.http-service.virtual-server.server.default-web-module=HelloServlet
      Command set executed successfully.

      3) set http-listener-1.http.max-post-size-bytes
      asadmin set server.network-config.protocols.protocol.http-listener-1.http.max-post-size-bytes=2000
      server.network-config.protocols.protocol.http-listener-1.http.max-post-size-bytes=2000
      Command set executed successfully.

      4) error occurs in server.log

      [2013-12-17T16:29:08.916+1100] [glassfish 4.0] [SEVERE] [AS-WEB-GLUE-00115] [javax.enterprise.web] [tid: _ThreadID=145 _ThreadName=pool-50-thread-1] [timeMillis: 1387258148916] [levelValue: 1000] [[
      Exception processing HttpService configuration change
      org.apache.catalina.LifecycleException: java.lang.Exception: No context matching /HelloServlet deployed on virtual server server
      at com.sun.enterprise.web.WebContainer.updateDefaultWebModule(WebContainer.java:2340)
      at com.sun.enterprise.web.WebContainer.updateHost(WebContainer.java:3157)
      at com.sun.enterprise.web.reconfig.WebConfigListener$1.changed(WebConfigListener.java:156)
      at org.jvnet.hk2.config.ConfigSupport.sortAndDispatch(ConfigSupport.java:331)
      at com.sun.enterprise.web.reconfig.WebConfigListener.changed(WebConfigListener.java:132)
      at org.jvnet.hk2.config.Transactions$ConfigListenerJob.process(Transactions.java:400)
      at org.jvnet.hk2.config.Transactions$ConfigListenerJob.process(Transactions.java:390)
      at org.jvnet.hk2.config.Transactions$ConfigListenerNotifier$1$1.call(Transactions.java:280)
      at org.jvnet.hk2.config.Transactions$ConfigListenerNotifier$1$1.call(Transactions.java:278)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      at java.util.concurrent.FutureTask.run(FutureTask.java:166)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:722)
      Caused by: java.lang.Exception: No context matching /HelloServlet deployed on virtual server server
      at org.glassfish.grizzly.http.server.util.Mapper.addDefaultContext(Mapper.java:791)
      at org.glassfish.grizzly.http.server.util.Mapper.setDefaultContextPath(Mapper.java:755)
      at com.sun.enterprise.web.WebContainer.updateDefaultWebModule(WebContainer.java:2332)
      ... 13 more
      ]]

      5) get http-listener-1.http.max-post-size-bytes
      asadmin get server.network-config.protocols.protocol.http-listener-1.http.max-post-size-bytes
      server.network-config.protocols.protocol.http-listener-1.http.max-post-size-bytes=2000
      Command get executed successfully.

        Activity

        Hide
        jifeng added a comment - - edited

        Hi
        Shing Wai Chan
        xianwu

        After a few investigation about the source, I found the exact precise place where the failure happens:

        org.glassfish.grizzly.http.server.util.Mapper
        private void addDefaultContext(Host host, String defaultContextPath)
                    throws Exception {
        
                boolean defaultContextFound = false;
        
                Context[] contexts = host.contextList.contexts;
        
                if (contexts != null) {
                    for (Context context1 : contexts) {
                        if (context1.name.equals(defaultContextPath)) {
                            host.defaultContexts[0] = context1;
                            defaultContextFound = true;
                            break;
                        }
                    }
                }
        
                if (!defaultContextFound) {
                    throw new Exception("No context matching " + defaultContextPath
                                        + " deployed on virtual server "
                                        + host.name);★
                }
            }
        
        

        I have debuged the 'Mapper' class and found the [context.name] object has never been valued。

        The [context.name] object's initialization processing as follows:

        package com.sun.enterprise.v3.services.impl.ContainerMapper
        private final static String ROOT = "";★
        protected void configureMapper() {
            ......
            try {
            ....
                 mapper.addContext(defaultHostName, ROOT★,
                            new ContextRootInfo(this, null),
                            new String[]{"index.html", "index.htm"}, null);
            ....
                } finally {
                    mapperLock.writeLock().unlock();
                }
        }
        

        org.glassfish.grizzly.http.server.util.Mapper
        public void addContext
                    (String hostName, String path★, Object context,
                    String[] welcomeResources, NamingContext resources,
                    List<AlternateDocBase> alternateDocBases) {
            ......
            newContext.name = path;★//the [context.name] object's 
                                     //value always equals to ""
            ......
         }
        
        Show
        jifeng added a comment - - edited Hi Shing Wai Chan xianwu After a few investigation about the source, I found the exact precise place where the failure happens: org.glassfish.grizzly.http.server.util.Mapper private void addDefaultContext(Host host, String defaultContextPath) throws Exception { boolean defaultContextFound = false ; Context[] contexts = host.contextList.contexts; if (contexts != null ) { for (Context context1 : contexts) { if (context1.name.equals(defaultContextPath)) { host.defaultContexts[0] = context1; defaultContextFound = true ; break ; } } } if (!defaultContextFound) { throw new Exception( "No context matching " + defaultContextPath + " deployed on virtual server " + host.name);★ } } I have debuged the 'Mapper' class and found the [context.name] object has never been valued。 The [context.name] object's initialization processing as follows: package com.sun.enterprise.v3.services.impl.ContainerMapper private final static String ROOT = "";★ protected void configureMapper() { ...... try { .... mapper.addContext(defaultHostName, ROOT★, new ContextRootInfo( this , null ), new String []{ "index.html" , "index.htm" }, null ); .... } finally { mapperLock.writeLock().unlock(); } } ⇣ org.glassfish.grizzly.http.server.util.Mapper public void addContext ( String hostName, String path★, Object context, String [] welcomeResources, NamingContext resources, List<AlternateDocBase> alternateDocBases) { ...... newContext.name = path;★ //the [context.name] object's //value always equals to "" ...... }
        Hide
        jifeng added a comment -

        Hi
        Shing Wai Chan
        xianwu

        I modify the following code, it works fine,could you please confirm it and give me some suggestions?

        package com.sun.enterprise.v3.services.impl.ContainerMapper
        @@ -69,6 +69,8 @@
         import org.glassfish.grizzly.http.util.MimeType;
         import org.glassfish.internal.grizzly.ContextMapper;
         import org.glassfish.kernel.KernelLoggerInfo;
        +import com.sun.enterprise.config.serverbeans.ConfigBeansUtilities;
        +import com.sun.enterprise.config.serverbeans.VirtualServer;
         
         /**
          * Container's mapper which maps {@link ByteBuffer} bytes representation to an  {@link HttpHandler}, {@link
        @@ -148,7 +150,7 @@
                 try {
                     mapper.setDefaultHostName(defaultHostName);
                     mapper.addHost(defaultHostName, new String[]{}, null);
        -            mapper.addContext(defaultHostName, ROOT,
        +            mapper.addContext(defaultHostName, getContextRoot(),
                             new ContextRootInfo(this, null),
                             new String[]{"index.html", "index.htm"}, null);
                     // Container deployed have the right to override the default setting.
        @@ -157,7 +159,29 @@
                     mapperLock.writeLock().unlock();
                 }
             }
        -
        +    
        +    private String getContextRoot() {
        +        String defaultWebModule = null;
        +        String contextRoot = null;
        +        Collection<VirtualServer> list = grizzlyService.getHabitat().getAllServices(VirtualServer.class);
        +        ConfigBeansUtilities cbu = grizzlyService.getHabitat().getService(ConfigBeansUtilities.class);
        +        for (VirtualServer virtualServer : list) {
        +            if (virtualServer.getId().equals(defaultHostName)) {
        +                defaultWebModule = virtualServer.getDefaultWebModule();
        +                if (cbu == null) {
        +                    contextRoot = null;
        +                }
        +                else {
        +                    if (defaultWebModule != null) {
        +                        contextRoot = cbu.getContextRoot(defaultWebModule);
        +                    }
        +                }
        +                break;
        +            }
        +        }
        +        return contextRoot == null ?ROOT:contextRoot;
        +    }
        +   
        
        Show
        jifeng added a comment - Hi Shing Wai Chan xianwu I modify the following code, it works fine,could you please confirm it and give me some suggestions? package com.sun.enterprise.v3.services.impl.ContainerMapper @@ -69,6 +69,8 @@ import org.glassfish.grizzly.http.util.MimeType; import org.glassfish.internal.grizzly.ContextMapper; import org.glassfish.kernel.KernelLoggerInfo; + import com.sun.enterprise.config.serverbeans.ConfigBeansUtilities; + import com.sun.enterprise.config.serverbeans.VirtualServer; /** * Container's mapper which maps {@link ByteBuffer} bytes representation to an {@link HttpHandler}, {@link @@ -148,7 +150,7 @@ try { mapper.setDefaultHostName(defaultHostName); mapper.addHost(defaultHostName, new String []{}, null ); - mapper.addContext(defaultHostName, ROOT, + mapper.addContext(defaultHostName, getContextRoot(), new ContextRootInfo( this , null ), new String []{ "index.html" , "index.htm" }, null ); // Container deployed have the right to override the default setting. @@ -157,7 +159,29 @@ mapperLock.writeLock().unlock(); } } - + + private String getContextRoot() { + String defaultWebModule = null ; + String contextRoot = null ; + Collection<VirtualServer> list = grizzlyService.getHabitat().getAllServices(VirtualServer.class); + ConfigBeansUtilities cbu = grizzlyService.getHabitat().getService(ConfigBeansUtilities.class); + for (VirtualServer virtualServer : list) { + if (virtualServer.getId().equals(defaultHostName)) { + defaultWebModule = virtualServer.getDefaultWebModule(); + if (cbu == null ) { + contextRoot = null ; + } + else { + if (defaultWebModule != null ) { + contextRoot = cbu.getContextRoot(defaultWebModule); + } + } + break ; + } + } + return contextRoot == null ?ROOT:contextRoot; + } +
        Hide
        oleksiys added a comment -

        IMO ContainerMapper has nothing to do with the problem. I think the problem occurs because WebContainer tries to set default web module even before this module is registered/deployed in the Mapper. The registration sequence has to be fixed in WebContainer.

        Show
        oleksiys added a comment - IMO ContainerMapper has nothing to do with the problem. I think the problem occurs because WebContainer tries to set default web module even before this module is registered/deployed in the Mapper. The registration sequence has to be fixed in WebContainer.
        Hide
        bradvido added a comment -

        I have this problem as well in 4.1.
        I have a virtual server set up with a default web module defined. Whenever I update the settings for the network-listener that the virtual server uses, I get the same error. Moreover, the server becomes unresponsive and starts returning zero-length responses for all HTTP requests. Only a restart fixes it.

        Show
        bradvido added a comment - I have this problem as well in 4.1. I have a virtual server set up with a default web module defined. Whenever I update the settings for the network-listener that the virtual server uses, I get the same error. Moreover, the server becomes unresponsive and starts returning zero-length responses for all HTTP requests. Only a restart fixes it.
        Hide
        Arindam Bandyopadhyay added a comment -

        Committed in trunk/main
        Sending appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebContainer.java
        Transmitting file data .
        Committed revision 63862.

        Show
        Arindam Bandyopadhyay added a comment - Committed in trunk/main Sending appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebContainer.java Transmitting file data . Committed revision 63862.

          People

          • Assignee:
            Arindam Bandyopadhyay
            Reporter:
            xianwu
          • Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: