2016-09-16 18 views
0

我正在Netbeans8.0 IDE,apache-tomcat服務器上運行java web應用程序。服務器沒有引用我的戰爭中的依賴jar,但是當我將相同的jar放在服務器庫中時,它工作正常

我有三個項目其中一個具有父pom.xml,另外兩個擁有自己的POM.xml 此應用程序具有遺留代碼,並且在運行時它引用來自服務器庫的ojdbc6 jar。現在,管理層希望我們將所有依賴關係瓶移動到戰爭的Web-Inf/lib中。我們將下載的jar文件下載到應用程序的本地文件夾中,但由於某種原因,它不能從Web- INF,當我將它們移動到pom.xml時,我認爲我可能與組和artifactID有關。所以我直接從codeIds的maven倉庫中引用它,現在我有兩個問題 1.我只看到這個jar在Web-Inf中,只有當我用依賴關係構建時 2.在Web-Inf中看到它之後,當我調試時運行它我正在運行時得到ojdbc-driver異常。

但是,當我將相同的jar移動到server/lib它工作正常。

我幾乎花了整整一週的時間來解決這個問題,從互聯網上的許多文件的幫助,但沒有運氣。

我的pom.xml父

<?xml version="1.0" encoding="UTF-8"?> 
<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> 

    <groupId>portalsGroupId.portals</groupId> 
    <artifactId>matrix</artifactId> 
    <name>matrix</name> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>war</packaging> 

    <url>http://www.8x8.com</url> 

    <parent> 
     <groupId>portalsGroupId</groupId> 
     <artifactId>portals</artifactId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 

    <repositories> 
     <repository> 
      <id>codelds</id> 
      <url>https://code.lds.org/nexus/content/groups/main-repo</url> 
     </repository> 
     <repository> 
      <id>jboss-public-repository-group</id> 
      <name>Jboss Repository for Maven</name> 
     <url><http://repository.jboss.org/nexus/content/groups /public></url> 
     </repository> 

     <repository> 
      <id>jboss</id> 
      <name>Jboss</name> 
      <url>http://repository.jboss.com/maven2/</url> 
     </repository> 
     </repository> 
    </repositories> 
    <pluginRepositories> 
     <pluginRepository> 
      <id>jboss-public-repository-group</id> 
      <name>JBoss Public Maven Repository Group</name> 
      <url>http://8x8.com/nexus/content/groups/public-jboss/</url> 
      <layout>default</layout> 
      <releases> 
       <enabled>false</enabled> 
       <updatePolicy>never</updatePolicy> 
      </releases> 
      <snapshots> 
       <enabled>false</enabled> 
       <updatePolicy>never</updatePolicy> 
      </snapshots> 
     </pluginRepository> 
    </pluginRepositories> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
       <org.richfaces.bom.version>4.0.0.Final</org.richfaces.bom.version>   
     <slf4j.version>1.5.6</slf4j.version> 
     <jsf.version>2.1.2</jsf.version> 
     <ssputil.version>1.0-SNAPSHOT</ssputil.version> 
     <sspapi.version>1.0-SNAPSHOT</sspapi.version>   
     <oltu.version>1.0.0</oltu.version> 
    </properties> 

    <build> 
     <finalName>matrix-${project.version}</finalName> 
     <plugins> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.3.2</version> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
       </configuration> 
      </plugin> 
      <plugin> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>2.1-alpha-2</version> 
       <configuration> 
        <webResources> 
         <resource> 
          <directory>${basedir}/src/main/java</directory> 
          <targetPath>/WEB-INF/src</targetPath> 
         </resource> 
        </webResources> 
        <webResources> 
         <resource> 
          <directory>${basedir}/../ext_lib/cloud/</directory> 
          <targetPath>/WEB-INF/lib</targetPath> 
         </resource> 
         <resource> 
          <directory>${basedir}/../ext_lib/commons-net/</directory> 
          <targetPath>/WEB-INF/lib</targetPath> 
         </resource> 
         <resource> 
          <directory>${basedir}/src/main/java/com/_8x8/matrix/skin/</directory> 
          <targetPath>/WEB-INF/classes</targetPath> 
         </resource> 
         <resource> 
          <directory>${basedir}/../ext_lib/httpclient431/</directory> 
          <targetPath>/WEB-INF/lib</targetPath> 
         </resource> 
        </webResources>   
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

    <profiles> 
     <profile> 
      <id>jee6</id> 
      <build> 
       <plugins> 
        <plugin> 
         <artifactId>maven-war-plugin</artifactId> 
         <configuration> 
          <webappDirectory>${project.build.directory}/${project.build.finalName}-jee6</webappDirectory> 
          <packagingExcludes>WEB-INF/lib/jsf-api*,WEB-INF/lib/jsf-impl*,WEB-INF/lib/jstl*</packagingExcludes> 
          <warSourceExcludes>WEB-INF/lib/jsf-api*,WEB-INF/lib/jsf-impl*,WEB-INF/lib/jstl*</warSourceExcludes> 
         </configuration> 
        </plugin> 
       </plugins> 
      </build> 


      <dependencyManagement> 
       <dependencies> 
        <dependency> 
         <groupId>org.richfaces</groupId> 
         <artifactId>richfaces-bom</artifactId> 
         <version>${org.richfaces.bom.version}</version> 
         <scope>import</scope> 
         <type>pom</type> 
        </dependency> 
       </dependencies> 
      </dependencyManagement> 

      <dependencies> 
       <dependency> 
        <groupId>org.richfaces.ui</groupId> 
        <artifactId>richfaces-components-ui</artifactId> 
       </dependency> 
       <dependency> 
        <groupId>org.richfaces.core</groupId> 
        <artifactId>richfaces-core-impl</artifactId> 
       </dependency> 
       <dependency> 
        <groupId>com.sun.faces</groupId> 
        <artifactId>jsf-api</artifactId> 
        <scope>provided</scope> 
       </dependency> 
       <dependency> 
        <groupId>org.apache.oltu.oauth2</groupId> 
        <artifactId>org.apache.oltu.oauth2.client</artifactId> 
        <version>${oltu.version}</version> 
       </dependency> 
       <dependency> 
        <groupId>com.sun.faces</groupId> 
        <artifactId>jsf-impl</artifactId> 
        <scope>provided</scope> 
       </dependency> 
       <dependency> 
        <groupId>javax.transaction</groupId> 
        <artifactId>jta</artifactId> 
        <version>1.1</version> 
        <scope>provided</scope> 
       </dependency> 
      </dependencies> 
     </profile> 
     <profile> 
      <id>release</id> 
      <build> 
       <plugins> 
        <plugin> 
         <artifactId>maven-war-plugin</artifactId> 
         <executions> 
          <execution> 
           <id>jee6</id> 
           <phase>package</phase> 
           <goals> 
            <goal>war</goal> 
           </goals> 
           <configuration> 
            <webappDirectory>${project.build.directory}/${project.build.finalName}-jee6</webappDirectory> 
            <classifier>jee6</classifier> 
            <packagingExcludes>WEB-INF/lib/jsf-api*,WEB-INF/lib/jsf-impl*,WEB-INF/lib/jstl*</packagingExcludes> 
            <warSourceExcludes>WEB-INF/lib/jsf-api*,WEB-INF/lib/jsf-impl*,WEB-INF/lib/jstl*</warSourceExcludes> 
           </configuration> 
          </execution> 
         </executions> 
         <configuration> 
          <webResources> 
           <resource> 
            <directory>${basedir}/src/main/java</directory> 
            <targetPath>/WEB-INF/src</targetPath> 
           </resource> 
          </webResources> 
         </configuration> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
    </profiles> 

    <dependencyManagement> 
     <dependencies> 
      <dependency> 
       <groupId>com.google.code.gson</groupId> 
       <artifactId>gson</artifactId> 
       <version>2.5</version> 
      </dependency> 
      <dependency> 
       <groupId>${project.groupId}</groupId> 
       <artifactId>matrix_ssp_api</artifactId> 
       <version>1.0-SNAPSHOT</version> 
      </dependency> 
      <dependency> 
       <groupId>org.richfaces</groupId> 
       <artifactId>richfaces-bom</artifactId> 
       <version>${org.richfaces.bom.version}</version> 
       <scope>import</scope> 
       <type>pom</type> 
      </dependency> 
      <dependency> 
       <groupId>com.sun.faces</groupId> 
       <artifactId>jsf-api</artifactId> 
       <version>${jsf.version}</version> 
      </dependency> 
      <dependency> 
      <groupId>org.apache.tomcat</groupId> 
      <artifactId>tomcat-jdbc</artifactId> 
      <version>7.0.19</version> 
      <type>jar</type> 
     </dependency> 
      <dependency> 
       <groupId>org.hibernate</groupId> 
       <artifactId>hibernate-validator</artifactId> 
       <version>4.2.0.Final</version> 
      </dependency> 
      <dependency> 
       <groupId>org.slf4j</groupId> 
       <artifactId>slf4j-api</artifactId> 
       <version>${slf4j.version}</version> 
      </dependency> 
      <dependency> 
       <groupId>org.slf4j</groupId> 
       <artifactId>slf4j-log4j12</artifactId> 
       <version>${slf4j.version}</version> 
      </dependency> 
      <dependency> 
       <groupId>com.oracle</groupId> 
       <artifactId>ojdbc6</artifactId> 
       <version>11.2.0.1.0</version> 
       <type>jar</type> 
      </dependency> 
     </dependencies> 
    </dependencyManagement> 

    <dependencies> 
     <dependency> 
      <groupId>org.richfaces.ui</groupId> 
      <artifactId>richfaces-components-ui</artifactId> 
      <version>${org.richfaces.bom.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.oltu.oauth2</groupId> 
      <artifactId>org.apache.oltu.oauth2.client</artifactId> 
      <version>${oltu.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.richfaces.core</groupId> 
      <artifactId>richfaces-core-impl</artifactId> 
      <version>${org.richfaces.bom.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.richfaces.cdk</groupId> 
      <artifactId>annotations</artifactId> 
      <scope>provided</scope> 
      <version>${org.richfaces.bom.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-validator</artifactId> 
      <!--scope>provided</scope--> 
     </dependency>   
     <!-- Logging --> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-api</artifactId> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-log4j12</artifactId> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.faces</groupId> 
      <artifactId>jsf-api</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.faces</groupId> 
      <artifactId>jsf-impl</artifactId> 
      <version>2.1.2</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet.jsp</groupId> 
      <artifactId>jsp-api</artifactId> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.el</groupId> 
      <artifactId>el-api</artifactId> 
      <version>2.2</version> 
      <scope>compile</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.glassfish.web</groupId> 
      <artifactId>el-impl</artifactId> 
      <version>2.2</version> 
      <scope>runtime</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>jstl</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>net.sf.ehcache</groupId> 
      <artifactId>ehcache</artifactId> 
     </dependency> 

     <!-- Local Project Dependency --> 
     <dependency> 
      <groupId>portalsGroupId.portals</groupId> 
      <artifactId>matrix_ssp_util</artifactId> 
      <version>1.0-SNAPSHOT</version> 
      <exclusions> 
       <exclusion> 
        <groupId>com._8x8.matrix</groupId> 
        <artifactId>matrix_httpClient401_cmncodec</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>portalsGroupId.portals</groupId> 
      <artifactId>matrix_ssp_api</artifactId> 
      <exclusions> 
       <exclusion> 
        <groupId>com._8x8.matrix</groupId> 
        <artifactId>matrix_httpClient401_cmncodec</artifactId> 
       </exclusion> 
      </exclusions> 
      <version>1.0-SNAPSHOT</version> 
     </dependency> 

     <dependency> 
      <groupId>portalsGroupId.portals</groupId> 
      <artifactId>matrix_cloud_commons</artifactId> 
      <scope>system</scope> 
      <version>1.0-SNAPSHOT</version> 
      <systemPath>${project.basedir}/../ext_lib/cloud/cloud_commons.jar</systemPath> 
     </dependency> 
     <dependency> 
      <groupId>portalsGroupId.portals</groupId> 
      <artifactId>matrix_cloud_client</artifactId> 
      <scope>system</scope> 
      <version>1.0-SNAPSHOT</version> 
      <systemPath>${project.basedir}/../ext_lib/cloud/cloud_client.jar</systemPath> 
     </dependency> 

     <dependency> 
      <groupId>commons-net</groupId> 
      <artifactId>commons-net</artifactId> 
      <scope>system</scope> 
      <version>1.0-SNAPSHOT</version> 
      <systemPath>${project.basedir}/../ext_lib/commons-net/commons-net-3.0.1.jar</systemPath> 
     </dependency> 

     <dependency> 
      <groupId>sims</groupId> 
      <artifactId>sims</artifactId> 
      <scope>system</scope> 
      <version>1.0-SNAPSHOT</version> 
      <systemPath>${project.basedir}/../ext_lib/sims/sims-connector.jar</systemPath> 
     </dependency> 

     <dependency> 
      <groupId>jlayer</groupId> 
      <artifactId>jlayer</artifactId> 
      <scope>system</scope> 
      <version>1.0-SNAPSHOT</version> 
      <systemPath>${project.basedir}/../ext_lib/jlayer/jl1.0.1.jar</systemPath> 
     </dependency> 

     <dependency> 
      <groupId>cdirector</groupId> 
      <artifactId>cdirector</artifactId> 
      <scope>system</scope> 
      <version>1.0-SNAPSHOT</version> 
      <systemPath>${project.basedir}/../ext_lib/chartdirector/ChartDirector.jar</systemPath> 
     </dependency> 

     <dependency> 
      <groupId>gson</groupId> 
      <artifactId>gson222</artifactId> 
      <scope>system</scope> 
      <version>1.0-SNAPSHOT</version> 
      <systemPath>${project.basedir}/../ext_lib/gson/google-gson-2.2.2/gson-2.2.2.jar</systemPath> 
     </dependency>  
     <dependency> 
      <groupId>com.thoughtworks.xstream</groupId> 
      <artifactId>xstream</artifactId> 
      <version>1.4.5</version> 
     </dependency> 
     <dependency> 
      <groupId>org.codehaus.jettison</groupId> 
      <artifactId>jettison</artifactId> 
      <version>1.3.4</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.httpcomponents</groupId> 
      <artifactId>httpclient</artifactId> 
      <version>4.3.1</version> 
     </dependency> 

     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.10</version> 
      <scope>test</scope> 
      <type>jar</type> 
     </dependency> 
    </dependencies> 
</project> 
+0

是的,它現在的作品。謝謝。 – user2617611

回答

1

只要下載一個罐子,把它到項目文件夾不是「Maven的方式」 ......

如果你想使用一個庫,該庫而不是在中央倉庫中,您必須將其放入當地倉庫或使用其他遠程倉庫。 如果我理解正確,您已選擇使用code.lds.org回購。 我在你的pom中看不到的是(real)依賴項。 ojdbc6只有dependency management

你必須把它添加到您<dependencies>部分和運行mvn package(或Netbeans的建立)和ojdbc6罐子應該被打包成戰爭。

<dependency> 
    <groupId>com.oracle</groupId> 
    <artifactId>ojdbc6</artifactId> 
</dependency> 

(版本在這裏省略,因爲它是在<dependencyManagement>已經定義;不需要<type>jar</type>,因爲它的默認...)

你也可以看看這個問題,也許有一些更多/其他信息:Oracle JDBC ojdbc6 Jar as a Maven Dependency

相關問題