我有基于Jersey和Shiro安全的简单RESTful服务 但是当我尝试部署时,所有人都崩溃了。
的web.xml
<servlet>
<servlet-name>Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>alexiuscrow.ws</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>ShiroFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ShiroFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
Gradle依赖项:
dependencies {
compile 'org.glassfish.jersey.core:jersey-server:2.19'
compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.19'
compile 'org.apache.shiro:shiro-core:1.2.3'
compile 'org.apache.shiro:shiro-web:1.2.3'
}
输出:
18-Jul-2015 21:28:10.775 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class org.apache.shiro.web.env.EnvironmentLoaderListener
java.lang.ClassNotFoundException: org.apache.shiro.web.env.EnvironmentLoaderListener
//...
怎么了?为什么不能部署?
答案 0 :(得分:2)
您使用的是Shiro 1.2.4吗?你加入了slf4j-api-1.7.12
?
(Shiro要求的slf4j)
实际问题来自slf4j-api-1.7.12
它说:
Uncaught exception from servlet
java.lang.ExceptionInInitializerError
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:149)
...
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "createSecurityManager")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:382)
我的解决方案
我放slf4j-api-1.7.7
答案 1 :(得分:0)
似乎jar文件在构建时可能无法复制到WEB-INF/lib
文件夹。
尝试使用war
插件/任务,运行时配置的所有依赖项将被复制到WEB-INF/lib