L
-

                 Key: STR-3103
                 URL: https://issues.apache.org/struts/browse/STR-3103
             Project: Struts 1
          Issue Type: Bug
    Affects Versions: 1.3.8
         Environment: Windows XP
            Reporter: Dmitry Rubenchik


I load my InitSrvlet through WEB.xml to perform an app initialization from 
property files. Once this servlet is loaded, it effects struts global exception 
handling.
Defined global exceptions are not caught by struts framework. If I would 
disable load of the servlet, global exceptions are handled normally. Please let 
me know what could be a cause for this behavior.

WEB.xml fragment:
<servlet>
                <servlet-name>action</servlet-name>
                <servlet-class>
                        org.apache.struts.action.ActionServlet
                </servlet-class>
                <init-param>
                        <param-name>config</param-name>
                        <param-value>/WEB-INF/struts-config.xml</param-value>
                </init-param>
                <init-param>
                        <param-name>debug</param-name>
                        <param-value>2</param-value>
                </init-param>
                <init-param>
                        <param-name>detail</param-name>
                        <param-value>2</param-value>
                </init-param>
                <init-param>
                        <param-name>validate</param-name>
                        <param-value>true</param-value>
                </init-param>
                <load-on-startup>2</load-on-startup>
        </servlet>
        <servlet>
                <servlet-name>InitSrvlt</servlet-name>
                <servlet-class>
                com.ubs.fcm.servlets.InitSrvlt</servlet-class>
                <init-param>
                        <param-name>configFileName</param-name>
                        
<param-value>/apps/WasApps/FCM/FCMSystem/properties/log4j.properties</param-value>
                </init-param>
                <load-on-startup>-1</load-on-startup>
        </servlet>
        <servlet-mapping>
                <servlet-name>action</servlet-name>
                <url-pattern>*.do</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
                <servlet-name>InitSrvlt</servlet-name>
                <url-pattern>/InitSrvlt</url-pattern>
        </servlet-mapping>



InitSrvlet.java:

package com.ubs.fcm.servlets;



import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Properties;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import com.pwj.fwa.log4j.PwLoggingConfigurator;
import com.pwj.fwa.log4j.PwLoggingSubLevel;
import com.ubs.fcm.common.ConfigFCM;
//import com.ubs.fcm.exceptions.*;
import com.ubs.fcm.log.Log;


/**
 * @version     1.0
 * @author
 */
public class InitSrvlt extends HttpServlet implements Servlet {
        

        /**
        * @see javax.servlet.GenericServlet#void ()
        */
        public void init(ServletConfig config) throws ServletException {        
        
                
                // Setting pwlog init parameters
                
                
                String configFileName=null;
                try { 
                        configFileName = (String)(new 
javax.naming.InitialContext()).lookup("java:comp/env/LOG4J_SOURCE"); 
                } catch (Exception e) {
                        e.printStackTrace(System.err);             
                }
                String rootLogDir = null;
        
                InputStream logPropsFile;
                Properties logProp = new Properties();
                try {
                        logPropsFile = new FileInputStream(configFileName);
                
                        logProp.load(logPropsFile);
                        logPropsFile.close();
                        
                        Enumeration enLogProps = logProp.propertyNames(); 
                        String logKey;
                        while ( enLogProps.hasMoreElements() ) {
                                logKey = (String) enLogProps.nextElement();
                                try{    
                                        if(logKey.equals("ROOT_LOG_DIR")){ 
                                                
rootLogDir=logProp.getProperty(logKey);
                                        }
                                }
                                catch(NumberFormatException e){ 
                                        e.printStackTrace(System.err);          
                        
                                        throw e;
                                }               
                        }
                } catch (IOException e) {
                        e.printStackTrace(System.err);                  
                }
                
                PwLoggingConfigurator pwLog = 
PwLoggingConfigurator.getInstance(config);
                pwLog.setLogFileName(rootLogDir);
                
                if (Log.loggerDebug.isDebugEnabled())
                        Log.loggerDebug.debug("InitSrvlt.init(): PwLoggin 
initialized successfully ", PwLoggingSubLevel.DEBUG);
                        
                super.init(config);
                
                InputStream propsFile;
                Properties prop = new Properties();     
                
                
                
                try { 
                        try { 
                                ConfigFCM.setAppPropPath((String)(new 
javax.naming.InitialContext()).lookup("java:comp/env/CONFIG_SOURCE")); 
                        } catch (Exception e) {                         
                                Log.loggerError.error("InitSrvlt.init(): Error 
retrieving environment variable java:comp/env/CONFIG_SOURCE.", 
PwLoggingSubLevel.NONE);
                        }
                        
                        propsFile = new 
FileInputStream(ConfigFCM.getAppPropPath());
                        
                        //Throw an application exception if results were not 
found.
                        //if (propsFile == null) {
                                //throw new 
ConfigurationFileNotFoundException();
                        //}
                        
                        prop.load(propsFile);
                        propsFile.close();
                        Enumeration enProps = prop.propertyNames(); 
                        String key;
                        while ( enProps.hasMoreElements() ) {
                                key = (String) enProps.nextElement();
                                if(key.equals("propPath")) 
                                        
ConfigFCM.setPwSecPropPath(prop.getProperty(key));
                                try{
                                        if(key.equals("appCode")) 
                                                
ConfigFCM.setPwSecAppCode(Integer.parseInt(prop.getProperty(key)));
                                }
                                catch(NumberFormatException e){                 
                                                
                                        
Log.loggerError.error("InitSrvlt.init(): Invalid value for appCode in 
FCMapp.properties.", PwLoggingSubLevel.NONE);
                                        throw e;
                                }
                                try{
                                        if(key.equals("appName")) 
                                                
ConfigFCM.setPwSecAppName(prop.getProperty(key));
                                }
                                catch(NumberFormatException e){                 
                                                
                                        
Log.loggerError.error("InitSrvlt.init(): Invalid value for appName in 
FCMapp.properties.", PwLoggingSubLevel.NONE);
                                        throw e;
                                }
                                try{    
                                        if(key.equals("generalUserPermCode")) 
                                                
ConfigFCM.setPwSecGenUserCode(Integer.parseInt(prop.getProperty(key)));
                                }
                                catch(NumberFormatException e){                 
                 
                                        
Log.loggerError.error("InitSrvlt.init(): Invalid value for generalUserPermCode 
in FCMapp.properties.", PwLoggingSubLevel.NONE);
                                        throw e;
                                }
                                try{    
                                        if(key.equals("adminUserPermCode")) 
                                                
ConfigFCM.setPwSecAdminUserCode(Integer.parseInt(prop.getProperty(key)));
                                }
                                catch(NumberFormatException e){                 
                 
                                        
Log.loggerError.error("InitSrvlt.init(): Invalid value for adminUserPermCode in 
FCMapp.properties.", PwLoggingSubLevel.NONE);
                                        throw e;
                                }                       
                                if(key.equals("data_source")) 
                                        
ConfigFCM.setDataSource(prop.getProperty(key));
                                        
                        }
                        
                        
                        //Initialize Web Tabs from xml file
                        //initTabControl();             
                        //initReportManager(); 
                        
                        if (Log.loggerDebug.isDebugEnabled())
                                Log.loggerDebug.debug("InitSrvlt.init(): FCM 
App proporties initialized successfully ", PwLoggingSubLevel.DEBUG);            
           
                } catch (IOException e) {                       
                        Log.loggerError.error("InitSrvlt.init(): I/O Exception: 
Can't read FCMapp.properties.", PwLoggingSubLevel.NONE,e);
                }
                         
                
                
        }

        

} 


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to