Hey Joost,
this was a hard nut to crack. Seems related to ProxyFactory combined
with JCR events being dispatched from the CMS webapp classloader. A
workaround is quite simple (see below). I will fix it in the HST in
[1].
Apart from this, some small remarks:
instead of
<property name="targetObject" ref="jcrObservationEventListenerItems" />
<property name="targetMethod" value="add" />
you can better use 'customJcrObservationEventListenerItems' in your
end project, see [2].
Also make sure that if you access a jcr session in a listener, that
you make sure to logout the session at the end. Namely, even though
you get a pooled HST session, there is not resource management because
you are not in context of a hst request. Hence, you need in a finally
to logout the jcr session.
Last thing: The HST and in general listeners typically do not have
this problem you describe because they are only used to register
events, say, in some queue. Then, another consumer acts on this queue.
The advantage is that jcr event listening can better not take too long
HTH, Regards Ard
Temporary solution for you:
@Override
public void onEvent(EventIterator events) {
final ClassLoader currentCL =
Thread.currentThread().getContextClassLoader();
Session session = null;
try {
Thread.currentThread().setContextClassLoader(DocListener.class.getClassLoader());
session = repository.login(credentials);
while (events.hasNext()) {
if (eventIgnorable(events.nextEvent())) {
continue;
}
return;
}
} catch (RepositoryException e) {
// log
} finally {
if (session != null) {
session.logout();
}
Thread.currentThread().setContextClassLoader(currentCL);
}
}
[1]
https://issues.onehippo.com/browse/HSTTWO-3323
[2]
http://www.onehippo.org/library/concepts/hst-spring/how-to-add-custom-jcr-event-listener-through-spring-configuration.html
> --
> Hippo Community Group: The place for all discussions and announcements about
> Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to
hippo-c...@googlegroups.com
> RSS:
>
https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups
> "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
hippo-communi...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/hippo-community.
> For more options, visit
https://groups.google.com/d/optout.
--
Hippo Netherlands, Oosteinde 11, 1017 WT Amsterdam, Netherlands
Hippo USA, Inc.- 745 Atlantic Ave, Eight Floor, Boston MA 02111,
United states of America.
US
+1 877 414 4776 (toll free)
Europe
+31(0)20 522 4466
www.onehippo.com