[Building Sakai] Spring bean lookup failing on Sample tool/service

Steve Swinsburg steve.swinsburg at gmail.com
Tue Apr 6 00:21:00 PDT 2010


Hi all,

I just hit this in trunk when using Wicket's Spring Annotations for dependency injection in my app [1]. It looks up the registered beans to find a match but it's failing when it comes across this one, because the bean is in the sample tool (see stack trace). 


Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.sakaiproject.sample.tool.ItemServiceImpl] for bean with name 'org.sakaiproject.sample.tool.ItemService' defined in ServletContext resource [/WEB-INF/components.xml]; nested exception is java.lang.ClassNotFoundException: org.sakaiproject.sample.tool.ItemServiceImpl
	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:524)
	at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1177)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:222)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:202)
	at org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:933)
	at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:143)
	at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:147)
	at org.apache.wicket.spring.SpringBeanLocator.getBeanNameOfClass(SpringBeanLocator.java:112)
	at org.apache.wicket.spring.SpringBeanLocator.getBeanName(SpringBeanLocator.java:216)
	at org.apache.wicket.spring.SpringBeanLocator.hashCode(SpringBeanLocator.java:294)
	at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:782)
	at org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:106)
	at org.apache.wicket.injection.Injector.inject(Injector.java:121)
	at org.apache.wicket.injection.ConfigurableInjector.inject(ConfigurableInjector.java:39)
	at org.apache.wicket.injection.ComponentInjector.onInstantiation(ComponentInjector.java:52)
	at org.apache.wicket.Application.notifyComponentInstantiationListeners(Application.java:1040)
	at org.apache.wicket.Component.<init>(Component.java:920)
	at org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:113)
	at org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:105)
	at org.apache.wicket.Page.<init>(Page.java:237)
	at org.apache.wicket.markup.html.WebPage.<init>(WebPage.java:185)
	at org.sakaiproject.profile2.tool.pages.BasePage.<init>(BasePage.java:52)
	at org.sakaiproject.profile2.tool.Dispatcher.<init>(Dispatcher.java:25)
	... 51 more

I believe the problem is that the tool itself defines a bean in it's WEB-INF/components.xml which can't be resolved outside of that tool:
https://source.sakaiproject.org/svn/samples/trunk/sample-tool-jsf/src/webapp/WEB-INF/components.xml

From looking through the source of the sample tool, it gives example code on using ContentHosting, JSF and servlets in Sakai. This would be best moved to Confluence, perhaps in the Sakai Developer guide, and dropped from the source (or at least disabled). 

This is a showstopper for using Wicket's Spring Annotations and the sample code is not a dependency for anything else. WDYT?

cheers
Steve

[1]: http://cwiki.apache.org/WICKET/spring.html#Spring-AnnotationbasedApproach



On 25/11/2009, at 4:38 AM, Anthony Whyte wrote:

> When I look in Tomcat instances stocked with 2.6.x and 2.7.x artifacts  
> I see
> 
> 2.6.x, 2.7.x
> /components
> 	/sakai-sample-impl-access-pack
> 		WEB-INF/lib/sakai-sample-impl-access-impl-[VERSION].jar
> 
> The only bean defined in components.xml is
> 
> org.sakaiproject.sample.impl.SampleImplAccess
> 
> Cheers,
> 
> Anth
> 
> 
> 
> 
> 
> On Nov 24, 2009, at 12:22 PM, James Renfro wrote:
> 
>> I'm having a problem deploying the 2.7.x branch -- I have a contrib  
>> tool that makes a call to  
>> AbstractApplicationContext.getBeanNamesForType() that's throwing an  
>> exception because it can't seem to resolve  
>> 'org.sakaiproject.sample.tool.ItemService'. Looks to me like this is  
>> because the sample tool has a dependency on that bean, but since the  
>> sample tool is not being loaded by default this doesn't become an  
>> issue in a vanilla 2.7.x build/deploy.
>> 
>> If I remove the sample tool wars from the webapps directory  
>> everything works without a hitch.
>> 
>> Are we missing the component that goes with the sample tool in this  
>> branch?
>> 
>> 
>> Caused by:  
>> org.springframework.beans.factory.CannotLoadBeanClassException:  
>> Cannot find class [org.sakaiproject.sample.tool.ItemServiceImpl] for  
>> bean with name 'org.sakaiproject.sample.tool.ItemService' defined in  
>> ServletContext resource [/WEB-INF/components.xml]; nested exception  
>> is java.lang.ClassNotFoundException:  
>> org.sakaiproject.sample.tool.ItemServiceImpl
>>    at  
>> org 
>> .springframework 
>> .beans 
>> .factory 
>> .support 
>> .AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141)
>>    at  
>> org 
>> .springframework 
>> .beans 
>> .factory 
>> .support 
>> .AbstractAutowireCapableBeanFactory 
>> .predictBeanType(AbstractAutowireCapableBeanFactory.java:524)
>>    at  
>> org 
>> .springframework 
>> .beans 
>> .factory 
>> .support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java: 
>> 1177)
>>    at  
>> org 
>> .springframework 
>> .beans 
>> .factory 
>> .support 
>> .DefaultListableBeanFactory 
>> .getBeanNamesForType(DefaultListableBeanFactory.java:222)
>>    at  
>> org 
>> .springframework 
>> .beans 
>> .factory 
>> .support 
>> .DefaultListableBeanFactory 
>> .getBeanNamesForType(DefaultListableBeanFactory.java:202)
>>    at  
>> org 
>> .springframework 
>> .context 
>> .support 
>> .AbstractApplicationContext 
>> .getBeanNamesForType(AbstractApplicationContext.java:933)
>>    at  
>> org 
>> .sakaiproject 
>> .gradebook 
>> .gwt.sakai.Gradebook2ServiceImpl.init(Gradebook2ServiceImpl.java:172)
>>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>    at  
>> sun 
>> .reflect 
>> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>    at  
>> sun 
>> .reflect 
>> .DelegatingMethodAccessorImpl 
>> .invoke(DelegatingMethodAccessorImpl.java:25)
>>    at java.lang.reflect.Method.invoke(Method.java:592)
>>    at  
>> org 
>> .springframework 
>> .beans 
>> .factory 
>> .support 
>> .AbstractAutowireCapableBeanFactory 
>> .invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1414)
>>    at  
>> org 
>> .springframework 
>> .beans 
>> .factory 
>> .support 
>> .AbstractAutowireCapableBeanFactory 
>> .invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1375)
>>    at  
>> org 
>> .springframework 
>> .beans 
>> .factory 
>> .support 
>> .AbstractAutowireCapableBeanFactory 
>> .initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
>>    ... 54 more
>> Caused by: java.lang.ClassNotFoundException:  
>> org.sakaiproject.sample.tool.ItemServiceImpl
>>    at  
>> org 
>> .apache 
>> .catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java: 
>> 1386)
>>    at  
>> org 
>> .apache 
>> .catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java: 
>> 1232)
>>    at org.springframework.util.ClassUtils.forName(ClassUtils.java: 
>> 211)
>>    at  
>> org 
>> .springframework 
>> .beans 
>> .factory 
>> .support 
>> .AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java: 
>> 385)
>>    at  
>> org 
>> .springframework 
>> .beans 
>> .factory 
>> .support 
>> .AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138)
>> _______________________________________________
>> sakai-dev mailing list
>> sakai-dev at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>> 
>> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org 
>> with a subject of "unsubscribe"
> 
> _______________________________________________
> sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
> 
> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3689 bytes
Desc: not available
Url : http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20100406/7a7e8c3b/attachment.bin 


More information about the sakai-dev mailing list