Hi, all.
I'm using maven to create an OSGi bundle and then maven-sling-plugin to install
it ("mvn clean package install"). One odd thing happens, though, every single
time the install occurs. When trying to access my site via HTTP I get a
"java.lang.NoClassDefFoundError: org/apache/sling/api/resource/Resource". I
can resolve this by stopping and starting the "Apache Sling Scripting Core
implementation" bundle.
Interestingly, this only happens for pages where I'm using Velocity as the
scripting language. I used the Velocity scripting engine in the "contrib"
area. It generally works great except for this particular issue. Pages that
are purely JSP based don't seem to have the problem. There is a reason for
this. While my OSGi bundle doesn't, of course, contain any Velocity templates
or anything like that (it is just Java code that acts as helpers) it does
include a BindingsValuesProvider for the use of the Velocity templates stored
in /apps.
The exact line which throws the error is in my BindingsValuesProvider. It is
simply:
Resource theResource = (Resource) inBindings.get("resource");
And the odd thing is that it is a NoClassDefFoundError which is cleared up by
simply restarting the Sling scripting core bundle.
Caused by: java.lang.NoClassDefFoundError:
org/apache/sling/api/resource/Resource
at
org.consumersunion.cq.CUBindingsValuesProvider.addCurrentNodeAndCurrentData(CUBindingsValuesProvider.java:57)
at
org.consumersunion.cq.CUBindingsValuesProvider.addBindings(CUBindingsValuesProvider.java:49)
at
org.apache.sling.scripting.core.impl.DefaultSlingScript.verifySlingBindings(DefaultSlingScript.java:688)
at
org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:185)
at
org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:170)
at
org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:456)
Has anyone seen something like this before? At first I thought I simply wasn't
waiting long enough after the bundle installation, but this happens no matter
how long I wait, but it is cleared up instantly when I restart the Sling
scripting core bundle.
Thanks for any help,
--David
**
This e-mail message is intended only for the designated recipient(s) named
above. The information contained in this e-mail and any attachments may be
confidential or legally privileged. If you are not the intended recipient, you
may not review, retain, copy, redistribute or use this e-mail or any attachment
for any purpose, or disclose all or any part of its contents. If you have
received this e-mail in error, please immediately notify the sender by reply
e-mail and permanently delete this e-mail and any attachments from your
computer system.