Hi Eric,
Merry Christmas to you :).
I am trying to read domains from the database from my custom matcher.
I have a written a helper class which is replica of
org.apache.james.domainlist.jpa.JPADomainList.java which has the below
method.
public List<String> getDomainListInternal() throws DomainListException {
List<String> domains = new ArrayList<String>();
EntityManager entityManager = entityManagerFactory
.createEntityManager();
LOGGER.info("entity manager created.......");
final EntityTransaction transaction =
entityManager.getTransaction();
try {
transaction.begin();
domains =
entityManager.createNamedQuery("listDomainNames")
.getResultList();
transaction.commit();
} catch (PersistenceException e) {
getLogger().error("Failed to list domains", e);
if (transaction.isActive()) {
transaction.rollback();
}
throw new DomainListException("Unable to retrieve
domains", e);
} finally {
entityManager.close();
}
if (domains.size() == 0) {
return null;
} else {
return new ArrayList<String>(domains);
}
Now In my custom mailet class, I have called the above method, but I
am unable to retrieve the domains from the database table. Below is my
code from custom mailtet.
try{
domainsList =
oTestJPADomainsList.getDomainListInternal();
}catch (Exception exp)
{
exp.printStackTrace();
}
if(domains != null && !domains.isEmpty()){
domains.clear();
}
if(domainsList != null && !domainsList.isEmpty()){
for(String aDomain : domainsList)
{
domains.add(aDomain);
}
} else {
LOGGER.error("Unable to read domains from JPA DOmains
List...");
throw new Exception("No Domains Found");
}
When I try to send an email I am getting throw the no domains found
exception (my custom exception).
Please can you guide in using the right api to read the domains from
the database source.
Regards,
Rajender
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]