Announcement Announcement Module
Collapse
No announcement yet.
Interceptor error :( Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Interceptor error :(

    Hello all,

    Im trying to use interceptor for my session checking. but whenever i try to run my project it gives me error. i think there is something wrong with my dispatcher-servlet but i still dont know what and where is the problem.

    here's my dispatcher servlet

    Code:
    <bean id="SessionChecking" class="Avatar.Controller.SessionCheckingInterceptor"></bean>
    
    
    
    <bean id="UserMaintenance" name="/Admin/UserMaintenance.htm" class="Avatar.AdminController.UserMaintenanceController">
          <property name="interceptors">
    		<list>
    			<ref bean="SessionChecking"/>
    		</list>
    	</property>
    
    </bean>
    here is my session checking code

    Code:
    package Avatar.Controller;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
     
    import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
    
    public class SessionCheckingInterceptor extends HandlerInterceptorAdapter{
    
        protected void handleRequestBefore(HttpServletRequest request, HttpServletResponse response) throws Exception {
                    //Only for trying purpose
                    //SessionChecking later will be implemented here
    
    
    		request.setAttribute("example", "TRUE");
    	}
    
    
    }
    the error is

    Code:
    SEVERE: Exception while loading the app
    java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: org.springframework.beans.NotWritablePropertyException: Invalid property 'interceptors' of bean class [Avatar.AdminController.UserMaintenanceController]: Bean property 'interceptors' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
            at com.sun.enterprise.web.WebApplication.start(WebApplication.java:117)
            at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
            at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
            at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236)
            at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
            at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:183)
            at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:272)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:305)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:320)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1176)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$900(CommandRunnerImpl.java:83)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
            at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1224)
            at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:365)
            at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:204)
            at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:166)
            at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:100)
            at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:245)
            at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
            at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
            at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
            at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
            at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
            at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
            at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
            at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
            at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
            at java.lang.Thread.run(Thread.java:662)

    Thanks a lot. Really appreciate if somebody helps me with the solution
    Last edited by ChelseaFans; Mar 14th, 2011, 04:30 AM.

  • #2
    You should apply interceptors to handlermapping instead of controller bean definition.

    Please refer Spring Documentation

    Example code from above link
    Code:
    <beans>
        <bean id="handlerMapping"
              class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="interceptors">
                <list>
                    <ref bean="officeHoursInterceptor"/>
                </list>
            </property>
            <property name="mappings">
                <value>
                    /*.form=editAccountFormController
                    /*.view=editAccountFormController
                </value>
            </property>
        </bean>
    
        <bean id="officeHoursInterceptor"
              class="samples.TimeBasedAccessInterceptor">
            <property name="openingTime" value="9"/>
            <property name="closingTime" value="18"/>
        </bean>
    <beans>

    Comment

    Working...
    X