Foren
NoSuchBeanDefinitionException - Custom Velocity Tools and Liferay 6.1
Daniel Niklas, geändert vor 12 Jahren.
NoSuchBeanDefinitionException - Custom Velocity Tools and Liferay 6.1
Junior Member Beiträge: 46 Beitrittsdatum: 08.11.10 Neueste Beiträge
Hi,
i have downloaded and deployed the hook within the project from Ray Augés example from Custom Velocity Tools and Liferay 6.0 on tomcat-liferay-bundle 6.1.
Unforunately i' getting an exception:
Can you give me some hints whats going wrong here?
I've configured Debug-Loglevel for BeanLocatorImpl, but no interesting information here!?
Daniel
i have downloaded and deployed the hook within the project from Ray Augés example from Custom Velocity Tools and Liferay 6.0 on tomcat-liferay-bundle 6.1.
Unforunately i' getting an exception:
16:54:28,875 ERROR [UtilLocator:56] com.liferay.portal.kernel.bean.BeanLocatorException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'com.mytool.MyTool' is defined
com.liferay.portal.kernel.bean.BeanLocatorException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'com.mytool.MyTool' is defined
at com.liferay.portal.bean.BeanLocatorImpl.locate(BeanLocatorImpl.java:70)
at com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate(PortletBeanLocatorUtil.java:47)
at com.liferay.portal.velocity.UtilLocator.findUtil(UtilLocator.java:52)
...
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'com.mytool.MyTool' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:529)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java
Can you give me some hints whats going wrong here?
I've configured Debug-Loglevel for BeanLocatorImpl, but no interesting information here!?
Daniel
Daniel Niklas, geändert vor 12 Jahren.
RE: NoSuchBeanDefinitionException - Custom Velocity Tools and Liferay 6.1
Junior Member Beiträge: 46 Beitrittsdatum: 08.11.10 Neueste Beiträge
what i've done is this:
Is here missing something?
Can you give me a hint where to start debugging?
Thanks in advance
Daniel Niklas
- created interface and impl
- declaration for corresponding bean in WEB-INF/applicationContext.xml
- configured PortletContextLoaderListener in web.xml
Is here missing something?
Can you give me a hint where to start debugging?
Thanks in advance
Daniel Niklas
David H Nebinger, geändert vor 12 Jahren.
RE: NoSuchBeanDefinitionException - Custom Velocity Tools and Liferay 6.1
Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
First I'd suggest downloading and using the test-velotool-hook provided by Ray as-is, just to determine if his is working in your environment.
Second, did you see his note at the end on using the contextPathName of your hook? If you're not using the right contextPathName, the bean locator lookup could be failing due to that reason...
Second, did you see his note at the end on using the contextPathName of your hook? If you're not using the right contextPathName, the bean locator lookup could be failing due to that reason...
Daniel Niklas, geändert vor 12 Jahren.
RE: NoSuchBeanDefinitionException - Custom Velocity Tools and Liferay 6.1
Junior Member Beiträge: 46 Beitrittsdatum: 08.11.10 Neueste BeiträgeDavid H Nebinger:
First I'd suggest downloading and using the test-velotool-hook provided by Ray as-is, just to determine if his is working in your environment.
Yes, I've taken the test-velotool-hook "as-is".
David H Nebinger:
Second, did you see his note at the end on using the contextPathName of your hook? If you're not using the right contextPathName, the bean locator lookup could be failing due to that reason...
I've seen the note with the contextPathName, too. The example uses 'test-velotool-hook' as contextPathName. I think thats ok, because there is a directory with the same name beneath LIFERAY_HOME/tomcat-7.0.23/webapps/.
Eduardo Aragón, geändert vor 12 Jahren.
RE: NoSuchBeanDefinitionException - Custom Velocity Tools and Liferay 6.1
New Member Beiträge: 6 Beitrittsdatum: 08.02.12 Neueste Beiträge
I have the same problem. I configured the applicationContext.xml and web.xml, but seems the BeanLocator can't locate the defined bean.
Anyone has found the soolution??....
Anyone has found the soolution??....
Sagar A Vyas, geändert vor 12 Jahren.
RE: NoSuchBeanDefinitionException - Custom Velocity Tools and Liferay 6.1
Liferay Master Beiträge: 679 Beitrittsdatum: 17.04.09 Neueste Beiträge
Hi Daniel,
Please try your stuff with following test-hook, which i have tested on my local machine its working fine to me.
Hope this help
Thanks,
Sagar Vyas
Please try your stuff with following test-hook, which i have tested on my local machine its working fine to me.
Hope this help
Thanks,
Sagar Vyas
Anhänge:
Eduardo Aragón, geändert vor 12 Jahren.
RE: NoSuchBeanDefinitionException - Custom Velocity Tools and Liferay 6.1
New Member Beiträge: 6 Beitrittsdatum: 08.02.12 Neueste BeiträgeSagar A Vyas:
Hi Daniel,
Please try your stuff with following test-hook, which i have tested on my local machine its working fine to me.
Hope this help
Thanks,
Sagar Vyas
I tried to deploy the hook you attached but doesn't work when defined spring beans. Same error org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'XXXXXXX' is defined.
It seems on this liferay version you must load the spring bean in some other way. I developed a script for liferay 6.0.6 and runs perfect. I deployed in liferay 6.1 GA and doesn't work.
Anyone knows another way to load spring beans?...
Sampsa Sohlman, geändert vor 12 Jahren.
RE: NoSuchBeanDefinitionException - Custom Velocity Tools and Liferay 6.1
Regular Member Beiträge: 230 Beitrittsdatum: 27.09.07 Neueste Beiträge
The question is this done intentionally or is it bug.
Well, I'm trying to debug this through and find a reason why it is working differently.
So here a little progress:
With Liferay 6.0.6 and 6.1.0 both reason ends up at com.liferay.portal.bean.BeanLocatorImpl method doLocate(..) and at line "return _applicationContext.getBean(name);"
When I inspect that "_applicationContext"
at 6.0.6 I get with debug
and 6.1.0 I get with debug
So it seems that bean is not getting registered to _applicationContext at 6.1.0, why is that? Where the bean registration to _applicationContext happen?
Well, I'm trying to debug this through and find a reason why it is working differently.
So here a little progress:
With Liferay 6.0.6 and 6.1.0 both reason ends up at com.liferay.portal.bean.BeanLocatorImpl method doLocate(..) and at line "return _applicationContext.getBean(name);"
When I inspect that "_applicationContext"
at 6.0.6 I get with debug
_applicationContext.getClassLoader()
(org.apache.catalina.loader.WebappClassLoader) WebappClassLoader
context:
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@6d3f7281
_applicationContext.getDisplayName()
(java.lang.String) Root WebApplicationContext
_applicationContext.getBeanDefinitionCount()
(int) 1
and 6.1.0 I get with debug
_applicationContext.getClassLoader()
(org.apache.catalina.loader.WebappClassLoader) WebappClassLoader
context:
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@11a06e38
_applicationContext.getDisplayName()
(java.lang.String) Root WebApplicationContext
_applicationContext.getBeanDefinitionCount()
(int) 0
So it seems that bean is not getting registered to _applicationContext at 6.1.0, why is that? Where the bean registration to _applicationContext happen?
Sampsa Sohlman, geändert vor 12 Jahren.
RE: NoSuchBeanDefinitionException - Custom Velocity Tools and Liferay 6.1 (Antwort)
Regular Member Beiträge: 230 Beitrittsdatum: 27.09.07 Neueste Beiträge
It is so good that Liferay is open source. So the problems can be solved just by studying the code.
Finally the problem was traced to
com.liferay.portal.spring.context.PortletApplicationContext class where was new method comparing to 6.0.6.
and from version control I could trace that change to issue LPS-21104
So the solution to fix it to add path to applicationContext.xml to web.xml with context-params
Finally the problem was traced to
com.liferay.portal.spring.context.PortletApplicationContext class where was new method comparing to 6.0.6.
protected String[] getDefaultConfigLocations() {
return new String[0];
}
and from version control I could trace that change to issue LPS-21104
So the solution to fix it to add path to applicationContext.xml to web.xml with context-params
<context-param>
<param-name>portalContextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
Andy Harb, geändert vor 10 Jahren.
RE: NoSuchBeanDefinitionException - Custom Velocity Tools and Liferay 6.1
Junior Member Beiträge: 66 Beitrittsdatum: 22.10.09 Neueste Beiträge
Thanks Sampsa!