はまった訳でorz

仕事でSpring+JSFをやってるから、家ではJSF-Springを使ってみようかとサンプル構築してみましたわ。
なんでもSpringのJSF Integrationを一歩進めてRESTモデルになってるらしい。
かっこよく言うと、RESTful web application?(笑

まずはサイトで公開されてるQuickstartを見ながら構築。
ここに落とし穴がw
そのとおりやってみると、JSFページにアクセスすると「ManagedBean」がインスタンス化されてないぞーと例外にorz
んで、なにが足りないのかというとSpring2.0で追加されたBeanScopeに関連するリスナ。
org.springframework.web.context.request.RequestContextListener
↑こいつです。
ようはRequestを受けたときに、BeanFactoryでスコープに対応したBeanをインスタンス化してくれるやつだね。
例外メッセージをみてたら、リファレンスを読んでた時のなんかあったなぁと思い出して検索してみれば案の定
RequestContextListenerの記述が。
試しにこやつをweb.xmlに追加して起動したら動いたー!


なんつーか、JSF-Springのサイトてドキュメントがまだ全然ないんだよね。
サンプルも。
かなり手探り状態orz


記述した設定ファイルは以下の通り。(実際はFaceletsとTomahawkも使ったけど)

 [WEB-INF/web.xml]
 <?xml version="1.0" encoding="utf-8"?>
 <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
   version="2.4">
 
  <!-- SpringFramework -->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext*.xml</param-value>
  </context-param>
 
  <listener>
     <listener-class>
       org.springframework.web.context.ContextLoaderListener
     </listener-class>
   </listener>
 
   <listener>
     <listener-class>
       org.springframework.web.context.request.RequestContextListener
     </listener-class>
   </listener>
 
   <!-- JSF-Spring -->
   <listener>
     <listener-class>
       de.mindmatters.faces.spring.context.ContextLoaderListener
     </listener-class>
   </listener>
 
   <!-- Faces Servlet -->
   <servlet>
     <servlet-name>Faces Servlet</servlet-name>
     <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
     <load-on-startup>1</load-on-startup>
   </servlet>
 
   <!-- Faces Servlet Mapping -->
   <servlet-mapping>
     <servlet-name>Faces Servlet</servlet-name>
     <url-pattern>*.faces</url-pattern>
   </servlet-mapping>
 </web-app>
 [WEB-INF/faces-config.xml]
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE faces-config PUBLIC
     "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
     "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
 <faces-config>
   <application>
     <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
   </application>
   
   <managed-bean>
     <managed-bean-name>uiBean</managed-bean-name>
     <managed-bean-class>sample.web.UiBean</managed-bean-class>
     <managed-bean-scope>request</managed-bean-scope>
     <managed-property>
       <property-name>timeService</property-name>
       <value>#{timeService}</value>
     </managed-property>
   </managed-bean>
   
 </faces-config>
 [WEB-INF/applicationContext.xml]
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd ">
 
     <bean id="timeService" class="sample.service.TimeServiceImpl" />
 
 </beans>