最近项目需要集成shiro
我在本地已经开发完成,能够运行。但是我将代码部署在was7服务器下时,可以启动,但是无法登陆。
登陆的时候,运行到Subject user = SecurityUtils.getSubject();这段代码的时候
一直报错:No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton. This is an invalid application configuration.
项目用的是 struts2 + spring2.5.6 + shiro1.2.2
本地用的是tomcat,运行完全没问题,目前不知道咋个解决了,请大神帮忙看看,谢谢。非常急
我的XML配置:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>cdp</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.xml</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/spring/*.xml,classpath*:/shiro/applicationContext_*.xml</param-value>
</context-param>
<!-- <context-param>
<param-name>contextClass</param-name>
<param-value>org.jboss.spring.vfs.context.VFSXmlWebApplicationContext</param-value>
</context-param> -->
<!-- Shiro Security filter -->
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>*.do</url-pattern>
<url-pattern>*.jsp</url-pattern>
<url-pattern>*.html</url-pattern>
<url-pattern>/*</url-pattern>
<!-- <dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher> -->
</filter-mapping>
<!-- GJZHU ADD 20120906 -->
<filter>
<filter-name>encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<!--过滤器名字 -->
<filter-name>struts2</filter-name>
<!-- 过滤器支持的struts2类 -->
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<!--过滤器拦截名字 -->
<filter-name>struts2</filter-name>
<!--过滤器拦截文件路径名字 -->
<url-pattern>*.do</url-pattern>
<url-pattern>*.jsp</url-pattern>
<url-pattern>/</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>com.travelsky.cdp.service.config.SetApplicationInfo</listener-class>
</listener>
<servlet>
<servlet-name>VerificationCodeServlet</servlet-name>
<servlet-class>com.travelsky.cdp.servlet.verification.VerificationCodeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>VerificationCodeServlet</servlet-name>
<url-pattern>/servlet/VerificationCodeServlet</url-pattern>
</servlet-mapping>
<!-- download servlet -->
<servlet>
<servlet-name>Download</servlet-name>
<servlet-class>com.travelsky.cdp.servlet.download.DownloadFromFullPath</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Download</servlet-name>
<url-pattern>/servlet/Download</url-pattern>
</servlet-mapping>
<!-- picNum servlet -->
<servlet>
<servlet-name>PicNumServlet</servlet-name>
<servlet-class>com.travelsky.cdp.servlet.picinfo.InfoPicServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>PicNumServlet</servlet-name>
<url-pattern>/servlet/PicNumServlet</url-pattern>
</servlet-mapping>
<!--CDP WebService servlet-->