Springで設定する必要があるプロパティを持つJSF ManagedBeanがあります。しかし、私は次のエラーを受け取ります:JSF ManagedBeanにSpring Beanをインジェクトする際のエラー
Caused by: javax.el.ELException: java.lang.IllegalArgumentException: Cannot convert [email protected] of type class $Proxy166 to class persistence.AuthDao
at com.sun.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:68)
at com.sun.faces.el.ELUtils.coerce(ELUtils.java:536)
at com.sun.faces.mgbean.BeanBuilder$Expression.evaluate(BeanBuilder.java:592)
at com.sun.faces.mgbean.ManagedBeanBuilder$BakedBeanProperty.set(ManagedBeanBuilder.java:606)
... 57 more
Caused by: java.lang.IllegalArgumentException: Cannot convert [email protected] of type class $Proxy166 to class persistence.AuthDao
at com.sun.el.lang.ELSupport.coerceToType(ELSupport.java:397)
at com.sun.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:66)
私はELSolverをfaces-config.xmlに持っています。
<managed-bean>
<managed-bean-name>authController</managed-bean-name>
<managed-bean-class>controllers.AuthController</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>authDao</property-name>
<value>#{authDao}</value>
</managed-property>
</managed-bean>
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
クラスを見つけることができるようですが、クラスは別の型($ Proxy166?それはどこから来るのかわからない)です。
PS:ELResolverを削除すると、そのトリックが実行されたようです。私はfaces-config.xmlのマネージドBeanを明示的に提供することがELResolverをオーバーライドすると考えました。これらの両方が共存する方法はありますか?同様に、BeanのアノテーションとXML設定の両方を提供する場合、これらのどちらかが優先されるか、またはそれらをマージする方法があります。アノテーションにいくつかのプロパティを、XMLにはいくつかのプロパティを提供しますか?
PPS:インターフェースを追加し、それらを実装するために私の現在のクラスを変更した後、私は次のエラーを取得する:
Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authDao' 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 '$Proxy157 implementing persistence.UserDao,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'persistence.UserDaoImpl' for property 'userDao'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy157 implementing persistence.UserDao,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [persistence.UserDaoImpl] for property 'userDao': no matching editors or conversion strategy found. Please see server.log for more details.
を使用することができます実は、私はこのケースでインターフェイスを実装していなかった、これは、迅速なデモでした。だから、Springはデフォルトでインターフェイスを使うように強制していますか? – ustun
番号。しかし、あなたのbeanは確実にインターフェースを持っています。そうしないと、$ ProxyXXを取得できません。インタフェースがない場合は、cglibを使用します – Bozho
助けてくれてありがとう。私のプロジェクトでは、クラスだけでインターフェイスはありませんでした。インターフェイスを追加しても問題は解決されませんでした。上記のエラーメッセージが追加されました。 – ustun