SpringBridgeHstComponent: Cannot find the root web application context or client component manager

142 views
Skip to first unread message

Tlabs

unread,
Oct 31, 2014, 6:27:21 AM10/31/14
to hippo-c...@googlegroups.com
Hi,
I created two spring components into my hippo site.
My SimpleDispatcherHstComponent is ok, but my SpringBridgeHstComponent is not ok.

I set an element into my jcr repo as 
org.hippoecm.hst.component.support.spring.SpringBridgeHstComponent
and spring-delegated-bean on bean ID "importantTodoItemsListSpringDelegateComponent".

My delegated-spring-bean extends BaseHstComponent and I defined it into mvc-dispatcher-servlet.xml.

Well, I have an exception on spring-delegated-bean invokation:

[INFO] [talledLocalContainer] 31.10.2014 11:02:21 WARN  http-bio-8080-exec-2 [HstComponentInvokerImpl.invokeBeforeRender:139] Component exception caught: org.hippoecm.hst.core.component.HstComponentException: Cannot find the root web application context or client component manager. at org.hippoecm.hst.component.support.spring.SpringBridgeHstComponent.getDelegatedBean(SpringBridgeHstComponent.java:218)
[INFO] [talledLocalContainer] 31.10.2014 11:02:22 WARN  http-bio-8080-exec-2 [AbstractBaseOrderableValve.handleComponentExceptions:303] Component exception(s) found in page request, '/site/'.
[INFO] [talledLocalContainer] 31.10.2014 11:02:22 WARN  http-bio-8080-exec-2 [DefaultPageErrorHandler.logWarningsForEachComponentExceptions:51] Component exception on org.hippoecm.hst.component.support.spring.SpringBridgeHstComponent : org.hippoecm.hst.core.component.HstComponentException: Cannot find the root web application context or client component manager. 

Into my web.xml I configured this:

<servlet>
<servlet-name>HstDispatcherServlet</servlet-name>
<servlet-class>org.hippoecm.hst.component.support.spring.mvc.HstDispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
</init-param>
</servlet>

What is my error, please?

Regards,
Antonino

Woonsan Ko

unread,
Oct 31, 2014, 8:04:32 AM10/31/14
to hippo-c...@googlegroups.com
Hi Tlabs,

At this moment, SpringBridgeHstComponent finds the delegatee bean by
using
org.springframework.web.context.support.WebApplicationContextUtils.getWebApplicationContext(ServletContext)(servletContext);
As a result, it cannot find the delegatee bean unless the bean is
defined in the root web application context configuration, which is
loaded by org.springframework.web.context.ContextLoaderListener by
default from /WEB-INF/applicationContext.xml (which can be configured to
a different location by setting 'contextConfigLocation' servlet context
init param). See [1] for detail on ContextLoaderListener.

So, if you define your bean in /WEB-INF/applicationContext.xml and if
you have the following in /WEB-INF/web.xml,

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

then it will work without any problem.

I also gave another thought to improve this in HST-2:
- Spring dispatcher servlet allows to expose its own
WebApplicationContext as servlet context attribute through init parameters;
- So, if SpringBridgeHstComponent (and others) are able to retrieve a
WebApplicationContext through
org.springframework.web.context.support.WebApplicationContextUtils.getWebApplicationContext(ServletContext)(servletContext,
attrName) with attrName parameterized from somewhere, then it might be
more convenient without having to define the root application context
configuration.

Please review if my first suggestion would work for you.
Or if you like the improvement, then please feel free to file a JIRA
issue here:
- https://issues.onehippo.com/browse/HSTTWO/

Cheers,

Woonsan

[1]
http://docs.spring.io/spring/docs/3.2.11.RELEASE/spring-framework-reference/htmlsingle/
("5.14.4 Convenient ApplicationContext instantiation for web applications")
> --
> 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
> <mailto: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.


--
w....@onehippo.com www.onehippo.com
Boston - 101 Main Street, Cambridge, MA 02142
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

Tlabs

unread,
Oct 31, 2014, 9:28:28 AM10/31/14
to hippo-c...@googlegroups.com
Well, your suggestion work fine for me and now it's all ok.
Thank you very much.

However, I think that your improvement it's a good idea and so i decided to open an issue about this scenario.

Cheers,
Antonino

Woonsan Ko

unread,
Nov 10, 2014, 4:27:38 PM11/10/14
to hippo-c...@googlegroups.com
Hi Antonino,

I'm now trying to fix the improvements with the following issues:
- https://issues.onehippo.com/browse/HSTTWO-3119
- https://issues.onehippo.com/browse/HSTTWO-3128

The idea is that you will be able to prefix the delegatee bean name by
'org.springframework.web.servlet.FrameworkServlet.CONTEXT.' + <your
servlet name>.
For example, if you have a spring dispatcher servlet named 'springapp'
and you want to retrieve a bean named 'contactBean' from the application
context initialized by the servlet itself, then you can set the
'spring-delegated-bean' component parameter to
'org.springframework.web.servlet.FrameworkServlet.CONTEXT.springapp::contactBean'.

In your original example, it can be
'org.springframework.web.servlet.FrameworkServlet.CONTEXT.HstDispatcherServlet::importantTodoItemsListSpringDelegateComponent'
because of the differences in servlet name and bean name.

I'll document this in the javadoc at least.

Regards,

Woonsan
> <javascript:>
> > RSS:
> >
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> <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 <javascript:>
> > <mailto:hippo-communi...@googlegroups.com <javascript:>>.
> <http://groups.google.com/group/hippo-community>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> w....@onehippo.com <javascript:> www.onehippo.com
> <http://www.onehippo.com>
> Boston - 101 Main Street, Cambridge, MA 02142
> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
> US +1 877 414 4776 (toll free)
> Europe +31(0)20 522 4466
>
> --
> 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
> <mailto:hippo-communi...@googlegroups.com>.

Tlabs

unread,
Nov 17, 2014, 11:32:41 AM11/17/14
to hippo-c...@googlegroups.com
Oh, Very Well
Thanks! :)
>     > <mailto:hippo-community+unsub...@googlegroups.com <javascript:>>.
>     > Visit this group at http://groups.google.com/group/hippo-community
>     <http://groups.google.com/group/hippo-community>.
>     > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
>
>
>     --
>     w....@onehippo.com <javascript:>     www.onehippo.com
>     <http://www.onehippo.com>
>     Boston - 101 Main Street, Cambridge, MA 02142
>     Amsterdam - Oosteinde 11, 1017 WT Amsterdam
>     US +1 877 414 4776 (toll free)
>     Europe +31(0)20 522 4466
>
> --
> 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
Reply all
Reply to author
Forward
0 new messages