I create a component report and access it by http://localhost:4502/etc/reports/my-component-report.html. I can also get json output by http://localhost:4502/etc/reports/my-component-report/jcr:content/report.data.json.
I try to get this json output in Java and then to generate the excel file. However, I get the NullPointerException, see errors below:
GET /bin/excelreportservlet HTTP/1.1] com.day.cq.reporting.servlets.DataServlet Could not create report for report '/etc/reports/ryad-test-component-SECTION/jcr:content/report'
GET /bin/excelreportservlet HTTP/1.1] com.day.cq.reporting.servlets.DataServlet Stacktrace:
java.lang.NullPointerException: null
at com.day.cq.reporting.impl.cache.CacheImpl$CacheKey.toString(CacheImpl.java:77)
at com.day.cq.reporting.impl.cache.CacheImpl$CacheKey.hashCode(CacheImpl.java:64)
at org.apache.commons.collections.map.AbstractHashedMap.hash(AbstractHashedMap.java:373)
at org.apache.commons.collections.map.AbstractHashedMap.getEntry(AbstractHashedMap.java:433)
at org.apache.commons.collections.map.LRUMap.get(LRUMap.java:174)
at com.day.cq.reporting.impl.cache.CacheImpl.get(CacheImpl.java:242)
My code:
HttpServletRequest req = requestResponseFactory.createRequest("GET","/etc/reports/my-component-report/jcr:content/report.data.json");
ByteArrayOutputStream out = new ByteArrayOutputStream();
HttpServletResponse resp = requestResponseFactory.createResponse(out);
Writer writer = response.getWriter();
requestProcessor.processRequest(req, resp, request.getResourceResolver());
String jsonString = out.toString();
Above code works fine when the URL is "/etc/reports/my-component-report.-1.json".
Does anyone know how to get report json (/etc/reports/my-component-report/jcr:content/report.data.json) output in Java?
Thanks in advance for any information.
Solved! Go to Solution.
Views
Replies
Total Likes
I found the OOTB to be not as good as writing your own service and driving the look and feel of the report through a custom service. I never had any issues writing a custom Java class that created reports of JCR data,
Views
Replies
Total Likes
Hi,
Is this a question regarding Adobe's Dynamic Tag Managment solution? If so, can you clarify where you are getting this error? If the question was not around DTM, please let me know which solution the question matches best and I'll move the thread to the appropriate forum.
Cheers,
Jantzen
Views
Replies
Total Likes
Not related to DTM. It is the AEM default reporting. https://docs.adobe.com/docs/en/aem/6-1/administer/operations/reporting.html.
Thanks.
Views
Replies
Total Likes
The Java logic works for this node?
/etc/reports/my-component-report.-1.json
In the other location - is there any content at that location?
Views
Replies
Total Likes
Try passing this path -
/etc/reports/my-component-report/_jcr_content/report.data.json
Views
Replies
Total Likes
sandeepm744005 wrote...
Try passing this path -
/etc/reports/my-component-report/_jcr_content/report.data.json
Thanks for response, however, I try it, this URL gives me the same NullPointerException and stop at the same place.
Views
Replies
Total Likes
smacdonald2008 wrote...
The Java logic works for this node?
/etc/reports/my-component-report.-1.json
In the other location - is there any content at that location?
Yes, it works for this path: /etc/reports/my-component-report.-1.json.
No other content, only the report. If I put the whole URL in browser, it works. Only when trying to access this using Java code, it is failed.
Thanks.
Views
Replies
Total Likes
Another option that you can look at using - I have done this for many custom tools that need to pull out JCR data out of AEM and then put into a spreadsheet for reporting purposes is to write a custom tool that queries data using JCR SQL2. Then use a Java Excel API to dynamically build the report and write out the data. We have an artilce of this. This works very nicely,
https://helpx.adobe.com/experience-manager/using/java-swing-applications.html
Views
Replies
Total Likes
Thank you. I saw the code, eventually, I have to use the Jave Excel API to generate the excel from Json,
The report json is out of box feature from adobe. Try to reuse what out there instead writing own code. Unfortunately it can't get the json in Java code.
Views
Replies
Total Likes
I found the OOTB to be not as good as writing your own service and driving the look and feel of the report through a custom service. I never had any issues writing a custom Java class that created reports of JCR data,
Views
Replies
Total Likes
Thanks.
The customers are fine with the report output or they don't care the OOTB look and feel, just want to get the report as excel file.
Anyway, looks like no other choice in this case.
Thanks again.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies