TakayukiKoyama Geek Blog

Create, Entertain, Experience

aws-apigateway-importer mvn assembly:assemblyエラー解決

目的

 以下のようなエラーが出たときの解決策を記す。

1) Error injecting constructor, java.lang.NoClassDefFoundError: javax/xml/bind/SchemaOutputResolver
  at org.raml.parser.visitor.RamlDocumentBuilder.<init>(RamlDocumentBuilder.java:46)
  while locating org.raml.parser.visitor.RamlDocumentBuilder
    for parameter 0 at com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporter.<init>(ApiGatewayRamlFileImporter.java:37)
  while locating com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporter
  while locating com.amazonaws.service.apigateway.importer.RamlApiFileImporter

(略)

testImport_create_resources(com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporterTest)  Time elapsed: 0.006 sec  <<< ERROR!
com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error injecting constructor, java.lang.NoClassDefFoundError: javax/xml/bind/SchemaOutputResolver
  at org.raml.parser.visitor.RamlDocumentBuilder.<init>(RamlDocumentBuilder.java:46)
  while locating org.raml.parser.visitor.RamlDocumentBuilder
    for parameter 0 at com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporter.<init>(ApiGatewayRamlFileImporter.java:37)
  while locating com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporter
  while locating com.amazonaws.service.apigateway.importer.RamlApiFileImporter

(略)

testImport_create_methods(com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporterTest)  Time elapsed: 0.007 sec  <<< ERROR!
com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error injecting constructor, java.lang.NoClassDefFoundError: javax/xml/bind/SchemaOutputResolver
  at org.raml.parser.visitor.RamlDocumentBuilder.<init>(RamlDocumentBuilder.java:46)
  while locating org.raml.parser.visitor.RamlDocumentBuilder
    for parameter 0 at com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporter.<init>(ApiGatewayRamlFileImporter.java:37)
  while locating com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporter
  while locating com.amazonaws.service.apigateway.importer.RamlApiFileImporter

(略)

testImport_create_models(com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporterTest)  Time elapsed: 0.005 sec  <<< ERROR!
com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error injecting constructor, java.lang.NoClassDefFoundError: javax/xml/bind/SchemaOutputResolver
  at org.raml.parser.visitor.RamlDocumentBuilder.<init>(RamlDocumentBuilder.java:46)
  while locating org.raml.parser.visitor.RamlDocumentBuilder
    for parameter 0 at com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporter.<init>(ApiGatewayRamlFileImporter.java:37)
  while locating com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporter
  while locating com.amazonaws.service.apigateway.importer.RamlApiFileImporter

(略)

Running com.amazonaws.service.apigateway.importer.integration.LargeApiIntegrationTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0 sec
Running com.amazonaws.service.apigateway.importer.ApiImporterMainTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0 sec

Results :

Tests in error:
  testImport_create_api(com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporterTest): Unable to provision, see the following errors:(..)
  testImport_create_resources(com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporterTest): Unable to provision, see the following errors:(..)
  testImport_create_methods(com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporterTest): Unable to provision, see the following errors:(..)
  testImport_create_models(com.amazonaws.service.apigateway.importer.impl.ApiGatewayRamlFileImporterTest): Unable to provision, see the following errors:(..)

Tests run: 22, Failures: 0, Errors: 4, Skipped: 2

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.399 s
[INFO] Finished at: 2018-08-04T22:07:17+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project aws-apigateway-importer: There are test failures.
[ERROR]
[ERROR] Please refer to /Users/koyamatakayuki/opt/ePRO/aws-apigateway-swagger-importer/target/surefire-reports for the individual test results.
[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

解決策

mvn assembly:assembly

mvn assembly:assembly -DskipTests

 開発者はテストでコケて困ると思うが、使用者はビルドさえ通れば良いと思う。

参考

Getting Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20.1:test (default-test) on project TestSetup: There are test failures. · Issue #1693 · cbeust/testng · GitHub

Tips: API Gatewayのエクスポート/インポートでハマったところ