히스토리 | 로그인     현재 페이지 인쇄가능한 버전 보기.  
상세 이슈내용 (XML | Word | 프린트용 화면)

키 : IAM-74
종류: Sub-task Sub-task
상태: Closed Closed
처리상태: Fixed
우선순위: Critical Critical
담당자: 김성룡
보고자: 김성룡
참여: 0
관찰자: 0
작업

만일 당신이 로그인 상태 이라면 더 많은 작업을 수행 가능합니다.
IAM
IAM-34

Hibernate + WebLogic 라이브러리 충돌 원인 파악 및 조치

생성일자: 2009-10-14 02:40 오후   업데이트: 2009-10-15 02:46 오후  만기: 2009-10-16
컴포넌트: Admin
관련 버전: 1.0.0.RC1
수정 버전: 1.0.0.RC1
보안 등급: Open for All (JIRA에 등록된 모든 사용자가 조회할 수 있는 이슈)

작업시간 추적:
미지정

완료요청일(Expected End Date): 2009-10-16
시작예정일(Planned Start Date): 2009-10-14
시작일(Start Date): 2009-10-14
종료일(End Date): 2009-10-16


 설명  « 숨기기
Anyframe IAM의 WebLogic 10 버전 테스트 결과 서버 기동시
Hibernate 쪽에서 org.hibernate.hql.ast.HqlToken 클래스의 ClassNotFoundException 이 발생


 모두    댓글   작업기록   변경기록   Subversion Commits      정렬 순서: 내림차순 - 내림차순 정렬로 선택
김성룡 - 2009-10-14 02:41 오후
공식적으로는 Hibernate 와 WebLogic 간의 antlr 라이브러리의 충돌이 다음과 같이 보고되어 있습니다.



https://www.hibernate.org/250.html

 

BEA Weblogic issues

 Hibernate3 uses ANTLR for the new query parser. Unfortunately BEA Weblogic includes a version of ANTLR in the system classpath which will be loaded before any application libraries and, because Weblogic doesn't seem to support proper class loader isolation, will not see the Hibernate classes in the application's context.

 BEA seems to solve this issue by prefixing package names, but the distributed ANTLR doesn't have this prefix. Another source for this issue is the usage of Class.forName() in ANTLR itself.

 Until both parties have solved these issues we can only provide workarounds: Place all your Hibernate and dependent libraries on the application server's boot classpath or use the old query parser as described above.

 The Hibernate Team has sent a fix for this issue to the ANTLR developers, and it should be included in the next release. We'll distribute this new version with a minor release of Hibernate in the next few weeks or months.

 For now we distribute a patched version of ANTLR with Hibernate 3.0 which uses the context classloader instead of Class.forName().

 

<prefer-application-packages>

     <package-name>antlr.*</package-name>

</prefer-application-packages>
 

김성룡 - 2009-10-14 02:42 오후
해결방법

 

우선 회피책으로 제시되어 있는, Hibernate 라이브러리 및 참조관계가 있는 라이브러리를 모두 부트 클래스 패스로 옮기는 것이나,

쿼리 파서를 구버전으로 강제로 지정하는 것 모두 실제로 적용하기엔 문제가 있습니다.

 

웹로직에서는 두가지 방법으로 해당 문제점을 회피할 수 있습니다.

 

첫번째 : WAR 의 경우

WEB-INF/classes/weblogic.xml 을 다음과 같이 설정합니다.

<?xml version="1.0" encoding="UTF-8"?>

<wls:weblogic-web-app xmlns:wls="http://www.bea.com/ns/weblogic/90"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-web-app.xsd">

    <wls:weblogic-version>10.0</wls:weblogic-version>

    <wls:jsp-descriptor>

        <wls:page-check-seconds>3</wls:page-check-seconds>

        <wls:precompile>false</wls:precompile>

    </wls:jsp-descriptor>

    <wls:container-descriptor>

        <wls:servlet-reload-check-secs>3</wls:servlet-reload-check-secs>

        <wls:resource-reload-check-secs>-1</wls:resource-reload-check-secs>

        <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>

    </wls:container-descriptor>

    <wls:context-root>anyframe-iam-admin-web</wls:context-root>

    <wls:charset-params>

        <wls:input-charset>

            <wls:resource-path>/*</wls:resource-path>

            <wls:java-charset-name>utf-8</wls:java-charset-name>

        </wls:input-charset>

    </wls:charset-params>

</wls:weblogic-web-app>
 
  
두번째 : EAR 의 경우

위에 표기된 것처럼 특정 패키지로 시작하는 클래스를 별도로 지정합니다. EAR 패키지의 META-INF/weblogic-application.xml 을 다음과 같이 설정합니다.



<?xml version="1.0" encoding="UTF-8"?>

<wls:weblogic-application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xmlns:wls="http://www.bea.com/ns/weblogic/90"

    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-application.xsd">

    <wls:prefer-application-packages>

        <wls:package-name>antlr.*</wls:package-name>

    </wls:prefer-application-packages>

</wls:weblogic-application>
 

세번째, 클래스패스에 antlr 을 추가

%WL_HOME%\common\lib 디렉토리에 antlr-2.7.6.jar 을 복사한 후

 

setDomainEnv.cmd (또는 sh) 에

set PRE_CLASSPATH=%WL_HOME%\common\lib\antlr-2.7.6.jar

와 같이 추가해 주어도 정상적으로 동작합니다.

 

Configuring BEA WebLogic with Hibernate 3.x


Both of these apps use a version of ANTLR. Hibernate uses 2.7.6 while WebLogic use 2.7.1. In order for Hibernate 3 to run under WebLogic, a classpath change is required.

The ANTLR code for WebLogic is part of the server\lib\weblogic.jar so it's impossible to replace just the ANTLR jar file. Instead you have to setup a PRE_CLASSPATH that puts the Hibernate jar in the classpath before the weblogic.jar.

1. Edit startWebLogic.cmd located in bea\user_projects\domains\mydomains. Change the line for the PRE_CLASSPATH to read:


set PRE_CLASSPATH=%WL_HOME%\common\lib\antlr-2.7.6.jar


2. Copy the ANTLR jar from the Hibernate distro to WL_HOME\common\lib. For me, WL_HOME is C:\bea\wlserver_10.0, but you can find your setting in the startWebLogic.cmd file.

Now when WebLogic starts an application that uses Hibernate3, you should not get any errors.