2015-02-06 4 views
0

sql-maven-plugin을 사용하여 Oracle TimesTen 데이터베이스를 삭제하고 다시 작성하는 maven 스크립트를 작성하고 dbdeploy를 사용하여 여러 데이터베이스 마이그레이션 스크립트를 적용하려고합니다. 사전 통합 테스트 단계에서다중 Maven 플러그인 종속성 - 이미 다른 클래스 로더에로드 된 네이티브 라이브러리

[ERROR] 
java.sql.SQLException: Problems with loading native library/missing methods: Native Library /opt/timesten/TimesTen/tt1122/lib/libttJdbcCS.dylib already loaded in another classloader 

가 어떻게 구체적으로 받는다는에서 이러한 문제를 극복 할 수있다 :이 플러그인의

은 물론 다음과 같은 오류를 생산, 다른 클래스 로더에 의해로드 할 수 없습니다 기본 타임 스텐 라이브러리의 사용을 필요로?

참고로

, 내 pom.xml 파일은 아래와 같습니다 경우

<?xml version="1.0"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <parent> 
     <groupId>com.xxx.xxx</groupId> 
     <artifactId>xxx</artifactId> 
     <version>x.x.x.x-SNAPSHOT</version> 
    </parent> 

    <groupId>x.x.x.x</groupId> 
    <artifactId>db-reset</artifactId> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>com.dbdeploy</groupId> 
       <artifactId>maven-dbdeploy-plugin</artifactId> 
       <version>3.0M3</version> 

       <configuration> 
        <scriptdirectory>src/sql/dbdeploy-migrations</scriptdirectory> 
        <driver>${timesten.jdbc.driver.class}</driver> 
        <url>${timesten.jdbc.url}</url> 
        <userid>${timesten.user}</userid> 
        <password>${timesten.password}</password> 
        <dbms>timesten</dbms> 
        <delimiter>;</delimiter> 
        <delimiterType>row</delimiterType> 
       </configuration> 

       <dependencies> 
        <dependency> 
         <groupId>com.timesten</groupId> 
         <artifactId>timesten</artifactId> 
         <version>11.2.2.7.8</version> 
         <scope>system</scope> 
         <systemPath>${timesten.jdbc.library.path}</systemPath> 
        </dependency> 
       </dependencies> 

       <executions> 
        <execution> 
         <phase>pre-integration-test</phase> 
         <goals> 
          <goal>update</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>sql-maven-plugin</artifactId> 
       <configuration> 
        <driver>${timesten.jdbc.driver.class}</driver> 
        <url>${timesten.jdbc.url}</url> 
        <username>${timesten.user}</username> 
        <password>${timesten.password}</password> 
       </configuration> 
       <dependencies> 
        <dependency> 
         <groupId>com.timesten</groupId> 
         <artifactId>timesten</artifactId> 
         <version>11.2.2.7.8</version> 
         <scope>system</scope> 
         <systemPath>${timesten.jdbc.library.path}</systemPath> 
        </dependency> 
       </dependencies> 
       <executions> 
        <execution> 
         <id>drop-db</id> 
         <phase>clean</phase> 
         <goals> 
          <goal>execute</goal> 
         </goals> 
         <configuration> 
          <onError>continue</onError> 
          <srcFiles> 
           <srcFile>src/sql/base/drop.sql</srcFile> 
          </srcFiles> 
         </configuration> 
        </execution> 
        <execution> 
         <id>create-clean-db</id> 
         <phase>clean</phase> 
         <goals> 
          <goal>execute</goal> 
         </goals> 
         <configuration> 
          <srcFiles> 
           <srcFile>src/sql/base/create.sql</srcFile> 
          </srcFiles> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

</project> 

답변

0

이 여전히 재미있다 : 당신이 Class.forName을 제외한 아무것도하지 않는 모조있는 작은 받는다는 - 플러그인을 만들어이 문제를 해결할 수() 플러그인 클래스. 드라이버의 패키지를 확장으로 내보내는 META-INF/maven/extensions.xml을 만듭니다. 초기 (예를 들어 초기화 중)이 플러그인을 실행하고 효과적으로

<extensions>true</extensions> 

을에서 지정할, 확장 한 번로드 된 드라이버 클래스 (한 번로드 네이티브 라이브러리)와 모든 플러그인에 의해 공유 된 클래스 로더를 작성합니다.