SAP / olingo-jpa-processor-v4

The JPA Processor fills the gap between Olingo V4 and the database, by providing a mapping between JPA metadata and OData metadata, generating queries and supporting the entity manipulations.
Apache License 2.0
122 stars 76 forks source link

Loading of reference document for annotations fails in Spring Boot #156

Closed Boltzmann closed 1 year ago

Boltzmann commented 2 years ago

To get a description of Entities or Properties in the form of (xml) `

` we use the solution of the second step posted in https://github.com/SAP/olingo-jpa-processor-v4/issues/37#issuecomment-375079043, by creating an extension of JPAEdmMetadataPostProcessor overriding method provideReferences:

String uri = "http://docs.oasisopen.org/odata/odata/v4.0/os/vocabularies/Org.OData.Core.V1.xml";
IntermediateReferenceAccess reference = references.addReference(uri, "annotations/Org.OData.Core.V1.xml");
reference.addInclude("Org.OData.Core.V1", "Core");

However, in Spring Boot this fails with the error

nested exception is com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException: Parsing of 'annotations/Org.OData.Core.V1.xml' failed with message 'file:/app.jar!/BOOT-INF/classes!/annotations/Org.OData.Core.V1.xml (No such file or directory)'.

Reason for this is that the method loadXML in class CsdlDocumentReader uses this.getClass().getClassLoader().getResource(path)instead of this.getClass().getClassLoader().getResourceAsStream(path).

wog48 commented 1 year ago

I was able to reproduce the error and approved you PR. Please merge it.

Boltzmann commented 1 year ago

Hi @wog48, are you asking me? I cannot...maybe I need some information. See the SonarCloud build of the merge:

Error: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project odata-jpa: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator -> [Help 1]

Boltzmann commented 1 year ago

Hi @wog48 , I saw you tried the sonar check again on 6th October. Can you please give an update if I can be of any help?

https://github.com/SAP/olingo-jpa-processor-v4/actions/workflows/sonar.yml shows that all merge requests from forked repositories do not work with sonar in this repo, while your branches and edits in master do. Maybe the merge are not allowed to use the sonar check here?

wog48 commented 1 year ago

I tried to find the root cause, why the sonar token is not taken. Up to now I failed. Nevertheless, you should be able to merge the PR, as the sonar check is not required. In case you face a problem, I can merge the PR.

Boltzmann commented 1 year ago

Thank you for merging the PR! Regarding

Nevertheless, you should be able to merge the PR, as the sonar check is not required.

have a look at https://github.com/SAP/olingo-jpa-processor-v4/pull/161#issuecomment-1345281231.