[Seasar-user:20463] Interceptorを用いた際のIllegalAutoBindingPropertyRuntimeException

Shouta Morimoto [E-MAIL ADDRESS DELETED]
2010年 12月 27日 (月) 01:21:16 JST


森本と申します。
Seasar初心者ではありますが、掲題の件について質問させてください。


■開発環境
OS:Windows 7 Home Premium (64bit)
ブラウザ: Firefox3.6.13
DB: mysql5.5
コンパイラ: jdk1.6.0_22
使用中のライブラリ:(Jarを一部抜粋)
  - sa-struts-1.0.4-sp8.jar
  - struts-1.2.9.jar
  - mysql-connector-java-5.1.14-bin.jar
  - s2-framework-2.4.41.jar
  - s2-tiger-2.4.41.jar
  - s2-extension-2.4.41.jar
  - s2jdbc-gen-2.4.41.jar

SAStrutsを用いてWebアプリケーションを開発しております。
現在とあるアクションを実施する前にユーザ認証を実施しようと思い、
Interceptorを用いたところ、以下のようなエラーが発生し、
原因がわからず苦慮しております。
具体的には/<アプリ名>/admin/registUser/にアクセスしようとするとエラーが
発生します。

> 2010/12/27 0:40:11 org.apache.catalina.core.StandardWrapperValve invoke
> 致命的: サーブレット default のServlet.service()が例外を投げました
> org.seasar.framework.container.IllegalAutoBindingPropertyRuntimeException: [ESSR0080]クラス(scoreupgolf.interceptor.AdminAuthInterceptor)のプロパティ(user)の自動設定に失敗しました
> 	at org.seasar.framework.container.assembler.BindingTypeMustDef.doBind(BindingTypeMustDef.java:46)
> 	at org.seasar.framework.container.assembler.AbstractBindingTypeDef.bind(AbstractBindingTypeDef.java:91)
> 	at org.seasar.framework.container.assembler.AccessTypeFieldDef.bind(AccessTypeFieldDef.java:50)
> 	at org.seasar.framework.container.assembler.AccessTypeFieldDef.bind(AccessTypeFieldDef.java:42)
> 	at org.seasar.framework.container.assembler.AutoPropertyAssembler.assemble(AutoPropertyAssembler.java:56)
> 	at org.seasar.framework.container.deployer.PrototypeComponentDeployer.deploy(PrototypeComponentDeployer.java:43)
> 	at org.seasar.framework.container.impl.ComponentDefImpl.getComponent(ComponentDefImpl.java:111)
> 	at org.seasar.framework.container.impl.S2ContainerImpl.getComponent(S2ContainerImpl.java:129)
> 	at org.seasar.framework.container.customizer.AspectCustomizer$LookupAdaptorInterceptor.invoke(AspectCustomizer.java:193)
> 	at scoreupgolf.action.admin.RegistUserAction$$EnhancedByS2AOP$$5e8518d4$$MethodInvocation$$validate_registerConfirm2.proceed(MethodInvocationClassGenerator.java)
> 	at org.seasar.extension.tx.DefaultTransactionCallback.execute(DefaultTransactionCallback.java:58)
> 	at org.seasar.extension.tx.adapter.JTATransactionManagerAdapter.required(JTATransactionManagerAdapter.java:65)
> 	at org.seasar.extension.tx.RequiredInterceptor.invoke(RequiredInterceptor.java:50)
> 	at scoreupgolf.action.admin.RegistUserAction$$EnhancedByS2AOP$$5e8518d4$$MethodInvocation$$validate_registerConfirm2.proceed(MethodInvocationClassGenerator.java)
> 	at org.seasar.framework.aop.interceptors.TraceInterceptor.invoke(TraceInterceptor.java:73)
> 	at scoreupgolf.action.admin.RegistUserAction$$EnhancedByS2AOP$$5e8518d4$$MethodInvocation$$validate_registerConfirm2.proceed(MethodInvocationClassGenerator.java)
> 	at org.seasar.framework.aop.impl.NestedMethodInvocation.proceed(NestedMethodInvocation.java:55)
> 	at org.seasar.framework.aop.interceptors.TraceInterceptor.invoke(TraceInterceptor.java:73)
> 	at org.seasar.framework.aop.impl.NestedMethodInvocation.proceed(NestedMethodInvocation.java:53)
> 	at org.seasar.framework.container.customizer.AspectCustomizer$LookupAdaptorInterceptor.invoke(AspectCustomizer.java:198)
> 	at scoreupgolf.action.admin.RegistUserAction$$EnhancedByS2AOP$$5e8518d4$$MethodInvocation$$validate_registerConfirm2.proceed(MethodInvocationClassGenerator.java)
> 	at org.seasar.framework.aop.interceptors.ThrowsInterceptor.invoke(ThrowsInterceptor.java:79)
> 	at scoreupgolf.action.admin.RegistUserAction$$EnhancedByS2AOP$$5e8518d4$$MethodInvocation$$validate_registerConfirm2.proceed(MethodInvocationClassGenerator.java)
> 	at scoreupgolf.action.admin.RegistUserAction$$EnhancedByS2AOP$$5e8518d4.validate_registerConfirm(RegistUserAction$$EnhancedByS2AOP$$5e8518d4.java)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> 	at java.lang.reflect.Method.invoke(Unknown Source)
> 	at org.seasar.framework.util.MethodUtil.invoke(MethodUtil.java:96)
> 	at org.seasar.struts.action.ActionWrapper.execute(ActionWrapper.java:125)
> 	at org.seasar.struts.action.ActionWrapper.execute(ActionWrapper.java:87)
> 	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
> 	at org.seasar.struts.action.S2RequestProcessor.process(S2RequestProcessor.java:132)
> 	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
> 	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> 	at org.seasar.extension.filter.RequestDumpFilter.doFilter(RequestDumpFilter.java:127)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> 	at org.seasar.framework.container.filter.S2ContainerFilter.doFilter(S2ContainerFilter.java:79)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> 	at org.seasar.framework.container.hotdeploy.HotdeployFilter.doHotdeployFilter(HotdeployFilter.java:86)
> 	at org.seasar.framework.container.hotdeploy.HotdeployFilter.doFilter(HotdeployFilter.java:67)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> 	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
> 	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
> 	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
> 	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
> 	at org.seasar.struts.filter.RoutingFilter.forward(RoutingFilter.java:219)
> 	at org.seasar.struts.filter.RoutingFilter.doFilter(RoutingFilter.java:90)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> 	at org.seasar.framework.container.filter.S2ContainerFilter.doFilter(S2ContainerFilter.java:79)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> 	at org.seasar.framework.container.hotdeploy.HotdeployFilter.doHotdeployFilter(HotdeployFilter.java:99)
> 	at org.seasar.framework.container.hotdeploy.HotdeployFilter.doFilter(HotdeployFilter.java:67)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> 	at org.seasar.extension.filter.EncodingFilter.doFilter(EncodingFilter.java:69)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
> 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
> 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
> 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
> 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
> 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
> 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
> 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
> 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
> 	at java.lang.Thread.run(Unknown Source)

customizer.diconの内容は以下です。(一部抜粋)

>     <!-- ここよりカスタマイズ部分 -->
>     <initMethod name="addCustomizer">
> 		<arg>
> 			<component class="org.seasar.framework.container.customizer.AspectCustomizer">
> 				<property name="interceptorName">"adminAuthInterceptor"</property>
> 				<!-- ここ重要(追加必須) -->
> 				<property name="useLookupAdapter">true</property>
> 				<!-- このActionだけセッションチェックを行なう -->
> 				<initMethod name="addClassPattern">
> 					<arg>"scoreupgolf.action.admin"</arg>
> 					<arg>"RegistUserAction"</arg>
> 				</initMethod>
> 			</component>
> 		</arg>
> 	</initMethod>
>   </component>

また、該当のInterceptorの内容は以下になります。
ユーザ認証後にUserオブジェクトをセッションに持たせて、セッションがあるか
つroleがADMINだった場合にログインOKとしようとしています。
Userオブジェクトをセッションに持っていない場合、/login以下に飛ばし、ユー
ザ認証を行わせようと考えています。

> package scoreupgolf.interceptor;
> 
> import javax.annotation.Resource;
> 
> import org.aopalliance.intercept.MethodInvocation;
> import org.seasar.framework.aop.interceptors.AbstractInterceptor;
> import org.seasar.struts.annotation.Execute;
> 
> import scoreupgolf.dto.Role;
> import scoreupgolf.entity.User;
> 
> //import scoreupgolf.dto.UserDto;
> 
> public class AdminAuthInterceptor extends AbstractInterceptor {
>   private static final long serialVersionUID = 1L;
> 
>   @Resource
>   protected User user;
> 
>   @Override
>   public Object invoke(MethodInvocation invocation) throws Throwable {
>     // ここの条件がtrueであればログイン済みと判断
>     // ここの条件がfalseであればログインページへ移動
>     return (!isExecuteMethod(invocation) || isLoggedIn()) ? invocation
>         .proceed() : "/login/";
>   }
> 
>   private boolean isExecuteMethod(MethodInvocation invocation) {
>     return invocation.getMethod().isAnnotationPresent(Execute.class);
>   }
> 
>   private boolean isLoggedIn() {
>     // Sessionにユーザー情報が登録されているかチェック
>     // 最低限のもののみチェック
>     return (user != null && user.role == Role.ADMIN);
>   }
> }


上記のソースの中から以下の部分をコメントアウトして、

>   @Resource
>   protected User user;

加えて下記の部分をコメントアウトし、return trueを記述すると
認証は行いませんが、エラーは発生しません。

>     return (user != null && user.role == Role.ADMIN);


エラー内容を見ると、userプロパティを自動設定しようとしているように見えま
すが、なぜこのような事象が起きてしまうのかがわかっておりません。

メーリングリストの過去ログにも同様の事象は見受けられませんでしたので
この場を借りて質問させてください。
恐れ入りますが解決方法をご教示頂けますようお願いいたします。


Seasar-user メーリングリストの案内