2014-07-13 4 views
1

Bitnami Tomcat Stack을 사용하여 EC2에서 인스턴스를 생성했습니다. 모든 것이 몇 분이면 완벽하게 작동합니다. 그러나 최종 단계에서 응용 프로그램을 배포 할 때 maven이 소스 코드를 컴파일하지 못하고 있습니다. Eventhoug JAVA_HOME이 완벽하게 설정되어있어 아래 오류 로그로 컴파일하는 데 실패했습니다.Bitnami Tomcat Stack Maven 컴파일이 실패합니다.

[email protected]:/mnt/apps/stutzen-backend# echo $JAVA_HOME 
/opt/bitnami/java 
[email protected]:/mnt/webapps/stutzen-backend# mvn compile 
[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building ware27 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ ware27 --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] Copying 4 resources 
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ ware27 --- 
[INFO] Compiling 34 source files to /mnt/webapps/stutzen-backend/target/classes 
[INFO] ------------------------------------------------------------- 
[ERROR] COMPILATION ERROR : 
[INFO] ------------------------------------------------------------- 
[ERROR] Unable to locate the Javac Compiler in: 
    /opt/bitnami/java/../lib/tools.jar 
Please ensure you are using JDK 1.4 or above and 
not a JRE (the com.sun.tools.javac.Main class is required). 
In most cases you can change the location of your Java 
installation by setting the JAVA_HOME environment variable. 
[INFO] 1 error 
[INFO] ------------------------------------------------------------- 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 11.245s 
[INFO] Finished at: Sun Jul 13 10:37:54 UTC 2014 
[INFO] Final Memory: 6M/25M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project ware27: Compilation failure 
[ERROR] Unable to locate the Javac Compiler in: 
[ERROR] /opt/bitnami/java/../lib/tools.jar 
[ERROR] Please ensure you are using JDK 1.4 or above and 
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required). 
[ERROR] In most cases you can change the location of your Java 
[ERROR] installation by setting the JAVA_HOME environment variable. 
[ERROR] -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 

어떻게 처리하나요?

+0

당신의 JAVA_HOME 무엇을 당신이 "/ 옵션/bitnami/자바를 확인 않았다/..? /lib/tools.jar "? bitnami tomcat 스택 javahome 당 –

+0

은/opt/bitnami/java입니다. tools.jar의 올바른 경로는 "/opt/bitnami/java/lib/tools.jar"이지만, "/opt/bitnami/java/../lib/tools.jar"을 선택하는 이유를 이해할 수 없습니다. – arvindwill

+0

당신이 어떤 라인을 가지고 있는지 확인하기 위해 maven 프로파일을 사용하십시오 : $ {java.home} /../ lib/tools.jar

답변

1

maven compiler plugin은 기본적으로 Java 1.5 컴파일러 (official documentation의 소스 및 대상 옵션 참조)를 사용하도록 구성되었으며, Bitnami Tomcat Stack에는 Java 1.7이 포함되어 있습니다. 대신 Java 1.7을 사용하도록 프로젝트를 구성해야합니다. 이를 위해 maven.compiler.sourcemaven.compiler.target 속성에 다른 값을 정의하거나 maven.compiler.compilerVersion을 대신 정의 할 수 있습니다. 두 경우 모두 maven.compiler.fork을 true로 설정해야합니다. 아래의 예는 프로젝트 당이를 구성하는 방법을 보여줍니다

의 pom.xml :

<project> 
(...) 
    <properties> 
    <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion> 
    <maven.compiler.fork>true</maven.compiler.fork> 
    </properties> 
(...) 
</project> 

당신은 아마 모든 프로젝트에 대한 global settings 이러한 설정을 정의하는 것이 좋습니다 그러나

. 이 경우 당신은 ($ M2_HOME/conf의/Settings.XML의)에서 Settings.XML의 편집 항상 actived 될 프로파일을 정의 할 수 있습니다 :

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" ...> 
(...) 
    <profiles> 
    <profile> 
     <id>env-dev</id> 
     <properties> 
     <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion> 
     <maven.compiler.fork>true</maven.compiler.fork> 
     </properties> 
    </profile> 
    </profiles> 
    <activeProfiles> 
    <activeProfile>env-dev</activeProfile> 
    </activeProfiles> 
</settings> 
0

도움이되는지 아닌지 잘 모르겠습니다./옵션/bitnami : 그것은 작동하지 않습니다 잊지과 같은 당신의 Java 홈을 변경하면이 프로필 와 진정한 tools.jar가 주소와 실행 받는다는을 제공하여 pom.xml 파일 :

<profiles> 
     <profile> 
      <id>default-tools.jar</id> 
      <activation> 
       <property> 
        <name>java.vendor</name> 
        <value>Oracle Corporation</value> 
       </property> 
      </activation> 
      <dependencies> 
       <dependency> 
        <groupId>com.sun</groupId> 
        <artifactId>tools</artifactId> 
        <version>1.4.2</version> 
        <scope>system</scope> 
        <systemPath>${java.home}/../lib/tools.jar</systemPath> 
       </dependency> 
      </dependencies> 
     </profile> 
    </profiles> 

에 프로필을 추가 /jdk1.7.0_51/jre :)

+0

POM에 추가되고 "mvn compile -P default-tools.jar"을 실행했지만 동일한 문제가 발생합니다. 버전을 1.7로 변경하고 시스템 경로를 "/opt/bitnami/java/lib/tools.jar" – arvindwill

+0

내 대답을 편집합니다. –

+0

:) "오류 : JAVA_HOME이 (가) 올바르게 정의되지 않았습니다. /opt/bitnami/java/jre/bin/java를 실행할 수 없습니다." – arvindwill

1

kaysa의 답변이 정확합니다. 아래 그림과 같이이 솔루션은, 그러나, 당신의 치어에 받는다는 - 컴파일러 플러그인을 추가하여 좀 더 쉽게 달성 할 수있다 :

<build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.0</version> 
       <configuration> 
        <source>1.7</source> 
        <target>1.7</target> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
관련 문제