eclipse-ditto / ditto

Eclipse Ditto™: Digital Twin framework of Eclipse IoT - main repository
https://eclipse.dev/ditto/
Eclipse Public License 2.0
695 stars 230 forks source link

Cannot build ditto with maven #1836

Closed liuyinling closed 12 months ago

liuyinling commented 12 months ago

Hello, I am using maven to build ditto. The terminal shows the errors in the following. It tells the error relating to JSON. I would like to know how to fix it.

I am using Macbook M1 Pro with Sonoma 14.1.2. The JDK version is 18. The maven version 3.9.6.

If you need more information, just let me know. Thanks a lot!

[INFO] 
[ERROR] Tests run: 931, Failures: 0, Errors: 10, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Eclipse Ditto 0-SNAPSHOT:
[INFO] 
[INFO] Eclipse Ditto ...................................... SUCCESS [  1.177 s]
[INFO] Eclipse Ditto :: Legal ............................. SUCCESS [  0.192 s]
[INFO] Eclipse Ditto :: BOM ............................... SUCCESS [  0.036 s]
[INFO] Eclipse Ditto :: Utils ............................. SUCCESS [  0.067 s]
[INFO] Eclipse Ditto :: Utils :: JSR-305 Extensions ....... SUCCESS [  0.628 s]
[INFO] Eclipse Ditto :: JSON .............................. FAILURE [  3.290 s]
[INFO] Eclipse Ditto :: Base .............................. SKIPPED
[INFO] Eclipse Ditto :: Base :: Model ..................... SKIPPED
[INFO] Eclipse Ditto :: Base :: API ....................... SKIPPED
[INFO] Eclipse Ditto :: Internal .......................... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils ................. SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Config ....... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Metrics ...... SKIPPED
[INFO] Eclipse Ditto :: Utils :: Result ................... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Tracing ...... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Models ................ SKIPPED
[INFO] Eclipse Ditto :: Internal :: Models :: Streaming ... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Pekko ........ SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Health ....... SKIPPED
[INFO] Eclipse Ditto :: JSON CBOR ......................... SKIPPED
[INFO] Eclipse Ditto :: Policies .......................... SKIPPED
[INFO] Eclipse Ditto :: Policies :: Model ................. SKIPPED
[INFO] Eclipse Ditto :: Things ............................ SKIPPED
[INFO] Eclipse Ditto :: Things :: Model ................... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Cluster ...... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Extension .... SKIPPED
[INFO] Eclipse Ditto :: Placeholders ...................... SKIPPED
[INFO] Eclipse Ditto :: Base :: Service ................... SKIPPED
[INFO] Eclipse Ditto :: Connectivity ...................... SKIPPED
[INFO] Eclipse Ditto :: Connectivity :: Model ............. SKIPPED
[INFO] Eclipse Ditto :: Thing Search ...................... SKIPPED
[INFO] Eclipse Ditto :: Thing Search :: Model ............. SKIPPED
[INFO] Eclipse Ditto :: Messages .......................... SKIPPED
[INFO] Eclipse Ditto :: Messages :: Model ................. SKIPPED
[INFO] Eclipse Ditto :: Protocol .......................... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Models :: Signal ...... SKIPPED
[INFO] Eclipse Ditto :: Policies :: API ................... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Distributed Data SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Pub-Sub ...... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Cache ........ SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Test ......... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Persistence .. SKIPPED
[INFO] Eclipse Ditto :: Things :: API ..................... SKIPPED
[INFO] Eclipse Ditto :: Connectivity :: API ............... SKIPPED
[INFO] Eclipse Ditto :: JWT ............................... SKIPPED
[INFO] Eclipse Ditto :: JWT :: Model ...................... SKIPPED
[INFO] Eclipse Ditto :: WoT ............................... SKIPPED
[INFO] Eclipse Ditto :: WoT :: Model ...................... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Cache Loaders  SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Namespaces ... SKIPPED
[INFO] Eclipse Ditto :: Policies :: Enforcement ........... SKIPPED
[INFO] Eclipse Ditto :: RQL ............................... SKIPPED
[INFO] Eclipse Ditto :: RQL :: Model ...................... SKIPPED
[INFO] Eclipse Ditto :: RQL :: parser ..................... SKIPPED
[INFO] Eclipse Ditto :: RQL :: Query ...................... SKIPPED
[INFO] Eclipse Ditto :: Thing Search :: API ............... SKIPPED
[INFO] Eclipse Ditto :: Edge .............................. SKIPPED
[INFO] Eclipse Ditto :: Edge :: Service ................... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Models :: Signal Enrichment SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Conditional Headers SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Persistent Actors SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Protocol ..... SKIPPED
[INFO] Eclipse Ditto :: RQL :: search option parser ....... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Search ....... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Pub-Sub Policies SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: Pub-Sub Things SKIPPED
[INFO] Eclipse Ditto :: Connectivity :: Service ........... SKIPPED
[INFO] Eclipse Ditto :: Documentation ..................... SKIPPED
[INFO] Eclipse Ditto :: Gateway ........................... SKIPPED
[INFO] Eclipse Ditto :: Gateway :: API .................... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: HTTP ......... SKIPPED
[INFO] Eclipse Ditto :: Internal :: Utils :: JWT .......... SKIPPED
[INFO] Eclipse Ditto :: Gateway :: Service ................ SKIPPED
[INFO] Eclipse Ditto :: Policies :: Service ............... SKIPPED
[INFO] Eclipse Ditto :: WoT :: Integration ................ SKIPPED
[INFO] Eclipse Ditto :: Things :: Service ................. SKIPPED
[INFO] Eclipse Ditto :: Thing Search :: Service ........... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.942 s
[INFO] Finished at: 2023-12-07T09:14:31+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.1.2:test (default-test) on project ditto-json: 
[ERROR] 
[ERROR] Please refer to /Users/yinlingliu/Git/ditto/json/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[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
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :ditto-json
thjaeckle commented 12 months ago

What are the 10 test errors mentioned in the log?

liuyinling commented 12 months ago

Here are all the errors in the terminal.

[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   ImmutableJsonArrayTest.assertImmutability:56 » MutabilityAnalysis 
An unhandled error occurred. Please read message at end of this output.

Class being analysed: org.eclipse.ditto.json.ImmutableJsonArray
Checker that failed: MutableTypeToFieldChecker
Classes analysed so far:
    org.eclipse.ditto.json.ImmutableJsonBoolean
    org.eclipse.ditto.json.ImmutableJsonParseOptions
    org.eclipse.ditto.json.JsonCharEscaper
    org.eclipse.ditto.json.JsonValue
    org.eclipse.ditto.json.ImmutableJsonObjectNull
    org.eclipse.ditto.json.ImmutableJsonArrayNull
    org.eclipse.ditto.json.JsonValueFieldDefinition
    org.eclipse.ditto.json.JsonMergePatch
    org.eclipse.ditto.json.JsonKey
    org.eclipse.ditto.json.ImmutableJsonNull
    org.eclipse.ditto.json.ImmutableJsonDouble
    org.eclipse.ditto.json.JsonValueParser
    org.eclipse.ditto.json.JsonCollectors
    org.eclipse.ditto.json.ImmutableJsonLong
    org.eclipse.ditto.json.ImmutableJsonInt
    org.eclipse.ditto.json.JsonFieldDefinition
    org.eclipse.ditto.json.JsonFactory
    org.eclipse.ditto.json.JavaValueFieldDefinition
    org.eclipse.ditto.json.JsonParseException
    org.eclipse.ditto.json.JsonObjectMerger

An unhandled error occurred while analysing the class 'org.eclipse.ditto.json.ImmutableJsonArray'.

This is probably my fault, not yours, and I am sorry.
I'd love to get an opportunity to fix this, please report as an issue at:
 https://github.com/MutabilityDetector/MutabilityDetector/issues/ 
Pasting in this error message and stack trace, and if possible, 
information about the code causing the error. 
For example, one of: 
    .class files (preferably with source);
    compilable .java files; 
    a jar (again preferably with source);
    or, if your project is open source, information on where I can get the code from
        (I'm happy to checkout and build your project in order to investigate the error).

Apologies, and thank you for using Mutability Detector.

[ERROR]   ImmutableJsonFieldSelectorFactoryTest.assertImmutability:41 » MutabilityAnalysis 
An unhandled error occurred. Please read message at end of this output.

Class being analysed: org.eclipse.ditto.json.ImmutableJsonFieldSelectorFactory
Checker that failed: MutableTypeToFieldChecker
Classes analysed so far:

An unhandled error occurred while analysing the class 'org.eclipse.ditto.json.ImmutableJsonFieldSelectorFactory'.

[ERROR]   ImmutableJsonFieldSelectorTest.assertImmutability:40 » MutabilityAnalysis 
An unhandled error occurred. Please read message at end of this output.

Class being analysed: org.eclipse.ditto.json.ImmutableJsonFieldSelector
Checker that failed: MutableTypeToFieldChecker
Classes analysed so far:
    org.eclipse.ditto.json.ImmutableJsonBoolean
    org.eclipse.ditto.json.JsonValue
    org.eclipse.ditto.json.ImmutableJsonObjectNull
    org.eclipse.ditto.json.JsonKey
    org.eclipse.ditto.json.ImmutableJsonInt
    org.eclipse.ditto.json.JsonFieldDefinition
    org.eclipse.ditto.json.ImmutableJsonNull
    org.eclipse.ditto.json.ImmutableJsonDouble
    org.eclipse.ditto.json.JsonCollectors
    org.eclipse.ditto.json.JsonFactory
    org.eclipse.ditto.json.JsonObjectMerger

An unhandled error occurred while analysing the class 'org.eclipse.ditto.json.ImmutableJsonFieldSelector'.

[ERROR]   ImmutableJsonFieldTest.assertImmutability:55 » MutabilityAnalysis 
An unhandled error occurred. Please read message at end of this output.

Class being analysed: org.eclipse.ditto.json.ImmutableJsonField
Checker that failed: MutableTypeToFieldChecker
Classes analysed so far:
    org.eclipse.ditto.json.ImmutableJsonBoolean
    org.eclipse.ditto.json.ImmutableJsonInt
    org.eclipse.ditto.json.ImmutableJsonDouble
    org.eclipse.ditto.json.JsonFactory

An unhandled error occurred while analysing the class 'org.eclipse.ditto.json.ImmutableJsonField'.

[ERROR]   ImmutableJsonKeyTest.assertImmutability:31 » MutabilityAnalysis 
An unhandled error occurred. Please read message at end of this output.

Class being analysed: org.eclipse.ditto.json.ImmutableJsonKey
Checker that failed: MutableTypeToFieldChecker
Classes analysed so far:

An unhandled error occurred while analysing the class 'org.eclipse.ditto.json.ImmutableJsonKey'.

[ERROR]   ImmutableJsonObjectTest.assertImmutability:75 » MutabilityAnalysis 
An unhandled error occurred. Please read message at end of this output.

Class being analysed: org.eclipse.ditto.json.ImmutableJsonObject
Checker that failed: MutableTypeToFieldChecker
Classes analysed so far:
    org.eclipse.ditto.json.ImmutableJsonInt
    org.eclipse.ditto.json.JsonFactory

An unhandled error occurred while analysing the class 'org.eclipse.ditto.json.ImmutableJsonObject'.

[ERROR]   ImmutableJsonPatchTest.assertImmutability:37 » MutabilityAnalysis 
An unhandled error occurred. Please read message at end of this output.

Class being analysed: org.eclipse.ditto.json.ImmutableJsonPatch
Checker that failed: MutableTypeToFieldChecker
Classes analysed so far:

An unhandled error occurred while analysing the class 'org.eclipse.ditto.json.ImmutableJsonPatch'.

[ERROR]   ImmutableJsonPointerTest.assertImmutability:42 » MutabilityAnalysis 
An unhandled error occurred. Please read message at end of this output.

Class being analysed: org.eclipse.ditto.json.ImmutableJsonPointer
Checker that failed: MutableTypeToFieldChecker
Classes analysed so far:
    org.eclipse.ditto.json.ImmutableJsonBoolean
    org.eclipse.ditto.json.ImmutableJsonParseOptions
    org.eclipse.ditto.json.JsonCharEscaper
    org.eclipse.ditto.json.JsonValue
    org.eclipse.ditto.json.ImmutableJsonObjectNull
    org.eclipse.ditto.json.ImmutableJsonArrayNull
    org.eclipse.ditto.json.JsonValueFieldDefinition
    org.eclipse.ditto.json.JsonMergePatch
    org.eclipse.ditto.json.JsonKey
    org.eclipse.ditto.json.ImmutableJsonNull
    org.eclipse.ditto.json.ImmutableJsonDouble
    org.eclipse.ditto.json.JsonValueParser
    org.eclipse.ditto.json.JsonCollectors
    org.eclipse.ditto.json.ImmutableJsonLong
    org.eclipse.ditto.json.ImmutableJsonInt
    org.eclipse.ditto.json.JsonFieldDefinition
    org.eclipse.ditto.json.JsonFactory
    org.eclipse.ditto.json.JavaValueFieldDefinition
    org.eclipse.ditto.json.JsonParseException
    org.eclipse.ditto.json.JsonObjectMerger

An unhandled error occurred while analysing the class 'org.eclipse.ditto.json.ImmutableJsonPointer'.

[ERROR]   ImmutableJsonStringTest.assertImmutability:36 » MutabilityAnalysis 
An unhandled error occurred. Please read message at end of this output.

Class being analysed: org.eclipse.ditto.json.ImmutableJsonString
Checker that failed: MutableTypeToFieldChecker
Classes analysed so far:
    org.eclipse.ditto.json.ImmutableJsonBoolean
    org.eclipse.ditto.json.ImmutableJsonParseOptions
    org.eclipse.ditto.json.JsonCharEscaper
    org.eclipse.ditto.json.JsonValue
    org.eclipse.ditto.json.ImmutableJsonObjectNull
    org.eclipse.ditto.json.ImmutableJsonArrayNull
    org.eclipse.ditto.json.JsonValueFieldDefinition
    org.eclipse.ditto.json.JsonMergePatch
    org.eclipse.ditto.json.JsonKey
    org.eclipse.ditto.json.ImmutableJsonNull
    org.eclipse.ditto.json.ImmutableJsonDouble
    org.eclipse.ditto.json.JsonValueParser
    org.eclipse.ditto.json.JsonCollectors
    org.eclipse.ditto.json.ImmutableJsonLong
    org.eclipse.ditto.json.ImmutableJsonInt
    org.eclipse.ditto.json.JsonFieldDefinition
    org.eclipse.ditto.json.JsonFactory
    org.eclipse.ditto.json.JavaValueFieldDefinition
    org.eclipse.ditto.json.JsonParseException
    org.eclipse.ditto.json.JsonObjectMerger

An unhandled error occurred while analysing the class 'org.eclipse.ditto.json.ImmutableJsonString'.

[ERROR]   JavaStringToEscapedJsonStringTest.assertImmutability:34 » MutabilityAnalysis 
An unhandled error occurred. Please read message at end of this output.

Class being analysed: org.eclipse.ditto.json.JavaStringToEscapedJsonString
Checker that failed: MutableTypeToFieldChecker
Classes analysed so far:
    org.eclipse.ditto.json.ImmutableJsonBoolean
    org.eclipse.ditto.json.JsonValue
    org.eclipse.ditto.json.ImmutableJsonObjectNull
    org.eclipse.ditto.json.JsonKey
    org.eclipse.ditto.json.ImmutableJsonInt
    org.eclipse.ditto.json.JsonFieldDefinition
    org.eclipse.ditto.json.ImmutableJsonNull
    org.eclipse.ditto.json.ImmutableJsonDouble
    org.eclipse.ditto.json.JsonCollectors
    org.eclipse.ditto.json.JsonFactory
    org.eclipse.ditto.json.JsonObjectMerger

An unhandled error occurred while analysing the class 'org.eclipse.ditto.json.JavaStringToEscapedJsonString'.
thjaeckle commented 12 months ago

Then I assume that could have to do with JDK 18. Eclipse Ditto is currently compiled with JDK 17 - we did not yet test it with greater versions.

So either skip the unit tests by building -DskipTests or please build Ditto with JDK 17 (as you might also run into other issues).

liuyinling commented 12 months ago

I tried with JDK 17. I got these three errors.

[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   IndexInitializerIT.<clinit>:53 » ExceptionInInitializer
[ERROR]   MongoReadJournalIT.<clinit>:73 » NoClassDefFound Could not initialize class org.eclipse.ditto.internal.utils.test.docker.mongo.MongoContainerFactory
[ERROR]   MongoTimestampPersistenceIT.<clinit>:53 » NoClassDefFound Could not initialize class org.eclipse.ditto.internal.utils.test.docker.mongo.MongoContainerFactory
[INFO] 
[ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0
alstanchev commented 12 months ago

This one looks like you don't have docker running.

liuyinling commented 12 months ago

The engine of docker was running.

@thjaeckle this command mvn clean install -DskipTests works well.

However, when I build local Ditto Docker snapshot images by using ./build-images.sh, I got the following error

=> ERROR [4/4] COPY ./dist                 ./dist                         0.0s
------
 > [4/4] COPY ./dist                 ./dist:
------
Dockerfile:17
--------------------
  15 |     
  16 |     COPY ./index.html           .
  17 | >>> COPY ./dist                 ./dist
  18 |     
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 6026d1d0-f35c-4c48-a6cf-68de82b927d4::w6b571i2pc20htqz30pguehem: "/dist": not found

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/t089mgvqx8dahctc03owkfur4
thjaeckle commented 12 months ago

Please have a look here: #1699 We did not yet manage to address this - e.g. perform step 3. from the linked issue.

thjaeckle commented 12 months ago

I updated to ./build-images.sh script and by default excluded the UI build - so this should work now for you.

liuyinling commented 12 months ago

Yes, indeed, ./build-images.sh script works well.

However, when I executed docker-compose up -d command, I got the following error parsing /Users/yinlingliu/Git/ditto/deployment/docker/docker-compose.yml: yaml: line 13: did not find expected key