简体   繁体   English

在Adobe CQ5中使用servlet-api 3捆绑包

[英]using servlet-api 3 bundle in adobe CQ5

I'm trying to use the servlet-api version 3 in an Adobe CQ5 installation, without much success. 我正在尝试在Adobe CQ5安装中使用servlet-api版本3,但没有成功。

there is already a bundle that exports the javax.servlet package (version 2.5), so I deployed a bundle with version 3.1.0. 已经有一个可导出javax.servlet包(2.5版)的捆绑软件,因此我部署了3.1.0版的捆绑软件。 this bundle starts ok. 这个捆绑包开始正常。

The problem is starting the bundle that uses the api v3. 问题是启动使用api v3的捆绑软件。 I am getting an OSGi exception that I cannot fully understand: 我收到了我无法完全理解的OSGi异常:

POST /system/console/bundles/250 HTTP/1.1] cqse-httpservice %bundles.pluginTitle: Cannot start (org.osgi.framework.BundleException: POST / system / console / bundles / 250 HTTP / 1.1] cqse-httpservice%bundles.pluginTitle:无法启动(org.osgi.framework.BundleException:

Constraint violation for package 'javax.servlet' when resolving module 250.9 between existing import 266.0.javax.servlet 在现有导入266.0.javax.servlet之间解析模块250.9时,违反了程序包“ javax.servlet”的约束

BLAMED ON [[250.9] package; BLAMED ON [[250.9]封装; (&(package=javax.servlet)(version>=3.0.0)(!(version>=4.0.0)))] (&(package = javax.servlet)(版本> = 3.0.0)(!(版本> = 4.0.0)))]]

and uses constraint 22.1.javax.servlet 并使用约束22.1.javax.servlet

BLAMED ON [[250.9] package; BLAMED ON [[250.9]封装; (package=com.day.cq.wcm.foundation.forms), [210.0] package; (package = com.day.cq.wcm.foundation.forms),[210.0]软件包; (&(package=org.apache.sling.api.resource)(version>=2.0.0)), [93.0] package; (&(package = org.apache.sling.api.resource)(version> = 2.0.0)),[93.0]软件包; (&(package=javax.servlet)(version>=2.4.0))]) (&(package = javax.servlet)(版本> = 2.4.0))])

  • bundle 266 exports javax.servlet v=3.10 (I installed this one) 捆绑包266导出javax.servlet v = 3.10(我安装了这个)
  • bundle 22 exports javax.servlet v=2.5 (provided by CQ5) 束22导出javax.servlet v = 2.5(由CQ5提供)
  • bundle 250 (mine) imports javax.servlet,version=[3.0,4) from 266. It also imports packages from 210 and 93. bundle 250(mine)从266导入javax.servlet,version = [3.0,4)。它还从210和93导入包。
  • bundle 210 imports javax.servelt v=2.5 from 22 (but the import in manifest does not have a version. maybe this is the problem?) 捆绑包210从22导入javax.servelt v = 2.5(但是清单中的导入没有版本。也许这是问题所在?)
  • bundle 93 has javax.servlet; 捆绑软件93具有javax.servlet; version="2.4" in the Import-package. 导入包中的version =“ 2.4”。 but it resolved to javax.servlet,version=2.5.0 from (22) somehow. 但它以某种方式从(22)解析为javax.servlet,version = 2.5.0。

The problem seems to be around the dependencies of bundle 250, but Im not sure what is the problem. 问题似乎与捆绑包250的依赖关系有关,但是我不确定是什么问题。 AFAIK two versions of a package can coexist in an OSGi container. AFAIK软件包的两个版本可以在OSGi容器中共存。 bundles 210 and 93 are running without issues. 捆绑软件210和93正常运行。

This is most likely due to the fact that the used http-service only supports servlet 2.5 that's why this is the pre-installed servlet version. 这很可能是由于所使用的http服务仅支持servlet 2.5的事实,这就是为什么这是预安装的servlet版本的原因。 Since you installed a servlet 3.0 api your bundle does resolve but as it tries to export a service which is picked up by the http-service you run into this issue. 由于您安装了servlet 3.0 api,因此您的捆绑包确实可以解决,但是当它尝试导出由http服务获取的服务时,您会遇到此问题。 The root cause is the http-service implementation that is used. 根本原因是所使用的http服务实现。 I don't know if this would work but you might try to replace the http service version by using Pax-Web 2 or 3 instead. 我不知道这是否可行,但是您可以尝试使用Pax-Web 2或3替换http服务版本。 Pax-Web does support Servlet API since version 2. 从版本2开始,Pax-Web确实支持Servlet API。

After reading the article left in the comments, I noticed that dependencies of my bundle expose classes of the servlet api 2.5. 阅读注释中剩下的文章后,我注意到我的软件包的依赖项公开了servlet api 2.5的类。 This is causing the constraint and prevents my bundle. 这导致了约束并阻止了我的捆绑包。 If I understand correctly the classpath from bundle 210 is expanded up to my bundle. 如果我正确理解,则来自捆绑软件210的类路径将扩展到我的捆绑软件。

So, the only option will be to remove the dependency of my bundle with the other bundles, which I am afraid I cannot do. 因此,唯一的选择是删除我的捆绑包与其他捆绑包的依赖关系,恐怕我无法做到。 I will have to deal without the V3 api 如果没有V3 API,我将不得不处理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM