gpt4 book ai didi

java - Scala Spring IoC 和 JSF

转载 作者:行者123 更新时间:2023-12-01 04:54:24 24 4
gpt4 key购买 nike

我遇到了一个 Spring 注入(inject)问题,我已经尝试解决了 4 天,但没有任何进展:

在我的 spring 配置中,我有:

<bean id="applicationCache" class="domain.ui.ApplicationCacheServiceImpl">
<property name="divisionSelectOptionsCache" ref="divisionSelectOptionsCache"/>
</bean>

<bean id="divisionSelectOptionsCache" class="domain.jsf.DivisionSelectOptionsCache"></bean>

ApplicationCacheServiceImpl.scala 如下所示:

class ApplicationCacheServiceImpl extends ApplicationCacheService{
var divisionSelectOptionsCache: DivisionSelectOptionsCache = _

def setDivisionSelectOptionsCache(dsoc: DivisionSelectOptionsCache) ={
divisionSelectOptionsCache = dsoc
}
....

DivisionSelectOptionsCache.scala 如下所示:

class DivisionSelectOptionsCache extends Converter{
val options = mutable.Map[String, DivisionSelectOption]()
var em: EntityManager = _

// Just left this in case its relevant. Throws no errors though
@PersistenceContext
def setEntityManager(entManager: EntityManager) = {
em = entManager
}
....

应用程序编译并构建 war 。但是,当我部署它时,我收到以下异常消息:

INFO: Initializing Spring root WebApplicationContext
Jan 18, 2013 7:56:17 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'applicationCache' defined in class path resource
applicationPersistence.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException:
Failed to convert property value of type '$Proxy15 implementing javax.faces.convert.Converter,org.springframework.aop.SpringProxy,
org.springframework.aop.framework.Advised' to required type 'com.domain.jsf.DivisionSelectOptionsCache'
for property 'divisionSelectOptionsCache'; nested exception is java.lang.IllegalStateException:
Cannot convert value of type [$Proxy15 implementing javax.faces.convert.Converter,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised]
to required type [com.domain.jsf.DivisionSelectOptionsCache] for property 'divisionSelectOptionsCache': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
.....
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy15 implementing javax.faces.convert.Converter,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'com.domain.jsf.DivisionSelectOptionsCache' for property 'divisionSelectOptionsCache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy15 implementing javax.faces.convert.Converter,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.domain.jsf.DivisionSelectOptionsCache] for property 'divisionSelectOptionsCache': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:485)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:516)
....
Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy15 implementing javax.faces.convert.Converter,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.domain.jsf.DivisionSelectOptionsCache] for property 'divisionSelectOptionsCache': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:247)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470)
... 31 more

Jan 18, 2013 7:56:20 PM org.apache.catalina.core.StandardContext filterStop
FINE: Stopping filters

所以:ApplicationCacheServiceImpl 正在寻找 spring 将与 DivisionSelectOptionsCache 对应的类型注入(inject)到属性 divisionSelectOptionsCache 中,这是正确的,并且如 spring 配置 xml 文件中所定义。

DivisionSelectOptionsCache extends Converter所以那里应该不会有问题。

所以我被困住了。我什至尝试取出 spring IoC 并使用 google Guice 进行编译时间检查而不是部署时间检查(没有 xml 配置文件),但这不起作用,因为应用程序依赖于 Spring 来提供托管 jsf beans。/p>

请帮忙,因为我正要告诉客户这是不可能的。

谢谢

最佳答案

使用类似 http://java.decompiler.free.fr/ 中的反编译器检查 Scala 编译器生成的字节码。它很可能没有按照您的想法行事。

关于java - Scala Spring IoC 和 JSF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14413494/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com