spring + menu RuntimeException

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

spring + menu RuntimeException

tomasz bandura
Hello,

I use click (2.3.0) and spring (3.2.4)

When I try to run my app, I get during start:

(...)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.mytest.page.HomePage]: Constructor threw exception; nested exception is java.lang.RuntimeException: No Context available on ThreadLocal Context Stack
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1000)
... 21 more

java.lang.RuntimeException: No Context available on ThreadLocal Context Stack
at org.apache.click.Context$ContextStack.peek(Context.java:966)
at org.apache.click.Context$ContextStack.access$000(Context.java:917)
at org.apache.click.Context.getThreadLocalContext(Context.java:165)
at org.apache.click.extras.control.MenuFactory.loadFromMenuXml(MenuFactory.java:499)
at org.apache.click.extras.control.MenuFactory.getRootMenu(MenuFactory.java:302)
at org.apache.click.extras.control.MenuFactory.getRootMenu(MenuFactory.java:255)
at org.apache.click.extras.control.MenuFactory.getRootMenu(MenuFactory.java:197)
at com.mytest.page.BaseTemplate.<init>(BaseTemplate.java:19)

where BaseTemplate.java:19

        rootMenu = menuFactory.getRootMenu();



Without menu it runs correctly ( I did spring configuration according to  documentation )


How to solve it?


Tomasz


Reply | Threaded
Open this post in threaded view
|

Re: spring + menu RuntimeException

aadrian
Hi,
tomasz bandura wrote
I use click (2.3.0) and spring (3.2.4)
Apache Click 2.3.0 was developed and tested with Spring 2.5.6 only. Spring 3 doesn't seem to be a simple drop in replacement for Spring 2, see https://issues.apache.org/jira/browse/CLK-652
tomasz bandura wrote
java.lang.RuntimeException: No Context available on ThreadLocal Context Stack ... at com.mytest.page.BaseTemplate.(BaseTemplate.java:19) where BaseTemplate.java:19 rootMenu = menuFactory.getRootMenu();
AFAIK this kind of message might happen when the component is instantiated before the Page is ready. Basically it should happen after, so in onInit():
 public void onInit() {
        super.onInit();

        MenuFactory menuFactory = new MenuFactory();
        rootMenu = menuFactory.getRootMenu();
        addControl(rootMenu);
}
Adrian.