OSGI 问题上的 ATG 标签库
我们目前正在创建一个需要 SLING/OSGI 上的 ATG 标签库的应用程序,我们已经创建了包含这些标签库的捆绑包并上传了它,当然这些标签库调用 ATG 类,因此我们使用 sling.properties 文件将它们包含在 bootdelegation 中。
sling.bootdelegation.simple=atg.nucleus sling.bootdelegation.class.atg.nucleus.Nucleus=atg.app assembly,\ atg.app assembly.ant,\ atg.appassemble.progress,\ atg.app assembly.util,\ ...等等...
首先我们得到这个错误:
org.apache.sling.api.scripting.ScriptEvaluationException:atg/taglib/dspjsp/ImportBeanTag 在 org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:163) 在 org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:107) 在 org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:226) 在 org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:465
......
) 引起原因:java.lang.NoClassDefFoundError:atg/taglib/dspjsp/ImportBeanTag 在 org.apache.jsp.apps.mygeometrixx.components.contenpage.center_jsp._jspx_meth_dsp_005fimportbean_005f0(center_jsp.java:177) 在 org.apache.jsp.apps.mygeometrixx.components.contenpage.center_jsp._jspService(center_jsp.java:154) 在 org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:810) 因此
,我们将 atg.taglib.dspjsp 添加到要添加到 bootdelegation sling.properties 文件中的包中。
然后我们得到这个错误:
org.apache.sling.api.scripting.ScriptEvaluationException: atg.taglib.dspjsp.ImportBeanTag 在 org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:163) 在 org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:107) 在 org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:226) 在 org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:465) ...
引起的:java.lang.ClassCastException:atg.taglib.dspjsp.ImportBeanTag 在 org.apache.sling.scripting.jsp.jasper.runtime.TagHandlerPool.get(TagHandlerPool.java:125) 在 org.apache.jsp.apps.mygeometrixx.components.contenpage.center_jsp._jspx_meth_dsp_005fimportbean_005f0(center_jsp.java:177) 在 org.apache.jsp.apps.mygeometrixx.components.contenpage.center_jsp._jspService(center_jsp.java:154) 在 org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
所有这些都在 JBOSS 上运行。
有没有办法避免导致强制转换异常的类冲突?
We're currently creating an app that needs ATG taglibs on SLING/OSGI, we have created a bundle with these taglibs and uploaded it, of course these taglibs call ATG classes, so we are including them in the bootdelegation, using sling.properties file.
sling.bootdelegation.simple=atg.nucleus
sling.bootdelegation.class.atg.nucleus.Nucleus=atg.appassembly, \
atg.appassembly.ant, \
atg.appassembly.progress, \
atg.appassembly.util, \
...ETC...
First we got this error:
org.apache.sling.api.scripting.ScriptEvaluationException: atg/taglib/dspjsp/ImportBeanTag
at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:163)
at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:107)
at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:226)
at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:465)
....
....
Caused by: java.lang.NoClassDefFoundError: atg/taglib/dspjsp/ImportBeanTag
at org.apache.jsp.apps.mygeometrixx.components.contenpage.center_jsp._jspx_meth_dsp_005fimportbean_005f0(center_jsp.java:177)
at org.apache.jsp.apps.mygeometrixx.components.contenpage.center_jsp._jspService(center_jsp.java:154)
at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at
So we added atg.taglib.dspjsp to the packages to be added in bootdelegation sling.properties file.
Then we got this error:
org.apache.sling.api.scripting.ScriptEvaluationException: atg.taglib.dspjsp.ImportBeanTag
at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:163)
at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:107)
at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:226)
at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:465)
...
Caused by: java.lang.ClassCastException: atg.taglib.dspjsp.ImportBeanTag
at org.apache.sling.scripting.jsp.jasper.runtime.TagHandlerPool.get(TagHandlerPool.java:125)
at org.apache.jsp.apps.mygeometrixx.components.contenpage.center_jsp._jspx_meth_dsp_005fimportbean_005f0(center_jsp.java:177)
at org.apache.jsp.apps.mygeometrixx.components.contenpage.center_jsp._jspService(center_jsp.java:154)
at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
All this is running on JBOSS.
Is there a way to avoid this class conflict that is causing the cast exception?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
类转换异常通常表明该类在两个不同的地方可用(在您的情况下可能通过引导委托,也可能通过导出此类的包)。 这就是我首先要调查的。
另外,为了使事情更加明确,我通常建议您不要使用引导委托,而是通过系统捆绑包显式导出这些包。 这样至少您可以更好地调试类的来源以及 OSGi 解析器如何“连接”事物。
The class cast exception is usually a sign that that class is being made available in two different places (in your case probably via bootdelegation and maybe via a bundle that exports this class). That's what I would investigate first.
Also, to make things more explicit, I would in general advise you to not use boot delegation but instead export these packages explicitly through the system bundle. That way at least you can better debug where classes come from and how things are "wired" by the OSGi resolver.
从 OSGi 框架外部加载 ATG 标记库时,您还必须确保从框架外部提供 JSP API。 默认情况下,Sling 嵌入 JSP API(在 JSP 脚本包中)。
有多种方法可以将 JSP API 公开到框架中。 一种是将它们添加到 sling.properties 文件中的系统包中:
When loading the ATG tag libraries from outside of the OSGi framework you also have to make sure to provide the JSP API from outside of the framework. By default Sling embeds the JSP API (in the JSP Scripting Bundle).
There are various ways to expose the JSP API into the framework. One is to add them to the system packages in the sling.properties file: