OData Vdm 生成器 returns 特定 EDMX 文件出错
OData Vdm Generator returns an error on a particular EDMX file
我正在尝试使用 EDMX 文件上的 odata-generator-cli-3.52.0 生成 类,您可以从以下 API 中心 link 下载该文件: https://api.sap.com/api/ProjectServiceV2/overview。我正在使用的命令如下:java -jar odata-generator-cli-3.52.0.jar -b "/"
,但是,我收到了这个错误(当使用 generato 作为 Maven 插件时我得到了同样的错误):
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Generating EVERYTHING with parameters:
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Input directory: /Users/i045523/Temp/simmaco/input
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Output directory: /Users/i045523/Temp/simmaco/target
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Delete output directory: false
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Overwrite files: false
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Package name: com.sap.cloud.sdk.s4hana.datamodel.odata
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Default base path: /
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Service name mapping file: /Users/i045523/Temp/simmaco/serviceNameMappings.properties
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Naming strategy class: com.sap.cloud.sdk.datamodel.odata.utility.S4HanaNamingStrategy
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Name source (default strategy): LABEL
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Annotation strategy class: com.sap.cloud.sdk.datamodel.odata.generator.annotation.DefaultAnnotationStrategy
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Pattern for excluded files:
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Link to API Business Hub: false
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Fail on Warning: false
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Entity sets to process: <all>
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Function imports to process: <all>
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Loading OData service ProjectServiceV2
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Reading metadata file: /Users/i045523/Temp/simmaco/input/ProjectServiceV2.edmx
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Reading swagger file: null
Warning: validation was turned on but an org.xml.sax.ErrorHandler was not set, which is probably not what is desired. Parser will use a default ErrorHandler to print the first 0 errors. Please call the setErrorHandler method to fix this.
Error: URI=file:/Users/i045523/Temp/simmaco/input/ProjectServiceV2.edmx Line=2: Document root element "edmx:Edmx", must match DOCTYPE root "null".
Error: URI=file:/Users/i045523/Temp/simmaco/input/ProjectServiceV2.edmx Line=2: Document is invalid: no grammar found.
Warning: validation was turned on but an org.xml.sax.ErrorHandler was not set, which is probably not what is desired. Parser will use a default ErrorHandler to print the first 0 errors. Please call the setErrorHandler method to fix this.
Error: URI=file:/Users/i045523/Temp/simmaco/input/ProjectServiceV2.edmx Line=2: Document root element "edmx:Edmx", must match DOCTYPE root "null".
Error: URI=file:/Users/i045523/Temp/simmaco/input/ProjectServiceV2.edmx Line=2: Document is invalid: no grammar found.
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Title: ProjectServiceV2
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Raw URL: /service.ProjectServiceV1
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Java Package Name: projectservicev2
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Java Class Name: ProjectServiceV2
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Processing 1 OData service...
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Processing OData service 'ProjectServiceV2' at /service.ProjectServiceV1
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator - Found entity type GroupMemberships from set GroupMemberships
[main] WARN com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Error in file ProjectServiceV2; unable to generate all VDM classes.
com.sap.cloud.sdk.datamodel.odata.generator.ODataGeneratorReadException: org.apache.olingo.odata2.api.edm.EdmException: An exception occurred.
at com.sap.cloud.sdk.datamodel.odata.generator.EdmService$TypedAdapter.getType(EdmService.java:322)
at com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator.processNavigationProperties(NamespaceClassGenerator.java:1187)
at com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator.processEntitySet(NamespaceClassGenerator.java:924)
at com.sap.cloud.sdk.datamodel.odata.generator.EntitySetProcessor.processEntitySets(EntitySetProcessor.java:78)
at com.sap.cloud.sdk.datamodel.odata.generator.CodeModelClassGenerator.processService(CodeModelClassGenerator.java:123)
at com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator.createCodeModelForServices(ODataToVdmGenerator.java:129)
at com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator.generate(ODataToVdmGenerator.java:92)
at com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator.execute(DataModelGenerator.java:662)
at com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli.run(DataModelGeneratorCli.java:216)
at com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli.main(DataModelGeneratorCli.java:198)
Caused by: org.apache.olingo.odata2.api.edm.EdmException: An exception occurred.
at org.apache.olingo.odata2.core.edm.provider.EdmAssociationEndImplProv.getEntityType(EdmAssociationEndImplProv.java:51)
at org.apache.olingo.odata2.core.edm.provider.EdmNavigationPropertyImplProv.getType(EdmNavigationPropertyImplProv.java:44)
at com.sap.cloud.sdk.datamodel.odata.generator.EdmService$TypedAdapter.getType(EdmService.java:319)
... 9 more
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Generating Java classes to /Users/i045523/Temp/simmaco/target
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli - ------------------------------------------------------------
[main] WARN com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli - Generator SUCCEEDED but had the following 1 warning messages:
[main] WARN com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli - Error in file ProjectServiceV2; unable to generate all VDM classes.
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli - ------------------------------------------------------------
你知道这个文件的问题在哪里吗?
问候,
西马科
问题出在 EDMX 规范文件中。对于导航 属性 toUser
引用了未定义的实体类型,即 Users
.
<NavigationProperty Name="toUser" Relationship="service.ProjectServiceV1.GroupMemberships_toUser" FromRole="GroupMemberships" ToRole="Users"/>
从 EDMX 文件中删除此 属性 及其关联的 Association
和 AssociationSet
会导致成功生成 VDM。
我正在尝试使用 EDMX 文件上的 odata-generator-cli-3.52.0 生成 类,您可以从以下 API 中心 link 下载该文件: https://api.sap.com/api/ProjectServiceV2/overview。我正在使用的命令如下:java -jar odata-generator-cli-3.52.0.jar -b "/"
,但是,我收到了这个错误(当使用 generato 作为 Maven 插件时我得到了同样的错误):
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Generating EVERYTHING with parameters:
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Input directory: /Users/i045523/Temp/simmaco/input
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Output directory: /Users/i045523/Temp/simmaco/target
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Delete output directory: false
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Overwrite files: false
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Package name: com.sap.cloud.sdk.s4hana.datamodel.odata
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Default base path: /
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Service name mapping file: /Users/i045523/Temp/simmaco/serviceNameMappings.properties
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Naming strategy class: com.sap.cloud.sdk.datamodel.odata.utility.S4HanaNamingStrategy
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Name source (default strategy): LABEL
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Annotation strategy class: com.sap.cloud.sdk.datamodel.odata.generator.annotation.DefaultAnnotationStrategy
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Pattern for excluded files:
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Link to API Business Hub: false
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Fail on Warning: false
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Entity sets to process: <all>
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator - Function imports to process: <all>
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Loading OData service ProjectServiceV2
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Reading metadata file: /Users/i045523/Temp/simmaco/input/ProjectServiceV2.edmx
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Reading swagger file: null
Warning: validation was turned on but an org.xml.sax.ErrorHandler was not set, which is probably not what is desired. Parser will use a default ErrorHandler to print the first 0 errors. Please call the setErrorHandler method to fix this.
Error: URI=file:/Users/i045523/Temp/simmaco/input/ProjectServiceV2.edmx Line=2: Document root element "edmx:Edmx", must match DOCTYPE root "null".
Error: URI=file:/Users/i045523/Temp/simmaco/input/ProjectServiceV2.edmx Line=2: Document is invalid: no grammar found.
Warning: validation was turned on but an org.xml.sax.ErrorHandler was not set, which is probably not what is desired. Parser will use a default ErrorHandler to print the first 0 errors. Please call the setErrorHandler method to fix this.
Error: URI=file:/Users/i045523/Temp/simmaco/input/ProjectServiceV2.edmx Line=2: Document root element "edmx:Edmx", must match DOCTYPE root "null".
Error: URI=file:/Users/i045523/Temp/simmaco/input/ProjectServiceV2.edmx Line=2: Document is invalid: no grammar found.
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Title: ProjectServiceV2
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Raw URL: /service.ProjectServiceV1
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Java Package Name: projectservicev2
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Java Class Name: ProjectServiceV2
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Processing 1 OData service...
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Processing OData service 'ProjectServiceV2' at /service.ProjectServiceV1
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator - Found entity type GroupMemberships from set GroupMemberships
[main] WARN com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Error in file ProjectServiceV2; unable to generate all VDM classes.
com.sap.cloud.sdk.datamodel.odata.generator.ODataGeneratorReadException: org.apache.olingo.odata2.api.edm.EdmException: An exception occurred.
at com.sap.cloud.sdk.datamodel.odata.generator.EdmService$TypedAdapter.getType(EdmService.java:322)
at com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator.processNavigationProperties(NamespaceClassGenerator.java:1187)
at com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator.processEntitySet(NamespaceClassGenerator.java:924)
at com.sap.cloud.sdk.datamodel.odata.generator.EntitySetProcessor.processEntitySets(EntitySetProcessor.java:78)
at com.sap.cloud.sdk.datamodel.odata.generator.CodeModelClassGenerator.processService(CodeModelClassGenerator.java:123)
at com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator.createCodeModelForServices(ODataToVdmGenerator.java:129)
at com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator.generate(ODataToVdmGenerator.java:92)
at com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator.execute(DataModelGenerator.java:662)
at com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli.run(DataModelGeneratorCli.java:216)
at com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli.main(DataModelGeneratorCli.java:198)
Caused by: org.apache.olingo.odata2.api.edm.EdmException: An exception occurred.
at org.apache.olingo.odata2.core.edm.provider.EdmAssociationEndImplProv.getEntityType(EdmAssociationEndImplProv.java:51)
at org.apache.olingo.odata2.core.edm.provider.EdmNavigationPropertyImplProv.getType(EdmNavigationPropertyImplProv.java:44)
at com.sap.cloud.sdk.datamodel.odata.generator.EdmService$TypedAdapter.getType(EdmService.java:319)
... 9 more
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Generating Java classes to /Users/i045523/Temp/simmaco/target
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli - ------------------------------------------------------------
[main] WARN com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli - Generator SUCCEEDED but had the following 1 warning messages:
[main] WARN com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli - Error in file ProjectServiceV2; unable to generate all VDM classes.
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli - ------------------------------------------------------------
你知道这个文件的问题在哪里吗? 问候, 西马科
问题出在 EDMX 规范文件中。对于导航 属性 toUser
引用了未定义的实体类型,即 Users
.
<NavigationProperty Name="toUser" Relationship="service.ProjectServiceV1.GroupMemberships_toUser" FromRole="GroupMemberships" ToRole="Users"/>
从 EDMX 文件中删除此 属性 及其关联的 Association
和 AssociationSet
会导致成功生成 VDM。