Hi Team,
I have created a simple maven project which queries AEM 6.4 repository and sends the mail with query results in excel attachment. I am using Apache POI Api to create excel. To add the POI jar, I used depfinder(/system/console/depfinder) and got the below dependency details.
<dependency>
<artifactId>com.adobe.granite.poi</artifactId>
<version>2.0.24</version>
<groupId>com.adobe.granite</groupId>
</dependency>
I added the same in POM. But the build is failing with below error message.
Could not find artifact com.adobe.granite:com.adobe.granite.poi:jar:2.0.24 adobe (https://repo.adobe.com/nexus/content/groups/public/) -> [Help 1]
Can anyone let me know what is the suitable way to handle this scenario ? I have alternative way where in I can specify the dependency like below in my POM.
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.0</version>
</dependency>
But I want to know how to make the above depfinder suggested dependency to work ?
Regards,
/S
Solved! Go to Solution.
Views
Replies
Total Likes
You should really only need the uber-jar.
like this:
<dependency> | |
<groupId>com.adobe.aem</groupId> | |
<artifactId>uber-jar</artifactId> | |
<version>6.4.2</version> | |
<classifier>apis</classifier> | |
<scope>provided</scope> | |
</dependency> |
Views
Replies
Total Likes
You should really only need the uber-jar.
like this:
<dependency> | |
<groupId>com.adobe.aem</groupId> | |
<artifactId>uber-jar</artifactId> | |
<version>6.4.2</version> | |
<classifier>apis</classifier> | |
<scope>provided</scope> | |
</dependency> |
Views
Replies
Total Likes
Hi,
You can check all available versions at Index of /groups/public/com/adobe/granite/com.adobe.granite.poi
Views
Replies
Total Likes
Here the list of uber-jar versions Index of /groups/public/com/adobe/aem/uber-jar
Views
Replies
Total Likes
Feike and Arun are correct. I will test this too to make sure there are no issues.
Views
Replies
Total Likes
I have confirmed that uber 6.4 jar works (as Feike pointed out) .
My class:
package com.adobe.excel.core;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.osgi.service.component.annotations.Component;
@Component
public class ExcelImpl implements Excel {
private final Logger logger = LoggerFactory.getLogger(getClass());
private static final String FILE_NAME = "C:\\AdobeCQ\\MyFirstExcel.xlsx";
public void createExcel()
{
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Datatypes in Java");
Object[][] datatypes = {
{"Datatype", "Type", "Size(in bytes)"},
{"int", "Primitive", 2},
{"float", "Primitive", 4},
{"double", "Primitive", 8},
{"char", "Primitive", 1},
{"String", "Non-Primitive", "No fixed size"}
};
int rowNum = 0;
logger.info("Creating excel");
for (Object[] datatype : datatypes) {
Row row = sheet.createRow(rowNum++);
int colNum = 0;
for (Object field : datatype) {
Cell cell = row.createCell(colNum++);
if (field instanceof String) {
cell.setCellValue((String) field);
} else if (field instanceof Integer) {
cell.setCellValue((Integer) field);
}
}
}
try {
FileOutputStream outputStream = new FileOutputStream(FILE_NAME);
workbook.write(outputStream);
workbook.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
logger.info("Done");
}
}
Parent POM:
<
dependency
>
<
groupId
>com.adobe.aem</
groupId
>
<
artifactId
>uber-jar</
artifactId
>
<
version
>6.4.0</
version
>
<
classifier
>apis</
classifier
>
<
scope
>provided</
scope
>
</
dependency
>
<
dependency
>
<
groupId
>org.apache.geronimo.specs</
groupId
>
<
artifactId
>geronimo-atinject_1.0_spec</
artifactId
>
<
version
>1.0</
version
>
<
scope
>provided</
scope
>
</
dependency
>
CORE POM:
<?xml version="1.0" encoding="UTF-8"?>
<!--
| Copyright 2017 Adobe Systems Incorporated
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>excelPOI</groupId>
<artifactId>excelPOI</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>excelPOI.core</artifactId>
<packaging>bundle</packaging>
<name>excelPOI - Core</name>
<description>Core bundle for excelPOI</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>maven-sling-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<!-- Import any version of javax.inject, to allow running on multiple versions of AEM -->
<Import-Package>javax.inject;version=0.0.0,*</Import-Package>
<Sling-Model-Packages>
com.adobe.excel.core
</Sling-Model-Packages>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- OSGi Dependencies -->
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<classifier>apis</classifier>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-atinject_1.0_spec</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.core</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.annotation</artifactId>
</dependency>
<!-- Other Dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<classifier>apis</classifier>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.api</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
</dependency>
</dependencies>
</project>
Compiled successfully:
Bundle is Active
Hope this helps....
Views
Replies
Total Likes
Thanks. It's working.
Views
Replies
Total Likes
I am using uber jar 6.5.0. With that new XSSFWorkbook(inputStream) is working fine runtime and am able to generate excel, however the same is failing in PowerMockRunner junit with exception org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException. Any pointers appreciated
Views
Replies
Total Likes
Views
Likes
Replies