spring - Struts 2 Annotation With Interceptors not Working -
i have been trying implement interceptors in application each , works fine till time don't include interceptor annotation in action. but, when add interceptoref tag in action code below:
@interceptorrefs({ @interceptorref("mylogging") }) public class loginaction implements modeldriven{
it starts giving me exception
severe: exception starting filter struts2 unable load configuration. - [unknown location] @ org.apache.struts2.dispatcher.dispatcher.init(dispatcher.java:431) @ org.apache.struts2.dispatcher.ng.initoperations.initdispatcher(initoperations.java:69) @ org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter.init(strutsprepareandexecutefilter.java:51) @ org.apache.catalina.core.applicationfilterconfig.initfilter(applicationfilterconfig.java:281) @ org.apache.catalina.core.applicationfilterconfig.getfilter(applicationfilterconfig.java:262) @ org.apache.catalina.core.applicationfilterconfig.<init>(applicationfilterconfig.java:107) @ org.apache.catalina.core.standardcontext.filterstart(standardcontext.java:4746) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5399) @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150) @ org.apache.catalina.core.containerbase.addchildinternal(containerbase.java:901) @ org.apache.catalina.core.containerbase.addchild(containerbase.java:877) @ org.apache.catalina.core.standardhost.addchild(standardhost.java:633) @ org.apache.catalina.startup.hostconfig.deploywar(hostconfig.java:977) @ org.apache.catalina.startup.hostconfig$deploywar.run(hostconfig.java:1654) @ java.util.concurrent.executors$runnableadapter.call(executors.java:441) @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:303) @ java.util.concurrent.futuretask.run(futuretask.java:138) @ java.util.concurrent.threadpoolexecutor$worker.runtask(threadpoolexecutor.java:886) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:908) @ java.lang.thread.run(thread.java:662) caused by: unable load configuration. - [unknown location] @ com.opensymphony.xwork2.config.configurationmanager.getconfiguration(configurationmanager.java:58) @ org.apache.struts2.dispatcher.dispatcher.init_preloadconfiguration(dispatcher.java:374) @ org.apache.struts2.dispatcher.dispatcher.init(dispatcher.java:418) ... 19 more caused by: unable find interceptor class referenced ref-name mylogging - [unknown location]
i using struts 2 struts2-convention-plugin , hibernate, spring , using maven dependency management.
i have following dependencies have defined in maven's pom file:
<dependency> <groupid>org.apache.struts</groupid> <artifactid>struts2-core</artifactid> <version>2.1.8.1</version> </dependency> <!-- struts 2 + spring plugins --> <dependency> <groupid>org.apache.struts</groupid> <artifactid>struts2-spring-plugin</artifactid> <version>2.1.8.1</version> </dependency> <!-- mysql database driver --> <dependency> <groupid>mysql</groupid> <artifactid>mysql-connector-java</artifactid> <version>5.1.9</version> </dependency> <!-- spring framework --> <dependency> <groupid>org.springframework</groupid> <artifactid>spring</artifactid> <version>2.5.6</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-web</artifactid> <version>2.5.6</version> </dependency> <!-- hibernate core --> <dependency> <groupid>asm</groupid> <artifactid>asm-all</artifactid> <version>3.3</version> </dependency> <dependency> <groupid>asm</groupid> <artifactid>asm</artifactid> <version>3.3</version> </dependency> <dependency> <groupid>org.hibernate</groupid> <artifactid>hibernate-core</artifactid> <version>3.6.7.final</version> </dependency> <dependency> <groupid>org.apache.struts</groupid> <artifactid>struts2-convention-plugin</artifactid> <version>2.1.8.1</version> </dependency> <dependency> <groupid>javax.servlet</groupid> <artifactid>javax.servlet-api</artifactid> <version>3.0.1</version> <scope>provided</scope> </dependency> <dependency> <groupid>log4j</groupid> <artifactid>log4j</artifactid> <version>1.2.15</version> </dependency>
i have placed struts.xml in src root. far think there must missing in configuration.
struts.xml file configuration:
<struts> <constant name="struts.devmode" value="false" /> <constant name="struts.convention.package.locators.basepackage" value="com.abc.lab"/> <constant name="struts.convention.exclude.packages" value="org.apache.struts.*,org.apache.struts2.*,org.springframework.web.struts.*,org.springframework.web.struts2.*,org.hibernate.*,warfilename.*"/> <constant name="struts.convention.action.checkimplementsaction" value="false"/> <constant name="struts.convention.package.locators" value="action,actions,struts,struts2"/> <package name="default" extends="struts-default" namespace="/"> <interceptors> <interceptor name="mylogging" class="com.abc.lab.interceptor.logginginterceptor"> </interceptor> <interceptor-stack name="loggingstack"> <interceptor-ref name="mylogging" /> <interceptor-ref name="defaultstack" /> </interceptor-stack> </interceptors> </package> </struts>
if errors "unable find interceptor class referenced ref-name xyz". means package convention placing actions, not extend package interceptor defined. fix problem either 1)use @parentpackage annotation(or struts.convention.default.parent.package) passing name of package defines interceptor, or 2) create package in xml extends package defines interceptor, , use @parentpackage(or struts.convention.default.parent.package) point it.
Comments
Post a Comment