I am trying to create a custom OData v2 service in java with an S/4HANA Cloud data source using S/4HANA Cloud SDK. I tried to follow section 8.3 of the SAP Press book \"Extendi
The setup for OData V2 provisioning looks a bit different. So remove all modifications you did to use OData V4 provisioning. Then add the following:
Add the following dependencies (instead of the odata-v4 one) to your application/pom.xml
file:
<dependency>
<groupId>com.sap.cloud.servicesdk.prov</groupId>
<artifactId>odata2.web</artifactId>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sap.cloud.servicesdk.prov</groupId>
<artifactId>odata2.xsa</artifactId>
</dependency>
<dependency>
<groupId>com.sap.cloud.servicesdk.prov</groupId>
<artifactId>odatav2-hybrid</artifactId>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sap.cloud.servicesdk.prov</groupId>
<artifactId>odatav2-prov</artifactId>
</dependency>
Add the following entries to your application/src/main/webapp/WEB-INF/web.xml
file, replacing YOUR.PACKAGE
with a package to search for your OData endpoints:
<servlet>
<servlet-name>ODataServlet</servlet-name>
<servlet-class>org.apache.olingo.odata2.core.servlet.ODataServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>org.apache.olingo.odata2.service.factory</param-name>
<param-value>
com.sap.cloud.sdk.service.prov.v2.rt.core.CloudSDKODataServiceFactory
</param-value>
</init-param>
<init-param>
<param-name>org.apache.olingo.odata2.path.split</param-name>
<param-value>1</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>ODataServlet</servlet-name>
<url-pattern>/odata/v2/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>package</param-name>
<param-value>YOUR.PACKAGE</param-value>
</context-param>
<listener>
<listener-class>
com.sap.cloud.sdk.service.prov.v2.rt.core.web.ServletListener
</listener-class>
</listener>
application/src/main/resources/edmx
directory.These steps should get your OData V2 Provisioning service up and running.