事象 : パッケージjavax.annotationは存在しません
- 環境
- Windows10 Pro バージョン1909
- Apache Maven 3.6.3
$ mvn install -Pstaging -DskipTests=true
...省略...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project hoge: Compilation failure: Compilation failure:
[ERROR] /C:/project/src/main/java/com/hoge/Hoge.java:[6,24] パッケージjavax.annotationは存在しません
[ERROR] /C:/project/src/main/java/com/hoge/Hoge.java:[23,2] シンボルを見つけられません
[ERROR] シンボル: クラス Generated
...省略...
原因 : Java8を使うべきところJava11を使っているから
HFC_SDK(1.3)とJava11の相性はそこまで良くなかったので簡単に対応した話 - Qiitaを見て気が付いた・・・
pom.xmlで指定しているコンパイルのJavaバージョンを見てみたらJava8だった。
<properties>
<java.version>1.8</java.version>
<!-- 省略 -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<!-- 省略 -->
パスが通っているのはJava11だった。
# パスが通っているのはJava11だった
$ mvn -v
...省略...
Java version: 11, vendor: Oracle Corporation, runtime: C:\apps\Java\jdk-11
Default locale: ja_JP, platform encoding: MS932
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
対応 : Java8にパスを通して使う
- 環境変数のJAVA_HOMEでJava8を設定してパスを通す
- 今一度実行する
# Java8を使うようにパスを通す
$ mvn -v
...省略...
Java version: 1.8.0_251, vendor: Oracle Corporation, runtime: C:\apps\Java\jdk1.8.0_251\jre
Default locale: ja_JP, platform encoding: MS932
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
# 今一度実行する
$ mvn install -Pstaging -DskipTests=true
事象 : Unknown host static.appfuse.org
- 環境
- CentOS Linux release 7.6.1810 (Core)
- Apache Maven 3.2.5
- Java1.8.0_242 と Java1.6.0_41
$ mvn install -Dmaven.test.skip=true
...省略...
[ERROR] Failed to execute goal on project ... Could not transfer artifact jsonic:jsonic:pom:1.2.0 from/to appfuse (http://static.appfuse.org/repository): static.appfuse.org: Name or service not known: Unknown host static.appfuse.org: Name or service not known -> [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/DependencyResolutionException
原因 : リポジトリがもうない
http://static.appfuse.org/repository
はなくなったようだ・・・あったことも知らなかったけど
対応方法 : pom.xmlのリポジトリ設定を削除する
<?xml version="1.0" encoding="UTF-8"?>
...省略...
<repositories>
...↓削除↓...
<repository>
<id>appfuse</id>
<url>http://static.appfuse.org/repository</url>
</repository>
...↑削除↑...
<repository>
<id>central</id>
<url>http://repo1.maven.org/maven2</url>
</repository>
...省略...
事象 : Return code is: 501, ReasonPhrase: HTTPS Required.
事象1のエラーで-e
オプションを知った。
To see the full stack trace of the errors, re-run Maven with the -e switch.
$ mvn install -Dmaven.test.skip=true -e
...省略...
Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: http://repo1.maven.org/maven2/junit/junit/4.7/junit-4.7.pom. Return code is: 501, ReasonPhrase: HTTPS Required.
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.resourceExists(AbstractHttpClientWagon.java:740)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.resourceExists(AbstractHttpClientWagon.java:696)
at org.eclipse.aether.transport.wagon.WagonTransporter$PeekTaskRunner.run(WagonTransporter.java:518)
at org.eclipse.aether.transport.wagon.WagonTransporter.execute(WagonTransporter.java:427)
at org.eclipse.aether.transport.wagon.WagonTransporter.peek(WagonTransporter.java:398)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$PeekTaskRunner.runTask(BasicRepositoryConnector.java:376)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:350)
... 40 more
[ERROR]
[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/DependencyResolutionException
原因 : repo.maven.apache.org/maven2/
ではHTTPが使えなくなったから
Central 501 HTTPS Required – Sonatype Support
対応 : pom.xmlのリポジトリ設定をHTTPSに変更する
<?xml version="1.0" encoding="UTF-8"?>
...省略...
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
...省略...
事象 : SSLException: Received fatal alert: protocol_version
$ mvn install -Dmaven.test.skip=true -e
Caused by: javax.net.ssl.SSLException: Received fatal alert: protocol_version
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1902)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1074)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1320)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1347)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1331)
at org.apache.maven.wagon.providers.http.httpclient.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:275)
at org.apache.maven.wagon.providers.http.httpclient.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:254)
at org.apache.maven.wagon.providers.http.httpclient.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:123)
at org.apache.maven.wagon.providers.http.httpclient.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:318)
at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:363)
at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.MainClientExec.execute(MainClientExec.java:219)
at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec.execute(RetryExec.java:86)
at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
at org.apache.maven.wagon.providers.http.httpclient.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.maven.wagon.providers.http.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.execute(AbstractHttpClientWagon.java:848)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.resourceExists(AbstractHttpClientWagon.java:708)
... 46 more
[ERROR]
[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/DependencyResolutionException
原因 : repo.maven.apache.org/maven2/
ではTLSv1.0とTLSv1.1は使えないから
JDK8はデフォルトでTLSv1.2になるらしいが・・・プロジェクトはJDK6だからTLS v1.1になってしまったのかしら?
Diagnosing TLS, SSL, and HTTPS | Oracle Java Platform Group, Product Management Blog
対応方法 : -Dhttps.protocols=TLSv1.2
を指定する
Java7 環境で maven が失敗する (Received fatal alert: protocol_version) - Qiita
$ mvn install -Dmaven.test.skip=true -e -Dhttps.protocols=TLSv1.2
...省略...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.980 s
[INFO] Finished at: 2020-04-14T21:34:21+09:00
[INFO] Final Memory: 22M/962M
[INFO] ------------------------------------------------------------------------
事象 : Could not transfer artifact jsonic:jsonic:pom:1.2.0 from/to central
$ mvn install -Dmaven.test.skip=true -e
...省略...
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact jsonic:jsonic:pom:1.2.0 from/to central (https://repo1.maven.org/maven2): Received fatal alert: protocol_version
at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:43)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
... 35 more
Caused by: org.apache.maven.wagon.TransferFailedException: Received fatal alert: protocol_version
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:1085)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:977)
at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:116)
at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
at org.eclipse.aether.transport.wagon.WagonTransporter$GetTaskRunner.run(WagonTransporter.java:560)
at org.eclipse.aether.transport.wagon.WagonTransporter.execute(WagonTransporter.java:427)
at org.eclipse.aether.transport.wagon.WagonTransporter.get(WagonTransporter.java:404)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask(BasicRepositoryConnector.java:447)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:350)
... 40 more
Caused by: javax.net.ssl.SSLException: Received fatal alert: protocol_version
...省略...
原因1 : もうCentralポジトリにgroupIdがjsonic
のjsonic
はない
Maven Repository: Search/Browse/Exploreで検索すると・・・ない
<dependency>
<groupId>jsonic</groupId>
<artifactId>jsonic</artifactId>
<version>1.2.0</version>
</dependency>
対応 : 違うgroupIdとversionのjsonic
にする
セントラルリポジトリにはjsonicのバージョン1.2.0がなかったのでバージョンも上げる
<dependency>
<groupId>net.arnx</groupId>
<artifactId>jsonic</artifactId>
<version>1.2.7</version>
</dependency>
原因2 : .m2
ディレクトリの持ち主が自分じゃないから
原因と対応方法は Dockerで作った環境のMavenで/home/path/.m2/repository/x.pom.part.lock (Permission denied)となった時の対応方法 - Qiita
事象 : Fatal error compiling: 1.8は無効なターゲット・リリースです
maven-compiler-plugin
でJava1.8を指定したら怒られた。
$ mvn install -Dmaven.test.skip=true
...省略...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project プロジェクト: Fatal error compiling: 1.8は無効なターゲット・リリースです -> [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/MojoExecutionException
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
原因 : 現在のJavaとMavenで使っているJavaのバージョンが違うから
参考 : Maven に JDK 1.8 を認識させる - blog.kymmt.com
Mavenは、JAVA_HOMEがあるとJavaを使うそうです。
# Mavenが使っているのはJava1.6
$ mvn -v
...省略...
Java version: 1.6.0_41, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.41.x86_64/jre
...省略...
# JAVA_HOMEもJava1.6
$ printenv JAVA_HOME
/usr/lib/jvm/java-1.6.0-openjdk.x86_64
# 使っているのはJava1.8
$ java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
対応 : JAVA_HOMEを削除してMavenが使うJavaのバージョンを変更する
削除しないでJAVA_HOMEを変更する手段もある。
# JAVA_HOMEを削除して、
$ unset JAVA_HOME
# .bash_profile のJAVA_HOME設定をコメントアウトして
$ vi ~/.bash_profile
cat ~/.bash_profile
...省略...
#JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk.x86_64
#export JAVA_HOME
# 反映すると
$ source ~/.bash_profile
[1]+ Done exec ibus-daemon -dx
# JAVA_HOMEがなくなり、
$ printenv JAVA_HOME
$
# Mavenが使うJavaが、Java1.8になる
$ mvn -v
...省略...
Java version: 1.8.0_242, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre
...省略...
# そうするとエラーが解消する
$ mvn install -Dmaven.test.skip=true
...省略...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.202 s
[INFO] Finished at: 2020-04-15T11:33:39+09:00
[INFO] Final Memory: 18M/749M
[INFO] ------------------------------------------------------------------------
事象 : was cached in the local repository, resolution will not be reattempted until the update interval of local has elapsed or updates are forced
$ mvn install -Dmaven.test.skip=true -e
...省略...
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Failure to find ... was cached in the local repository, resolution will not be reattempted until the update interval of local has elapsed or updates are forced
at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:231)
at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:206)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:585)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:503)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
... 40 more
[ERROR]
[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/DependencyResolutionException
原因1 : キャッシュ?
[Eclipse]pom.xmlで余計なキャッシュのせいでエラーが発生 | ntの備忘録
対応方法 : .m2/repository/org/apache/maven
ディレクトリを削除する
$ rm -rf ~/.m2/repository/org/apache/maven
原因2 : 依存関係にあるプロジェクトのjarがないから
$ mvn install -Dmaven.test.skip=true -e
...省略...
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for jp.co.hoge:hoge-framework-fuga:jar:3.0.0
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:337)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:217)
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.resolveCachedArtifactDescriptor(DefaultDependencyCollector.java:525)
...省略...
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Failure to find ...was cached in the local repository, resolution will not be reattempted until the update interval of local has elapsed or updates are forced
at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:231)
at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:206)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:585)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:503)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
... 40 more
[ERROR]
[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/DependencyResolutionException
対応方法 : 依存関係にあるプロジェクトのjarを作ってからやり直す
STS(eclipse)からmavenビルドでjarファイルを作ろうとしたらエラーになった話 | ヰ刀のおもちゃ箱
今回の場合は、依存関係にあるhoge-framework-fuga
プロジェクトのjarを作ってからやり直す
原因3 : リポジトリがないかURLが古い
Eclipseで、プロジェクトを選択 > [Maven] > [Update Project...]したらErrorになった時のこと
Failure to transfer javax.resource:connector:jar:1.0 from http://maven.ow2.org/maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of ow2.org has elapsed or updates are forced. Original error: Could not transfer artifact javax.resource:connector:jar:1.0 from/to ow2.org (http://maven.ow2.org/maven2/): Cannot access http://maven.ow2.org/maven2/ with type legacy using the available connector factories: AetherRepositoryConnectorFactory, BasicRepositoryConnectorFactory
...省略...
Failure to transfer javax.resource:connector:jar:1.0 from http://download.java.net/maven/2/ was cached in the local repository, resolution will not be reattempted until the update interval of java.net has elapsed or updates are forced. Original error: Could not transfer artifact javax.resource:connector:jar:1.0 from/to java.net (http://download.java.net/maven/2/): Cannot access http://download.java.net/maven/2/ with type legacy using the available connector factories: AetherRepositoryConnectorFactory, BasicRepositoryConnectorFactory
...省略...
対応方法 : リポジトリの設定を修正する
- エラーになっている
http://maven.ow2.org/maven2/
はブラウザでアクセスするとhttps://repository.ow2.org/nexus/content/repositories/ow2-legacy/
へリダイレクトされるのでリダイレクトされたURLへ変更する - エラーになっている
http://download.java.net/maven/2/
はブラウザでアクセスするとWe're sorry, the page you requested was not found.
となるので削除する - プロジェクトを選択 > [Maven] > [Update Project...]を再度実行
↓削除↓
<repository>
<id>java.net</id>
<url>http://download.java.net/maven/2/</url>
</repository>
↑削除↑
<repository>
<id>ow2.org</id>
↓URL変更↓
<url>http://maven.ow2.org/maven2/</url>
</repository>
事象 : Mavenリポジトリにない独自のjarを指定したらCould not find artifact jp.co.hoge.fuga:hoge-fuga-project:pom
Mavenリポジトリにない独自のjarを指定したら、その親プロジェクトのpomがないと言われた・・・
$ mvn install -Dmaven.test.skip=true -e
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact jp.co.hoge.fuga:hoge-fuga-project:pom:2.0.0 in local (file:/home/fuga/hoge-fuga-project/hoge-framework-core/../repo)
at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
... 40 more
[ERROR]
[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/DependencyResolutionException
原因 : 不明
以下サイトの「ローカルリポジトリにインストールする方法その1」みたいなことをやっている。
Mavenリポジトリにないライブラリをpom.xmlで指定する方法 - grep Tips *
対応方法 : pomがないと言われたプロジェクトのpom.xmlをコピーした
Could not find artifact jp.co.hoge.fuga:hoge-fuga-project:pom:2.0.0
と言われたので
{ユーザホーム}/.m2/repository/jp/co/hoge/fuga/hoge-fuga-project/pom/2.0.0/
ディレクトリ配下に
プロジェクトのpomをhoge-fuga-project-2.0.0.pom
(.xmlは不要)にリネームしてコピーしてしのいだ。
ちゃんとした原因と対応方法を知りたい。