Bean初始化失败; ConversionNotSupportedException [英] Initialization of bean failed; ConversionNotSupportedException

本文介绍了Bean初始化失败; ConversionNotSupportedException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!



I have a higher hierarchy context, which on server startup (tomcat) gets the following bean:

<bean id="org.sakaiproject.rubrics.api.rubric.RubricsService" class="org.sakaiproject.rubrics.impl.RubricsServiceImpl"
    <property name="rubricsLogic"   ref="org.sakaiproject.rubrics.logic.RURubricLogic" />
    <property name="externalLogic"  ref="org.sakaiproject.rubrics.api.rubric.ExternalLogic" />


That bean's class ('RubricsServiceImpl'), implements an API interface called RubricsService ... so far so good. This initializes OK.


Down the hierarchy, when webapps are being deployed, on of these references this bean in applicationContext.xml :

<bean id="org.sakaiproject.rubrics.tool.RubricsTool" class="org.sakaiproject.rubrics.tool.RubricsTool">
    <property name="rubricsService" ref="org.sakaiproject.rubrics.api.rubric.RubricsService" />


While deploying the app, the following exception is thrown:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.sakaiproject.rubrics.tool.RubricsTool' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: 
Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.sakaiproject.rubrics.impl.RubricsServiceImpl' to required type 'org.sakaiproject.rubrics.api.rubric.RubricsService' for property 'rubricsService'; nested exception is java.lang.IllegalStateException: 
Cannot convert value of type [org.sakaiproject.rubrics.impl.RubricsServiceImpl] to required type [org.sakaiproject.rubrics.api.rubric.RubricsService] for property 'rubricsService': 
no matching editors or conversion strategy found


All the poms contain all the dependencies where they belong so no package starves from definitions or anything. I am clueless.


Could this be a Class Loader issue?


The following is my applications structure:


Ok... it was a classloader problem. The webapp's classloader was colliding with the container-level one, hence no casting could be done.

所有API .jars都部署到tomcat的shared / lib目录中,所有应用程序都可以访问它们。这是通过设置(Web应用程序的)API模块的pom来完成的:

All the API .jars are deployed to tomcat's shared/lib directory for all apps to be able to access them. This is done by setting in the pom of the API module (of the webapp) :


现在,基于上面的webapp层次结构,专栏有一个针对该webapp的基本pom.xml ,因此必须定义属性,以便其模块的所有子poms共享此依赖项。通过在Web应用程序的基本pom.xml中进行标记,可以执行以下操作:

Now, based on the hierarchy of the webapp above, rubrics has a base pom.xml for the webapp, and in this, it is necessary to define the property so all the children poms of its modules, shared this dependencies. By markind in the base pom.xml of the webapp the following:

          <scope>provided</scope> <!-- from the CONTAINER -->


Then, we just set the dependency if we need it with no .jar defined for that classloader, but to be provided by the container later on.


This was my interpretation after solving the issue. Please feel free to correct/add/enrich.

这篇关于Bean初始化失败; ConversionNotSupportedException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

登录 关闭
发送“验证码”获取 | 15天全站免登陆