Frank Carrillo
Frank Carrillo

Reputation:

ATG taglibs on OSGI problems

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?

Upvotes: 0

Views: 1543

Answers (2)

fmeschbe
fmeschbe

Reputation: 321

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:

sling.system.packages.atg_jsp = javax.servlet.jsp;javax.servlet.jsp.el; \
 javax.servlet.jsp.resources;javax.servlet.jsp.tagext;version=2.1.0

Upvotes: 1

Marcel Offermans
Marcel Offermans

Reputation: 3323

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.

Upvotes: 1

Related Questions