JDeveloper Embedded OC4J 기동시 오류


작성자 : 김민석 ( lemonfish at gmail dot com )
오라클 WAS 개발을 위해 어쩔수 없이 JDeveloper 를 사용하게 됐다. 
eclipse 를 사용할때는 딱히 아쉬운게 없었는데 JDeveloper 는 정말 열악하기 그지없다. 

어쨌든. 윈도즈 상에서 JDeveloper 에 내장된 OC4J 를 통해 테스트를 할경우 아래와 같은 메시지를 뱉어내며, 동작하지 않는 경우가 있다. 

Process exited with exit code 128.


ojvm 의 오류라고 하는데 알고보면 ojvm 의 결함때문이 아니라 윈도즈의 데이터실행방지 (DEP) 기능 때문이다. 


모든 프로그램에 적용하도록 되어있는 DEP 기능을 필수 프로그램 및 서비스에만 사용하도록 변경하고, 재부팅을 하고 나면 언제 그랬냐는듯. 자알~~~ 동작한다. 

by killy | 2010/02/01 15:49 | 삽질 | 트랙백 | 덧글(0)

Common.Logging 상에서 log4net 사용시 설정파일의 가상디렉토리 지원


작성자 : 김민석 ( lemonfish at gmail dot com )

Common.Logging 상에서 구현체로 log4net 을 사용할 경우 두 라이브러리 사이의 인터페이싱을 위해서 Log4NetLoggerFactoryAdapter 라는 클래스가 사용된다. Log4NetLoggerFactoryAdapter 는 Web.config 에서 configType 과 configFile 만을 인자로 입력 받는다. 

 <!-- 2. 로깅 섹션 -->
 <common>
  <logging>
   <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
    <arg key="configType" value="FILE-WATCH"/>

    <!-- 로깅 설정을 다르게 하고자 할경우 아래 경로에 해당 설정파일을 지정 -->
    <arg key="configFile" value="~/Config/Common/Log4Net.xml"/>
   </factoryAdapter>
  </logging>
 </common>


configFile 부분이 log4net 설정 파일의 위치가 되겠다. 그런데 여기서 value 에 해당하는 부분은 가상디렉토리 경로를 지원하지 않는다. 
 
왜그렇지? 하고 Log4NetLoggerFactoryAdapter 의 소스를 뜯어보면

configFile = string.Format("{0}/{1}", AppDomain.CurrentDomain.BaseDirectory.TrimEnd('/', '\\'), configFile.Substring(2));
이렇게 되있다. 무조건 웹애플리케이션의 루트디렉토리를 기본으로 하도록 되어있으니 가상디렉토리 경로가 먹힐리 만무.

그러면 가상디렉토리를 지원하도록 바꿔보자. 본인의 경우 Web.config 에서 아래와 같이 인자를 하나 더 받도록 처리했다.

 <!-- 2. 로깅 섹션 -->
 <common>
  <logging>
   <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
    <arg key="configType" value="FILE-WATCH"/>

    <!-- 로깅 설정을 다르게 하고자 할경우 아래 경로에 해당 설정파일을 지정 -->
    <arg key="configFile" value="~/Config/Common/Log4Net.xml"/>
    <!-- 설정파일이 가상디렉터리에 있을 경우 아래의 옵션을 준다. -->
    <arg key="virtualPath" value="true"/>
   </factoryAdapter>
  </logging>
 </common>


virtualPath 라는 인자를 통해 configFile 의 value 값이 가상디렉토리의 경로인지 알려주도록 하고  Log4NetLoggerFactoryAdapter  의 configFile 처리 부분을 아래와 같이 수정했다.

        protected Log4NetLoggerFactoryAdapter(NameValueCollection properties, ILog4NetRuntime runtime)
            : base(true)
        {
            if (runtime == null)
            {
                throw new ArgumentNullException("runtime");
            }
            _runtime = runtime;

            // parse config properties
            string configType = ArgUtils.GetValue(properties, "configType", string.Empty).ToUpper();
            string configFile = ArgUtils.GetValue(properties, "configFile", string.Empty);

   string virtualPath = ArgUtils.GetValue(properties, "virtualPath", "false");

   if (bool.Parse(virtualPath))
   {
    configFile = HttpContext.Current.Server.MapPath(configFile);
   }
   // app-relative path?
   else if (configFile.StartsWith("~/") || configFile.StartsWith("~\\"))
   {
    configFile = string.Format("{0}/{1}", AppDomain.CurrentDomain.BaseDirectory.TrimEnd('/', '\\'), configFile.Substring(2));
   }

            if (configType == "FILE" || configType == "FILE-WATCH")
            {
                if (configFile == string.Empty)
                {
                    throw new ConfigurationException("Configuration property 'configFile' must be set for log4Net configuration of type 'FILE' or 'FILE-WATCH'.");
                }

                if (!File.Exists(configFile))
                {
                    throw new ConfigurationException("log4net configuration file '" + configFile + "' does not exists");
                }
            }

            switch (configType)
            {
                case "INLINE":
                    _runtime.XmlConfiguratorConfigure();
                    break;
                case "FILE":
                    _runtime.XmlConfiguratorConfigure(configFile);
                    break;
                case "FILE-WATCH":
                    _runtime.XmlConfiguratorConfigureAndWatch(configFile);
                    break;
                case "EXTERNAL":
                    // Log4net will be configured outside of Common.Logging
                    break;
                default:
                    _runtime.BasicConfiguratorConfigure();
                    break;
            }
        }

위에서 빨간 부분이 수정된 부분이다. virtualPath 라는 인자에 true 값이 있을 경우 Server.MapPath 를 통해서 가상디렉토리를 제대로 처리한다.

by killy | 2009/11/25 16:19 | 삽질 | 트랙백 | 덧글(0)

◀ 이전 페이지          다음 페이지 ▶


동영상 한판 때리시죠? ^-^
rss

skin by FreeCssTemplates