【发布时间】:2015-06-02 07:09:52
【问题描述】:
我想使用 Eclipse Maven 多模块项目从 Adobe CQ5 发送电子邮件。我的想法是创建一个 servlet 来编写邮件功能的代码,然后在表单组件中调用该 servlet 以提供输入并将邮件发送给管理员。所以我在我的 Eclipse 项目中创建了一个 servlet 并遵循了所有this tutorial 的步骤,其中建议了以下 JAR:
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;
我可以看到构建成功并且包安装在http://localhost:4502/system/console/bundles。但在 System/console/bundle 中,软件包处于 已安装 状态,而不是处于无法使用的 active 状态。
为了验证问题,当我展开它时,我收到了这个错误:
org.apache.commons.mail,version=[1.3,2) -- Cannot be resolved.
包的完整描述是:
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
当我检查 AEM 作者的 error.log 文件时,我收到以下错误消息:
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)
在我的 POM.xml 文件中,我添加了如下依赖项:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.3.2</version>
</dependency>
在依赖文件夹 - .m2\repository\commons-email\commons-email 文件夹中,commons-email 1.3.2.jar 已经下载完毕。
谁能分享解决此问题的任何建议,或建议我如何在不使用工作流的情况下通过单击按钮从 CQ5 组件发送电子邮件?
【问题讨论】:
标签: java maven email servlets aem