2012-07-02 2 views
1

내 프로젝트의 maven 빌드를 만들었습니다. 빌드가 succesfull이었습니다.하지만 서버 (Apache Tomcat 6)에 배포하면 jar 파일과 관련된 다양한 오류가 발생합니다.하지만 해당 jar 파일은 그 jar 파일을 서버의 lib 디렉토리에 보관하면 에러가 해결됩니다. 그래서, 이것에 관한 아이디어가있는 사람은 .. 나는 Maven을 사용하여 건물을 짓는데 아무런 문제가 없습니다.Maven 빌드가 실행되지 않음

내 pom.xml 파일

http://maven.apache.org/xsd/maven-4.0.0.xsd "> 4.0.0 Test1을 Test1을 0.0.1-SNAPSHOT 전쟁 Test1을 http://maven.apache.org

<properties> 
    <project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding> 
</properties> 
<repositories> 
    <repository> 
     <id>central</id> 
     <name>Maven Repository Switchboard</name> 
     <layout>default</layout> 
     <url>http://repo1.maven.org/maven2</url> 
     <snapshots> 
      <enabled>false</enabled> 
     </snapshots> 
    </repository> 
</repositories> 
<dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>servlet-api</artifactId> 
     <version>2.5</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.struts</groupId> 
     <artifactId>struts-core</artifactId> 
     <version>1.3.10</version> 
    </dependency> 
    <dependency> 
     <groupId>com.googlecode.json-simple</groupId> 
     <artifactId>json-simple</artifactId> 
     <version>1.1</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.mail</groupId> 
     <artifactId>mail</artifactId> 
     <version>1.4</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-dbcp</groupId> 
     <artifactId>commons-dbcp</artifactId> 
     <version>1.2.2</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-io</groupId> 
     <artifactId>commons-io</artifactId> 
     <version>2.0.1</version> 
    </dependency> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.8</version> 
    </dependency> 
    <dependency> 
     <groupId>net.sourceforge.jexcelapi</groupId> 
     <artifactId>jxl</artifactId> 
     <version>2.6.10</version> 
    </dependency> 
    <dependency> 
     <groupId>org.ow2.orchestra.eclipse.birt</groupId> 
     <artifactId>org.ow2.orchestra.eclipse.birt.core</artifactId> 
     <version>3.7.0</version> 
    </dependency> 
    <dependency> 
     <groupId>org.ow2.orchestra.eclipse.birt</groupId> 
     <artifactId>org.ow2.orchestra.eclipse.birt.report.engine</artifactId> 
     <version>3.7.0</version> 
    </dependency> 
    <dependency> 
     <groupId>openforecast</groupId> 
     <artifactId>openforecast</artifactId> 
     <version>1.0.16</version> 
     <scope>system</scope> 
     <systemPath>D:/testing/WebContent/WEB-INF/lib/OpenForecast-0.5.0.jar</systemPath> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.poi</groupId> 
     <artifactId>poi</artifactId> 
     <version>3.7</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.commons</groupId> 
     <artifactId>commons-math</artifactId> 
     <version>2.0</version> 
    </dependency> 
    <dependency> 
     <groupId>net.sf.jsci</groupId> 
     <artifactId>jsci</artifactId> 
     <version>1.2</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-collections</groupId> 
     <artifactId>commons-collections</artifactId> 
     <version>1.0</version> 
    </dependency> 
    <dependency> 
     <groupId>taglibs</groupId> 
     <artifactId>standard</artifactId> 
     <version>1.1.2</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.struts</groupId> 
     <artifactId>struts-taglib</artifactId> 
     <version>1.3.10</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>struts</groupId> 
     <artifactId>struts-bean</artifactId> 
     <version>1.2.7</version> 
     <type>tld</type> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>net.sourceforge.jtds</groupId> 
     <artifactId>jtds</artifactId> 
     <version>1.2</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-logging</groupId> 
     <artifactId>commons-logging</artifactId> 
     <version>1.1.1</version> 
    </dependency> 

</dependencies> 
<build> 
    <plugins> 
     <plugin> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
       <properties> 
        <maven.compiler.target>1.6</maven.compiler.target> 
        <maven.compiler.source>1.6</maven.compiler.source> 
       </properties> 
       <encoding>ISO-8859-1</encoding> 
      </configuration> 
     </plugin> 
     <plugin> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.1.1</version> 
      <configuration> 
       <packagingExcludes>D:/Test1/src/main/webapp/WEB-INF/web.xml</packagingExcludes> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

+0

범위가 '제공된'것으로 설정 되었기 때문일 수 있습니다. 문제가있는 항아리를 정확하게 알려주고 POM의 전체 종속성 섹션을 표시 할 수 있다면이를 해결할 수 있습니다. –

답변

3

당신은 톰캣에 항아리를 배포하지 않습니다. 당신이 전쟁 파일을 배포 war에는 라이브러리가 포함 된 WEB-INF/lib 폴더가 있습니다.

Tomcat 루트의 lib 폴더는 배포 된 모든 응용 프로그램간에 공유되는 라이브러리에만 사용됩니다. 예를 들어, 데이터베이스 드라이버.

Maven 종속성이 인 범위에 있는지 확인하십시오. WEB-INF/lib 폴더에 포함되어야합니다.

<dependency> 
    <groupId>javax.servlet</groupId> 
    <artifactId>servlet-api</artifactId> 
    <version>2.5</version> 
</dependency> 

이 범위가 반드시 다음과 같이 "제공"그들이 컴파일에 필요한되지만 런타임에이에 톰캣에 의해 제공된다는 것을 의미합니다 : 서블릿 API로 의존성과 같은

+0

답장을 보내 주셔서 감사합니다. 내 pom.xml을 공유하고 있습니다. – Ankit

+0

나는 그가 의존성 병 파일을 의미한다고 생각합니다. –

0

것부터 케이스.

<dependency> 
    <groupId>javax.servlet</groupId> 
    <artifactId>servlet-api</artifactId> 
    <version>2.5</version> 
    <scope>provided</scope> 
</dependency> 

다음 :

시스템 1.0.16 openforecast D openforecast : /testing/WebContent/WEB-INF/lib/OpenForecast-0.5.0.jar

실제 필수 저장소 인 Repository를 사용하고 있지 않음을 나타냅니다. 빌드에서 시스템 범위 종속성을 사용하지 마십시오. 특정 환경을 빌드하게됩니다. 저장소 관리자 (Nexus, Artifactory 또는 Archive)를 사용하여 오픈 포리스트를 설치하십시오. 그리고 당신의 pom과 특히 Maven Central에 bad practice to define repositories이 있습니다. 당신은 당신이 당신의 치어에 다음을 정의한 경우

:

<properties> 
    <project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding> 
</properties> 

maven-compiler-plugin의 구성은 다음과 같이 필요하지 않습니다, 인코딩 매개 변수는 위의 속성을 기본으로 사용하여 발생합니다.

<plugin> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <configuration> 
     <source>1.6</source> 
     <target>1.6</target> 
     <properties> 
      <maven.compiler.target>1.6</maven.compiler.target> 
      <maven.compiler.source>1.6</maven.compiler.source> 
     </properties> 
     <encoding>ISO-8859-1</encoding> 
    </configuration> 
</plugin> 

는 다음을 사용할 수 있습니다

<plugin> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <configuration> 
     <source>1.6</source> 
     <target>1.6</target> 
    </configuration> 
</plugin> 

그러나 당신은 당신의 사용 플러그인의 버전을 정의해야합니다

<plugin> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <version>2.3.2</version> 
    <configuration> 
     <source>1.6</source> 
     <target>1.6</target> 
    </configuration> 
</plugin> 

할 수있는 최선은 pluginManagement 섹션을 사용하고 있습니다.

내 마음에 오는 또 다른 한가지는 당신이 오래된 Maven-War-Plugin을 사용하고 있으며 어떤 상황에서도 피해야하는 구성에서 절대 경로를 사용하고 있다는 것입니다.

<plugin> 
    <artifactId>maven-war-plugin</artifactId> 
    <version>2.1.1</version> 
    <configuration> 
    <packagingExcludes>D:/Test1/src/main/webapp/WEB-INF/web.xml</packagingExcludes> 
    </configuration> 
</plugin> 

최신 버전은 the web-site says입니다. 이 같은 일을 제외해야하는 경우에는 다음과 같은 방법으로이를 수행해야합니다 당신은 web.xml을 제외 할 이유가의 필수적인 부분입니다 원인

<plugin> 
    <artifactId>maven-war-plugin</artifactId> 
    <version>2.2</version> 
    <configuration> 
    <packagingExcludes>${basedir}/src/main/webapp/WEB-INF/web.xml</packagingExcludes> 
    </configuration> 
</plugin> 

그러나

이 경우 내가 이해하지 않는다 전쟁 파일. 조금 더 자세히 설명해 주시겠습니까?

+0

안녕하세요 khmarbaise는 답장을 보내 주셔서 고맙습니다. 귀하가 지정한 변경을했지만 여전히 다음 예외에 직면하고 있습니다. NoClassDefFoundError를 : \t org.apache.jasper.servlet.JspServletWrapper.service을 클래스 org.apache.struts.taglib.html.FormTag \t org.apache.jasper.servlet.JspServletWrapper.handleJspException (JspServletWrapper.java:500)를 초기화 할 수 없습니다 openforecast가 이잖아 위해 내가 시스템에서 추가 이유 (JspServletWrapper.java:410 \t org.apache.jasper.servlet.JspServlet.serviceJspFile – Ankit

+0

내가 받는다는 의존성을 찾지 못했습니다. – Ankit

+0

을 내가 저장소 관리자를 사용하여 시작을 언급 한 바와 같이. – khmarbaise

관련 문제