Revision: 2de0135faaf8
Author:   Jean Deruelle <[email protected]>
Date:     Fri Feb 14 21:54:59 2014 UTC
Log: Update Issue 257 Fixing exceptions happening on deploying directory containing META-INF/context.xml

(cherry picked from commit 8a7690918b23c510ad3ca59515171a04d29e5ea8)

Conflicts:
containers/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipStandardContext.java

http://code.google.com/p/sipservlets/source/detail?r=2de0135faaf8

Modified:
/containers/sip-servlets-catalina-7/src/main/java/org/mobicents/servlet/sip/catalina/SipHostConfig.java /containers/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipStandardContext.java

=======================================
--- /containers/sip-servlets-catalina-7/src/main/java/org/mobicents/servlet/sip/catalina/SipHostConfig.java Tue Mar 27 15:02:55 2012 UTC +++ /containers/sip-servlets-catalina-7/src/main/java/org/mobicents/servlet/sip/catalina/SipHostConfig.java Fri Feb 14 21:54:59 2014 UTC
@@ -28,6 +28,7 @@
 import java.util.jar.JarFile;

 import org.apache.catalina.Context;
+import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.startup.HostConfig;
 import org.apache.catalina.util.ContextName;
 import org.apache.log4j.Logger;
@@ -97,9 +98,17 @@
         File war = new File(appBase, baseName + ".war");
         if (war.exists()) {
                boolean isSipServletApplication = isSipServletArchive(war);
-            if(isSipServletApplication) {
+            if(isSipServletApplication) {
+                if(logger.isDebugEnabled()) {
+ logger.debug(SipContext.APPLICATION_SIP_XML + " found in " + + baseName + ". Enabling sip servlet archive deployment");
+                }
                deploySAR(cn, war);
             } else {
+                if(logger.isDebugEnabled()) {
+ logger.debug(SipContext.APPLICATION_SIP_XML + " not found in " + + baseName + ". Not Enabling sip servlet archive deployment");
+                }
                deployWAR(cn, war);
             }
             return;
@@ -117,7 +126,7 @@
        }

        /**
-        *
+        *
         * @param NAME
         * @param sar
         * @param string
@@ -126,7 +135,7 @@
                if (deploymentExists(cn.getName()))
             return;
                if(logger.isDebugEnabled()) {
-               logger.debug(SipContext.APPLICATION_SIP_XML + " found in "
+               logger.debug(SipContext.APPLICATION_SIP_XML + " found in "
                                + sar + ". Enabling sip servlet archive 
deployment");
        }
                String initialConfigClass = configClass;
@@ -142,9 +151,9 @@

        @Override
        protected void deployWAR(ContextName cn, File dir) {
-               if(logger.isTraceEnabled()) {
- logger.trace("Context class used to deploy the WAR : " + contextClass); - logger.trace("Context config class used to deploy the WAR : " + configClass);
+               if(logger.isDebugEnabled()) {
+ logger.debug("Context class used to deploy the WAR : " + contextClass); + logger.debug("Context config class used to deploy the WAR : " + configClass);
        }
                super.deployWAR(cn, dir);
        }
@@ -170,6 +179,17 @@
                        configClass = initialConfigClass;
                contextClass = initialContextClass;
                } else {
+            if(logger.isDebugEnabled()) {
+ logger.debug(SipContext.APPLICATION_SIP_XML + " not found in " + + dir + ". Not Enabling sip servlet archive deployment");
+            }
+ // https://code.google.com/p/sipservlets/issues/detail?id=257 make sure the digester to parse directories
+            // containing META-INF/context.xml is the correct one
+            digester = createDigester(StandardContext.class.getName());
+            if(logger.isDebugEnabled()) {
+ logger.debug("Context class used to deploy the directory : " + contextClass); + logger.debug("Context config class used to deploy the directory : " + configClass);
+            }
                        super.deployDirectory(cn, dir);
                }
        }
@@ -193,6 +213,10 @@
             File dir = new File(appBase, files[i]);
             boolean isSipServletApplication = isSipServletArchive(dir);
             if(isSipServletApplication) {
+                if(logger.isDebugEnabled()) {
+ logger.debug(SipContext.APPLICATION_SIP_XML + " found in " + + files[i] + ". Enabling sip servlet archive deployment");
+                }
                ContextName cn = new ContextName(files[i]);
                 // Calculate the context path and make sure it is unique
 //                String contextPath = "/" + files[i];
@@ -214,7 +238,13 @@
                 host.setConfigClass(initialConfigClass);
                 configClass = initialConfigClass;
                 contextClass = initialContextClass;
-            }
+            } else {
+                if(logger.isDebugEnabled()) {
+ logger.debug(SipContext.APPLICATION_SIP_XML + " not found in " + + files[i] + ". Not Enabling sip servlet archive deployment");
+                }
+                setContextClass(StandardContext.class.getName());
+            }
         }
         super.deployWARs(appBase, files);
        }
=======================================
--- /containers/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipStandardContext.java Fri Jul 27 12:50:42 2012 UTC +++ /containers/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipStandardContext.java Fri Feb 14 21:54:59 2014 UTC
@@ -200,8 +200,9 @@
        @Override
        public void initInternal() throws LifecycleException {
                if(logger.isInfoEnabled()) {
-                       logger.info("Initializing the sip context");
+                       logger.info("Initializing the sip context " + 
getName());
                }
+
 //             if (this.getParent() != null) {
 //                     // Add the main configuration listener for sip 
applications
 //                     LifecycleListener sipConfigurationListener = new 
SipContextConfig();
@@ -218,7 +219,7 @@
                prepareServletContext();

                if(logger.isInfoEnabled()) {
-                       logger.info("sip context Initialized");
+                       logger.info("sip context Initialized " + getName());
                }
        }

@@ -282,7 +283,7 @@
        @Override
        public synchronized void startInternal() throws LifecycleException {
                if(logger.isInfoEnabled()) {
-                       logger.info("Starting the sip context");
+                       logger.info("Starting the sip context " + getName());
                }
 //             if( this.getState().equals(LifecycleState.INITIALIZED)) {
                        prepareServletContext();
@@ -448,11 +449,11 @@
logger.info("sip application session timeout for this context is " + sipApplicationSessionTimeout + " minutes");
                        }
                        if(logger.isInfoEnabled()) {
-                               logger.info("sip context started");
+                               logger.info("sip context started " + getName());
                        }
                } else {
                        if(logger.isInfoEnabled()) {
-                               logger.info("sip context didn't started due to 
errors");
+                               logger.info("sip context didn't started due to 
errors " + getName());
                        }
                }
        }

--

--- You received this message because you are subscribed to the Google Groups "mobicents-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to