2016-08-29 6 views
1

cargo maven2 플러그인에서 일부 기능 테스트를 실행하려고합니다. 이러한 테스트는 cargo maven2 플러그인을 사용하지 않고 시작될 때 로컬 tomcat 서버에서 올바르게 실행됩니다. 성공적으로 플러그인 자체 부츠하지만이 테스트를 실행할 때 500 오류 다음 추적과 코드를 반환 :ClassNotFoundException : cargo maven2 플러그인을 사용하여 테스트를 실행하는 경우 oracle.jdbc.OracleDriver

Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.OracleDriver' 
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1429) 
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371) 
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) 

... 109 more 
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver 
at java.lang.ClassLoader.findClass(ClassLoader.java:531) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:425) 
at persistence.spi.hibernate.TransformingClassLoader.loadClass(TransformingClassLoader.java:46) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:358) 
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:14 

내가 5 ojdbc하는 ojdbc 6 내 치어의 항아리와 제외 참조를 추가하고 ojdbc을 14

다음은 나의화물 구성입니다.

 <plugin> 
     <groupId>org.codehaus.cargo</groupId> 
     <artifactId>cargo-maven2-plugin</artifactId> 
     <version>1.4.14</version> 
     <configuration> 
      <container> 
       <containerId>tomcat7x</containerId> 
       <type>installed</type> 
       <zipUrlInstaller> 
       <url>http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70.zip</url> 
       <downloadDir>${project.build.directory}/downloads</downloadDir> 
       <extractDir>${project.build.directory}/extracts</extractDir> 
       </zipUrlInstaller> 
       <systemProperties> 
       <java.io.tmpdir>target/tmp</java.io.tmpdir> 
       </systemProperties> 
       <output>${project.build.directory}/cargo-container.log</output> 
       <log>${project.build.directory}/cargo.log</log> 
      </container> 
      <deployables> 
       <deployable> 
       <groupId>x.rest</groupId> 
       <artifactId>x-war</artifactId> 
       <type>war</type> 
       </deployable> 
      </deployables> 
      <configuration> 
       <type>standalone</type> 
       <home>${project.build.directory}/tomcat7x/container</home> 
       <properties> 
       <cargo.tomcat.ajp.port>9414</cargo.tomcat.ajp.port> 
            <cargo.servlet.port>9484</cargo.servlet.port> 
       <cargo.rmi.port>9496</cargo.rmi.port> 
       <cargo.logging>high</cargo.logging> 
       <war>${project.build.directory}/x-war.war</war> 
       <!-- This section was added by me but didn't fix the problem --> 
       <cargo.datasource.datasource> 
        cargo.datasource.jndi=jdbc/DB| 
        cargo.datasource.type=javax.sql.DataSource| 
        cargo.datasource.driver=oracle.jdbc.OracleDriver| 
        cargo.datasource.url=jdbc:oracle:thin:abc/[email protected]:22:node1| 
        cargo.datasource.username=abc| 
        cargo.datasource.password=abc 
       </cargo.datasource.datasource> 
       </properties> 
       <configfiles> 
       <configfile> 
        <file>${project.basedir}/src/test/resources/war-dependencies/stable-dev/context.xml</file> 
        <todir>conf</todir> 
        <tofile>context.xml</tofile> 
       </configfile> 
       </configfiles> 
       <files> 
       <file> 
        <file>${project.basedir}/src/test/resources/war-dependencies/stable-dev/service.keystore</file> 
        <todir>shared/classes</todir> 
       </file> 
       </files> 
      </configuration> 
     </configuration> 
     <executions> 
      <!-- The executions here deal only with INTEGRATION-TEST phase. We are NOT hitting REST Service via tests in the TEST phase. We need to be assured that our container is already 
       up and running. So cargo is started in PRE-INTEGRATION-TEST phase. --> 
      <execution> 
       <id>start-container</id> 
       <phase>pre-integration-test</phase> 
       <goals> 
       <goal>stop</goal> 
       </goals> 
      </execution> 
     <!-- <execution> 
       <id>stop-container</id> 
       <phase>post-integration-test</phase> 
       <goals> 
       <goal>stop</goal> 
       </goals> 
      </execution>--> 
     </executions> 
    </plugin> 

나는 웹 서비스 세계의 초보자이므로 어떤 제안/조언을 부탁드립니다. 어딘가에 구성이 누락 되었습니까?

답변

0

가있어 다음과 같은 명령을 이동하여 로컬 드라이브에서 jar 파일을 열고 명령 프롬프트를 복사하여 로컬 저장소에 직접 jar 파일의 현재 디렉토리를 jar 파일을 설치하고 실행 일하다. ojdbc6을 컨테이너 섹션 내에서 종속성으로 추가해야했습니다.

0

Tomcat에서 예외가없는 이유는 Tomcat의 lib 폴더에있는 기존 ojdbc6.jar 파일 때문일 수 있습니다.

그러나 법적인 문제로 인해 oracle jdbc 드라이버 jar 파일을 공용 메이븐 저장소에서 찾을 수 없습니다.

는 여기에 또 다른 간단하고 곧장 앞으로 솔루션이 있습니다 받는다는 저장소

Get Oracle JDBC drivers from the Oracle Maven Repository - NetBeans, Eclipse & Intellij

에서 점점 오라클 JDBC 드라이버의 공식 명령어입니다.

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dpackaging=jar -Dversion=11.2.0.4.0 -Dfile=ojdbc6.jar -DgeneratePom=true 
+0

제안 해 주셔서 감사합니다.하지만 테스트 프로젝트 내에서 참조 된 라이브러리의 일부로 ojdbc6 -11.2.0.3을 볼 수 있습니다. 화물을 집어 들기에 충분하지 않아야합니까? – linuxNoob