I want to send email from Adobe CQ5 using Eclipse Maven multi-module project. My idea was to create a servlet to write the code for mail functionality and after that to call that servlet in a form component to provide inputs and fire the mail to the admin.So I have created a servlet in my Eclipse project and have followed all the steps from this tutorial, which suggested the following JARs:
import javax.jcr.Node;
import javax.jcr.Session;
import javax.mail.internet.InternetAddress;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import org.apache.commons.mail.HtmlEmail;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.felix.scr.annotations.sling.SlingServlet;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
import org.apache.sling.jcr.api.SlingRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.cq.mailer.MessageGateway;
import com.day.cq.mailer.MessageGatewayService;
I can see the build is successful and the package is installed in http://localhost:4502/system/console/bundles. But in System/console/bundle the package is in installed state, not in active state which cannot be used.
To verify the issue when I expanded it, I am getting this error:
org.apache.commons.mail,version=[1.3,2) -- Cannot be resolved.
The full description of the package is:
Exported Packages aem.flightdeck.com.flightdeck.core,version=1.0
Imported Packages aem.flightdeck.com.flightdeck.core,version=[1.0,1.1) from aem.flightdeck.com.flightdeck.core (408)
com.day.cq.mailer,version=[5.8,6) from com.day.cq.cq-mailer (267)
javax.jcr,version=[2.0,3) from org.apache.sling.jcr.jcr-wrapper (106)
javax.mail.internet,version=[1.4,2) from javax.mail (178)
javax.servlet from org.apache.felix.http.servlet-api (29)
org.apache.commons.mail,version=[1.3,2) -- Cannot be resolved
org.apache.sling.api,version=[2.3,3) from org.apache.sling.api (184)
org.apache.sling.api.request,version=[2.4,3) from org.apache.sling.api (184)
org.apache.sling.api.resource,version=[2.5,3) from org.apache.sling.api (184)
org.apache.sling.api.servlets,version=[2.1,3) from org.apache.sling.api (184)
org.apache.sling.commons.osgi,version=[2.2,3) from org.apache.sling.commons.osgi (56)
org.apache.sling.jcr.api,version=[2.2,3) from org.apache.sling.jcr.api (104)
org.apache.sling.settings,version=[1.3,2) from org.apache.sling.settings (13)
org.osgi.service.event,version=[1.2,2) from org.apache.felix.eventadmin (51)
org.slf4j,version=[1.5,2) from slf4j.api (14)
Manifest Headers Bnd-LastModified: 1427608012083
Build-Jdk: 1.7.0_71
Built-By: ajena
Bundle-Description: Core bundle for flightdeck
Bundle-ManifestVersion: 2
Bundle-Name: flightdeck - Core
Bundle-SymbolicName: aem.flightdeck.com.flightdeck.core
Bundle-Version: 1.0.1.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: aem.flightdeck.com.flightdeck.core; version="1.0"
Import-Package: aem.flightdeck.com.flightdeck.core; version="[1.0, 1.1)", com.day.cq.mailer; version="[5.8, 6)", javax.jcr; version="[2.0, 3)", javax.mail.internet; version="[1.4, 2)", javax.servlet, org.apache.commons.mail; version="[1.3, 2)", org.apache.sling.api; version="[2.3, 3)", org.apache.sling.api.request; version="[2.4, 3)", org.apache.sling.api.resource; version="[2.5, 3)", org.apache.sling.api.servlets; version="[2.1, 3)", org.apache.sling.commons.osgi; version="[2.2, 3)", org.apache.sling.jcr.api; version="[2.2, 3)", org.apache.sling.settings; version="[1.3, 2)", org.osgi.service.event; version="[1.2, 2)", org.slf4j; version="[1.5, 2)"
Manifest-Version: 1.0
Provide-Capability: osgi.service; effective:=active; objectClass="java.lang.Runnable"; scheduler.expression="*/30 * * * * ?"; scheduler.concurrent=false; service.vendor=Adobe
Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.6))"
Service-Component: OSGI-INF/aem.flightdeck.com.flightdeck.core.impl.schedulers.SimpleScheduledTask.xml, OSGI-INF/aem.flightdeck.com.flightdeck.core.impl.listeners.SimpleResourceListener.xml, OSGI-INF/aem.flightdeck.com.flightdeck.core.impl.filters.LoggingFilter.xml, OSGI-INF/aem.flightdeck.com.flightdeck.core.impl.servlets.EmailServlet.xml, OSGI-INF/aem.flightdeck.com.flightdeck.core.impl.HelloServiceImpl.xml, OSGI-INF/aem.flightdeck.com.flightdeck.core.impl.servlets.SimpleServlet.xml
Tool: Bnd-2.3.0.201405100607
When I checked the error.log file of AEM author I am getting the error message below:
29.03.2015 11:16:55.235 *INFO* [FelixDispatchQueue] org.apache.felix.framework FrameworkEvent PACKAGES REFRESHED
29.03.2015 11:16:55.235 *INFO* [OsgiInstallerImpl] org.apache.sling.installer.core.impl.tasks.BundleStartTask Could not start bundle aem.flightdeck.com.flightdeck.core [408]. Reason: {}. Will retry.
org.osgi.framework.BundleException: Unresolved constraint in bundle aem.flightdeck.com.flightdeck.core [408]: Unable to resolve 408.96: missing requirement [408.96] osgi.wiring.package; (&(osgi.wiring.package=org.apache.commons.mail)(version>=1.3.0)(!(version>=2.0.0)))
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3980)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2043)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:963)
at org.apache.sling.installer.core.impl.tasks.BundleStartTask.execute(BundleStartTask.java:93)
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.executeTasks(OsgiInstallerImpl.java:733)
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.run(OsgiInstallerImpl.java:247)
at java.lang.Thread.run(Unknown Source)
29.03.2015 11:16:55.275 *INFO* [OsgiInstallerImpl] org.apache.sling.installer.core.impl.tasks.BundleStartTask Could not start bundle aem.flightdeck.com.flightdeck.core [408]. Reason: {}. Will retry.
org.osgi.framework.BundleException: Unresolved constraint in bundle aem.flightdeck.com.flightdeck.core [408]: Unable to resolve 408.96: missing requirement [408.96] osgi.wiring.package; (&(osgi.wiring.package=org.apache.commons.mail)(version>=1.3.0)(!(version>=2.0.0)))
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3980)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2043)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:963)
at org.apache.sling.installer.core.impl.tasks.BundleStartTask.execute(BundleStartTask.java:93)
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.executeTasks(OsgiInstallerImpl.java:733)
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.run(OsgiInstallerImpl.java:247)
at java.lang.Thread.run(Unknown Source)
In my POM.xml file I have added the dependency as below:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.3.2</version>
</dependency>
In the dependency folder which is - .m2\repository\commons-email\commons-email folder, the commons-email 1.3.2.jar is already downloaded.
Can anyone share any suggestions for fixing this issue, or suggest how I can send email from CQ5 component on a button click without using workflow?