eclipse-tractusx / tractusx-edc

Apache License 2.0
45 stars 54 forks source link

Encountering a java.lang.NullPointerException error while trying to retrieve the 'secret1' secret from HashiCorp Vault. This issue prevents the application from starting up properly. #1248

Closed amnaishaq closed 5 months ago

amnaishaq commented 7 months ago

Steps to Reproduce

Configure the application to retrieve the 'secret1' secret from HashiCorp Vault. Start the application. Observe the error when attempting to retrieve the secret.

Expected Behavior

The application should be able to retrieve the 'secret1' secret from HashiCorp Vault without errors and start up correctly.

Tentative Steps for Resolution

Verify the HashiCorp Vault configuration for the 'secret1' secret. Investigate and address the root cause of the java.lang.NullPointerException error.

# Configuración de Vault HashiCorp
edc.vault.hashicorp.url=http://my-vault:8200
edc.vault.hashicorp.token=123456789
edc.vault.hashicorp.secret_path=secret/data/vault/data
edc.vault.hashicorp.secret_key=secret1

# Configuración de la base de datos PostgreSQL
database.url=jdbc:postgresql://localhost:5432/tractusx
database.username=amna
database.password=amna

# Configuración de OAuth2
tx.ssi.oauth.client.id=w6AIMQfS8KnokquAMGQsgP6k6QqWzgmm
#tx.ssi.oauth.client.secret=DUzJHQTnIHFUsCp5QXvk3BPXtSq1S-xVIF4FO1eFqI9eQjFB9XdCEEebyxfCt3V5
tx.ssi.oauth.client.secret.alias=secret1
tx.ssi.oauth.client.secret.id=z3iwTVc4G3r1TXhGT4alg9lMsKR8ubWT
tx.ssi.oauth.authorization.url=dev-qssiii8v6z2dvbe2.us.auth0.com
tx.ssi.oauth.token.url=https://dev-qssiii8v6z2dvbe2.us.auth0.com/oauth/token

edc.oauth.token.url=https://dev-qssiii8v6z2dvbe2.us.auth0.com
edc.oauth.public.key.alias=secret1
edc.oauth.client.id=z3iwTVc4G3r1TXhGT4alg9lMsKR8ubWT
#edc.oauth.private.key.alias=1vidip12366545fkodojvdknv=

ERROR

amna@amna:~/tractusX/tractusx-edc$ docker run --name mi-conector -p 8080:8080 -p 8383:8383 -p 8282:8282 -p 9191:9191 -p 9999:9999 -v "$PWD/configuration.properties:/app/configuration.properties" -v "$PWD/logging.properties:/app/logging.properties" -v "$PWD/opentelemetry.properties:/app/opentelemetry.properties" --network my-network edc-controlplane-postgresql-hashicorp-vault:latest
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
[otel.javaagent 2024-04-22 06:13:18:005 +0000] [main] INFO io.opentelemetry.javaagent.tooling.VersionLogger - opentelemetry-javaagent - version: 1.32.0
INFO 2024-04-22T06:13:20.687287978 Initialized FS Configuration
WARNING 2024-04-22T06:13:20.702298548 The runtime is configured as an anonymous participant. DO NOT DO THIS IN PRODUCTION.
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
INFO 2024-04-22T06:13:21.187280978 Initialized Micrometer Metrics
INFO 2024-04-22T06:13:21.188888195 Initialized Boot Services
INFO 2024-04-22T06:13:21.444616381 Initialized Core Default Services
INFO 2024-04-22T06:13:21.605909451 HTTPS enforcement it not enabled, please enable it in a production environment
INFO 2024-04-22T06:13:21.624133958 HTTPS enforcement it not enabled, please enable it in a production environment
INFO 2024-04-22T06:13:21.638934564 Initialized Hashicorp Vault
INFO 2024-04-22T06:13:21.675571542 Initialized Core Services
WARNING 2024-04-22T06:13:21.680447569 Settings: No setting found for key 'edc.hostname'. Using default value 'localhost'
INFO 2024-04-22T06:13:21.706678108 Initialized JSON-LD Extension
WARNING 2024-04-22T06:13:21.909622966 Error caching context URL 'https://w3id.org/dspace/2024/1/context.json' for URI 'jar:file:/app/edc-controlplane.jar!/document/dspace.jsonld'. Subsequent attempts to expand this context URL may fail.
INFO 2024-04-22T06:13:21.915967524 Initialized Local Transaction
INFO 2024-04-22T06:13:21.916328846 Initialized SQL Core
INFO 2024-04-22T06:13:21.926321994 Initialized org.eclipse.edc.connector.store.sql.assetindex.SqlAssetIndexServiceExtension
INFO 2024-04-22T06:13:21.933672925 Initialized org.eclipse.edc.connector.store.sql.contractnegotiation.SqlContractNegotiationStoreExtension
INFO 2024-04-22T06:13:21.965751053 Initialized org.eclipse.edc.connector.store.sql.policydefinition.SqlPolicyStoreExtension
INFO 2024-04-22T06:13:21.967212513 Initialized Control Plane Default Services
INFO 2024-04-22T06:13:21.972854037 Initialized org.eclipse.edc.connector.store.sql.contractdefinition.SqlContractDefinitionStoreExtension
INFO 2024-04-22T06:13:21.973580649 Initialized org.eclipse.edc.connector.contract.ContractNegotiationDefaultServicesExtension
INFO 2024-04-22T06:13:22.119627438 Initialized Jetty Service
INFO 2024-04-22T06:13:22.126936294 Initialized Jersey Web Service
WARNING 2024-04-22T06:13:22.128604112 Settings for [web.http.protocol.path] and/or [web.http.protocol.path] were not provided. Using default value(s) instead.
INFO 2024-04-22T06:13:22.128945903 Protocol API will be available under port=8282, path=/api/v1/dsp
INFO 2024-04-22T06:13:22.158117518 Initialized Dataspace Protocol API Configuration Extension
INFO 2024-04-22T06:13:22.179819519 Initialized Contract Core
INFO 2024-04-22T06:13:22.181670027 Initialized Contract Negotiation command handlers
INFO 2024-04-22T06:13:22.187502378 Initialized org.eclipse.edc.connector.store.sql.transferprocess.SqlTransferProcessStoreExtension
INFO 2024-04-22T06:13:22.187905512 Initialized Transfer Process Default Services
INFO 2024-04-22T06:13:22.226233533 Initialized Transfer Core
INFO 2024-04-22T06:13:22.231151617 Initialized org.eclipse.edc.connector.transfer.TransferProcessCommandExtension
WARNING 2024-04-22T06:13:22.231765123 No 'name' setting in group edc.datasource.asset found, no schema migrations will run for subsystem asset
INFO 2024-04-22T06:13:22.232054633 Initialized Postgresql schema migration for subsystem asset
WARNING 2024-04-22T06:13:22.232314177 No 'name' setting in group edc.datasource.contractdefinition found, no schema migrations will run for subsystem contractdefinition
INFO 2024-04-22T06:13:22.232423306 Initialized Postgresql schema migration for subsystem contractdefinition
WARNING 2024-04-22T06:13:22.232621543 No 'name' setting in group edc.datasource.contractnegotiation found, no schema migrations will run for subsystem contractnegotiation
INFO 2024-04-22T06:13:22.23271833 Initialized Postgresql schema migration for subsystem contractnegotiation
WARNING 2024-04-22T06:13:22.232915502 No 'name' setting in group edc.datasource.policy found, no schema migrations will run for subsystem policy
INFO 2024-04-22T06:13:22.233089435 Initialized Postgresql schema migration for subsystem policy
WARNING 2024-04-22T06:13:22.233334956 No 'name' setting in group edc.datasource.policy-monitor found, no schema migrations will run for subsystem policy-monitor
INFO 2024-04-22T06:13:22.233431372 Initialized Postgresql schema migration for subsystem policy-monitor
WARNING 2024-04-22T06:13:22.23361873 No 'name' setting in group edc.datasource.transferprocess found, no schema migrations will run for subsystem transferprocess
INFO 2024-04-22T06:13:22.233713867 Initialized Postgresql schema migration for subsystem transferprocess
WARNING 2024-04-22T06:13:22.233919613 No 'name' setting in group edc.datasource.edr found, no schema migrations will run for subsystem edr
INFO 2024-04-22T06:13:22.234035319 Initialized Postgresql schema migration for subsystem edr
WARNING 2024-04-22T06:13:22.234255948 No 'name' setting in group edc.datasource.bpn found, no schema migrations will run for subsystem bpn
INFO 2024-04-22T06:13:22.234348525 Initialized Postgresql schema migration for subsystem bpn
INFO 2024-04-22T06:13:22.234637828 Initialized SQL Business Partner Store
INFO 2024-04-22T06:13:22.237985281 Initialized EDR Cache Core
INFO 2024-04-22T06:13:22.238408624 Initialized OAuth2 Client
INFO 2024-04-22T06:13:22.240882765 Initialized SSI MIW OAuth2 Client
DEBUG 2024-04-22T06:13:22.347609739 [Hashicorp Vault] Failed to resolve secret 'secret1': [Failed to get secret with status 404]
SEVERE 2024-04-22T06:13:22.350204684 Error booting runtime: java.lang.reflect.InvocationTargetException
org.eclipse.edc.spi.system.injection.EdcInjectionException: java.lang.reflect.InvocationTargetException
        at org.eclipse.edc.spi.system.injection.ProviderMethod.invoke(ProviderMethod.java:66)
        at org.eclipse.edc.boot.system.injection.lifecycle.RegistrationPhase.invokeAndRegister(RegistrationPhase.java:51)
        at org.eclipse.edc.boot.system.injection.lifecycle.RegistrationPhase.lambda$invokeProviderMethods$0(RegistrationPhase.java:45)
        at java.base/java.lang.Iterable.forEach(Unknown Source)
        at org.eclipse.edc.boot.system.injection.lifecycle.RegistrationPhase.invokeProviderMethods(RegistrationPhase.java:45)
        at org.eclipse.edc.boot.system.injection.lifecycle.ExtensionLifecycleManager.provide(ExtensionLifecycleManager.java:70)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
        at org.eclipse.edc.boot.system.ExtensionLoader.bootServiceExtensions(ExtensionLoader.java:67)
        at org.eclipse.edc.boot.system.runtime.BaseRuntime.bootExtensions(BaseRuntime.java:139)
        at org.eclipse.edc.boot.system.runtime.BaseRuntime.boot(BaseRuntime.java:200)
        at org.eclipse.edc.boot.system.runtime.BaseRuntime.boot(BaseRuntime.java:83)
        at org.eclipse.edc.boot.system.runtime.BaseRuntime.main(BaseRuntime.java:71)
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.edc.spi.system.injection.ProviderMethod.invoke(ProviderMethod.java:61)
        ... 20 more
Caused by: java.lang.NullPointerException: Client secret could not be retrieved
        at java.base/java.util.Objects.requireNonNull(Unknown Source)
        at org.eclipse.tractusx.edc.iam.ssi.miw.SsiMiwOauth2ClientExtension.createConfiguration(SsiMiwOauth2ClientExtension.java:75)
        at org.eclipse.tractusx.edc.iam.ssi.miw.SsiMiwOauth2ClientExtension.oauth2Client(SsiMiwOauth2ClientExtension.java:67)
        ... 23 more
[otel.javaagent 2024-04-22 06:13:22:454 +0000] [OkHttp http://localhost:4317/...] WARN io.opentelemetry.exporter.internal.grpc.GrpcExporter - Failed to export spans. Server responded with gRPC status code 2. Error message: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:4317
wolf4ood commented 7 months ago

Hi @amnaishaq

Did you put the secret in the HashiCorp vault under the alias/key secret1?

Thanks

amnaishaq commented 7 months ago

@wolf4ood yes. but its still not working :(

wolf4ood commented 7 months ago

@amnaishaq for reference you could check the MXD it's working there

amnaishaq commented 7 months ago

@wolf4ood Thank you very much for your help and patience with me, I am new to this world of tractusX-edc and I am having a hard time. Can you help me through discord if you can, I would greatly appreciate it. I've been stuck with this problem for about two weeks and I no longer know which thread to pull. My discord user is amnagroot . Thanks

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 4 weeks with no activity.

github-actions[bot] commented 5 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.