Reputation: 3597
I'm trying to write a custom class in ACS Commons' MCP Tool
Including "azure storage" api in "pom.xml" as below:
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>8.0.0</version>
</dependency>
The build runs fine without any compile errors, but while running the program i'm seeing the below in error logs:
Sample usage:
import com.microsoft.azure.storage.CloudStorageAccount;
..
public class AzureAssetIngestor extends AssetIngestor {
private CloudStorageAccount storageAccount;
..
storageAccount = CloudStorageAccount.parse(storageConnectionString);
Error in logs while executing the program
Caused by: java.lang.ClassNotFoundException: com.microsoft.azure.storage.CloudStorageAccount not found by com.adobe.acs.acs-aem-commons-bundle
Caused by: java.lang.ClassNotFoundException: com.microsoft.azure.storage.CloudStorageAccount not found by com.adobe.acs.acs-aem-commons-bundle [521]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1574)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
Appreciate any help!
Upvotes: 0
Views: 994
Reputation: 3597
With @Jens inputs, the option to install bundles manually helped/worked.
Here's the solution:
pom.xml
<artifactId>maven-bundle-plugin</artifactId>
<Import-Package>
com.microsoft.azure.*;resolution:=optional,
...
</Import-Package>
...
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>8.0.0</version>
<scope>provided</scope>
</dependency>
Then go to AEM Bundles (Like http://localhost:4502/system/console/bundles) to install bundles manually. You can use either of the below.
Option 1:
Option 2:
Upvotes: 0
Reputation: 21530
There are two types of dependencies for AEM projects:
In Maven you define compile time dependencies. So adding dependencies to your pom.xml
will make them available only during the build (compile time) by Maven.
It is your job as a developer to make sure that those dependencies are also available during runtime. There are basically three ways to achieve that:
It is probably obvious, but you should go with option 2 or 3. Both approaches have their advantages and disadvantages. A (relatively) big issue with option 2 is that not all your dependencies are OSGi bundles. Therefore, for this to work, you would need to transform them to OSGi bundles. This is no rocket science but another thing to keep in mind. Embedding your dependency is easier but I personally do not like that solution that much.
Upvotes: 1