cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Implementing OOTB interface in custom Datahub extension

0 Likes
711

I want to override an OOTB bean from the saporder-canonical extension in my own customsaporder-canonical extension. My custom java class has the following import from that extension which is causing a build failure in the CCv2 build process.

import com.hybris.datahub.saporder.util.OrderItemNumberConverter;

My own customsaporder-canonical-datahub-extension.xml has a dependency on saporder-canonical but it doesn't allow the import to work as expected.

Does anyone have any idea why this doesn't work?

Accepted Solutions (1)

Accepted Solutions (1)

Slava
Product and Topic Expert
Product and Topic Expert

I'm not sure about CCv2 specifics but generally DataHub needs two things to manage dependencies correctly:
* declare dependency in the extension file. I expect you should have something like this in your customsaporder-canonical-datahub-extension.xml:

<dependencies>
   <dependency>
      <extension>saporder-canonical</extension>
   </dependency>
</dependencies>

* declare dependency in the pom.xml for customsaporder-canonical-datahub project.

The extension.xml dependency is used at runtime when datahub starts up and loads extensions. It should make sure that the saporder-canonical extension is loaded first and all it's classes and spring beans already exist in the context when customsaporder-canonical-datahub extension is loaded.

The pom.xml is to manage dependencies at build time to make sure the maven builds correctly your extension.

Also, it's important to understand that datahub does not use maven to resolve dependencies and to load their binaries at runtime. For that reason, any library that is declared in the pom.xml and all its transitive dependencies should be manually placed onto the DataHub classpath during deployment. In CCv2 it means placing them into the datahub/config/lib directory. This document contains more details: https://help.sap.com/viewer/1be46286b36a4aa48205be5a96240672/SHIP/en-US/239421560e5d44d9b0c9b49493c5...

Hope this helps

0 Likes

Thank you for your help, I've managed to resolve this. I manually added the jar file to the config/lib folder and referenced it like so:

<dependency>
  <groupId>com.hybris.datahub</groupId>
  <artifactId>saporder-canonical</artifactId>
  <version>18.11.21-RC1</version>
  <scope>system</scope>
  <systemPath>${datahub.customization.config.lib.path}/saporder-canonical-18.11.21-RC1.jar</systemPath>
</dependency>

What I don't understand is why I needed to do this. The documentation states that SAP artifact jar files will be installed and placed in the local maven repo and be available at compile time, so I should be able to reference them like so:

<dependency>
  <groupId>com.hybris.datahub</groupId>
  <artifactId>saporder-canonical</artifactId>
  <version>${hybris-datahub-integration-suite.version}</version>
</dependency>

However, this throws an error during the build.

'dependencies.dependency.version' for com.hybris.datahub:saporder-canonical:jar must be a valid version but is '${hybris-datahub-integration-suite.version}'

Possibly something to do with the CCv2 build process, I'm not sure what's going on there but at least. I have it working by manually placing the jar file.

Answers (0)