Indeed, surely something is wrong because it fails to get the domainHolder :(
09:31:51.508 ERROR
org.apache.syncope.core.provisioning.java.job.report.ReportJob - While
executing report bdd0ab2b-411f-4755-90ab-2b411f0755c2
org.quartz.JobExecutionException:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name
'org.apache.syncope.core.provisioning.java.job.report.myReportlet': Unsatisfied
dependency expressed through field 'domainHolder'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying
bean of type 'org.apache.syncope.core.persistence.api.DomainHolder' available:
expected at least 1 bean which qualifies as autowire candidate. Dependency
annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}
at
org.apache.syncope.core.provisioning.java.job.report.DefaultReportJobDelegate.execute(DefaultReportJobDelegate.java:208)
~[syncope-core-provisioning-java-2.1.7.jar:2.1.7]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_265]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[?:1.8.0_265]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[?:1.8.0_265]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_265]
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
~[spring-aop-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
~[spring-aop-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
~[spring-aop-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)
~[spring-tx-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
~[spring-tx-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.apache.syncope.core.persistence.jpa.spring.DomainTransactionInterceptor.invoke(DomainTransactionInterceptor.java:60)
~[syncope-core-persistence-jpa-2.1.7.jar:2.1.7]
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
~[spring-aop-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
~[spring-aop-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at com.sun.proxy.$Proxy193.execute(Unknown Source) ~[?:?]
at
org.apache.syncope.core.provisioning.java.job.report.ReportJob.lambda$execute$0(ReportJob.java:67)
~[syncope-core-provisioning-java-2.1.7.jar:2.1.7]
at
org.apache.syncope.core.spring.security.AuthContextUtils.execWithAuthContext(AuthContextUtils.java:117)
~[syncope-core-spring-2.1.7.jar:2.1.7]
at
org.apache.syncope.core.provisioning.java.job.report.ReportJob.execute(ReportJob.java:64)
~[syncope-core-provisioning-java-2.1.7.jar:2.1.7]
at org.quartz.core.JobRunShell.run(JobRunShell.java:202) ~[quartz-2.3.2.jar:?]
at
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
~[quartz-2.3.2.jar:?]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name
'org.apache.syncope.core.provisioning.java.job.report.myReportlet': Unsatisfied
dependency expressed through field 'domainHolder'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying
bean of type 'org.apache.syncope.core.persistence.api.DomainHolder' available:
expected at least 1 bean which qualifies as autowire candidate. Dependency
annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:598)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:376)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1402)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:591)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:514)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:351)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.apache.syncope.core.spring.ImplementationManager.buildJavaWithConf(ImplementationManager.java:228)
~[syncope-core-spring-2.1.7.jar:2.1.7]
at
org.apache.syncope.core.spring.ImplementationManager.buildReportlet(ImplementationManager.java:64)
~[syncope-core-spring-2.1.7.jar:2.1.7]
at
org.apache.syncope.core.provisioning.java.job.report.DefaultReportJobDelegate.execute(DefaultReportJobDelegate.java:171)
~[syncope-core-provisioning-java-2.1.7.jar:2.1.7]
... 18 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No
qualifying bean of type 'org.apache.syncope.core.persistence.api.DomainHolder'
available: expected at least 1 bean which qualifies as autowire candidate.
Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1680)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1239)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1193)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:595)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:376)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1402)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:591)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:514)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:351)
~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE]
at
org.apache.syncope.core.spring.ImplementationManager.buildJavaWithConf(ImplementationManager.java:228)
~[syncope-core-spring-2.1.7.jar:2.1.7]
at
org.apache.syncope.core.spring.ImplementationManager.buildReportlet(ImplementationManager.java:64)
~[syncope-core-spring-2.1.7.jar:2.1.7]
at
org.apache.syncope.core.provisioning.java.job.report.DefaultReportJobDelegate.execute(DefaultReportJobDelegate.java:171)
~[syncope-core-provisioning-java-2.1.7.jar:2.1.7]
... 18 more
#######################################
package org.apache.syncope.core.provisioning.java.job.report;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicReference;
import javax.sql.DataSource;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.lib.log.AuditEntry;
import org.apache.syncope.common.lib.report.myReportletConf;
import org.apache.syncope.common.lib.report.ReportletConf;
import org.apache.syncope.core.persistence.api.DomainHolder;
import org.apache.syncope.core.persistence.api.dao.LoggerDAO;
import org.apache.syncope.core.spring.security.AuthContextUtils;
import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
import org.apache.syncope.core.persistence.api.dao.ReportletConfClass;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ReportletConfClass(myReportletConf.class)
public class myReportlet extends AbstractReportlet {
private static final Logger LOG =
LoggerFactory.getLogger(myReportlet.class);
@Autowired
private DomainHolder domainHolder;
private myReportletConf conf;
private DataSource datasource;
private void doExtractConf(final ContentHandler handler, final
AtomicReference<String> status) throws SAXException {
status.set("Fetching " + conf.getSize() + " rows from the " +
LoggerDAO.AUDIT_TABLE + " table");
LOG.info("1");
JdbcTemplate jdbcTemplate = new JdbcTemplate(datasource);
jdbcTemplate.setMaxRows(conf.getSize());
LOG.info("2");
List<Map<String, Object>> rows = jdbcTemplate.
queryForList("SELECT * FROM " + LoggerDAO.AUDIT_TABLE + " ORDER
BY EVENT_DATE DESC");
//
"logger":{"type":"LOGIC","category":"RoleLogic","subcategory":null,"event":"update","result":"SUCCESS"}
HashMap<String, Integer> stats = new HashMap<>();
LOG.info("3");
for (Map<String, Object> row : rows) {
AuditEntry auditEntry =
POJOHelper.deserialize(row.get("MESSAGE").toString(), AuditEntry.class);
LOG.info("31");
if (StringUtils.isNotBlank(auditEntry.getLogger().getCategory()) &&
auditEntry.getLogger().getResult() != null &&
StringUtils.isNotBlank(auditEntry.getLogger().getEvent())) {
LOG.info("32");
String category = auditEntry.getLogger().getCategory();
String event = auditEntry.getLogger().getEvent();
String result = auditEntry.getLogger().getResult().name();
String key = category+"."+event+"."+result;
LOG.info("33");
int count = 0;
if (stats.containsKey(key)) {
count = stats.get(key);
}
LOG.info("34");
stats.put(key, count+1);
}
}
LOG.info("4");
handler.startElement("", "", "statistiques", null);
AttributesImpl atts = new AttributesImpl();
LOG.info("5");
Iterator<Map.Entry<String, Integer>> entrySet = stats.entrySet().iterator();
while (entrySet.hasNext()) {
LOG.info("51");
Map.Entry<String, Integer> entry = entrySet.next();
atts.clear();
handler.startElement("", "", "audit", atts);
String key = entry.getKey();
Integer value = entry.getValue();
LOG.info("52");
String[] s = key.split("\\.");
atts.clear();
atts.addAttribute("", "", "categorie", ReportXMLConst.XSD_STRING, s[0]);
atts.addAttribute("", "", "action", ReportXMLConst.XSD_STRING, s[1]);
atts.addAttribute("", "", "resultat", ReportXMLConst.XSD_STRING, s[2]);
atts.addAttribute("", "", "nombre", ReportXMLConst.XSD_INT,
String.valueOf(value));
handler.endElement("", "", "audit");
LOG.info("53");
}
handler.endElement("", "", "statistiques");
LOG.info("6");
status.set("Fetched " + conf.getSize() + " rows from the SYNCOPEAUDIT
table");
}
@Override
protected void doExtract(
final ReportletConf conf,
final ContentHandler handler,
final AtomicReference<String> status)
throws SAXException {
LOG.info("7");
if (conf instanceof myReportletConf) {
this.conf = myReportletConf.class.cast(conf);
} else {
throw new ReportException(new IllegalArgumentException("Invalid
configuration provided"));
}
LOG.info("8");
LOG.info(AuthContextUtils.getDomain());
LOG.info("81");
LOG.info(String.valueOf(domainHolder.getDomains().size()));
LOG.info("82");
datasource =
domainHolder.getDomains().get(AuthContextUtils.getDomain());
if (datasource == null) {
throw new ReportException(new IllegalArgumentException("Could not
get to DataSource"));
}
LOG.info("9");
doExtractConf(handler, status);
}
}
De : Francesco Chicchiriccò <[email protected]>
À : [email protected]
Sujet : Re: custom reportlet and reportletConf do not appear on console
Date : 22/10/2020 10:14:45 Europe/Paris
Hi,
the steps you mention below are normally not needed: there must be something in
your Maven project or settings that are impeding the normal behavior.
Regards.
On 22/10/20 10:06, [email protected] wrote:
Hi,
Finally found how to do it.
For those having same troubles:
You need to place your Conf in:
core/src/main/java/org/apache/syncope/common/lib/report/myReportletConf.java
AND IN
console/src/main/java/org/apache/syncope/common/lib/report/myReportletConf.java
Then your reportlet in
core/src/main/java/org/apache/syncope/core/provisioning/java/job/report/myReportlet.java
Then finally you also need to have (it does not build if it is not here)
core/src/main/java/org/apache/syncope/core/persistence/api/DomainHolder.java
Whom the content can be taken on github
Enjoy.
De : [email protected]
À : [email protected]
Sujet : custom reportlet and reportletConf do not appear on console
Date : 21/10/2020 19:37:36 Europe/Paris
Hi,
I developed my own reportlet class and reportletConf that I put in:
core/src/main/java/org/apache/syncope/core/provisioning/java/job/report/myReportlet.java
core/src/main/java/org/apache/syncope/common/lib/report/myReportletConf.java
Maven build runs well and I see my classes like:
./core/target/syncope/WEB-INF/classes/org/apache/syncope/core/provisioning/java/job/report/myReportlet.class
./core/target/syncope/WEB-INF/classes/org/apache/syncope/common/lib/report/myReportletConf.class
However, no way to see them on console when I go to Configuration ->
implementation -> reportlets -> [add]
Did I miss something ??
Thanks
--
Francesco Chicchiriccò
Tirasa - Open Source Excellence
http://www.tirasa.net/
Member at The Apache Software Foundation
Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
http://home.apache.org/~ilgrosso/