我目前正在构建一个Grails 1.3.5应用程序。它使用现有的模型层(共享代码 - 无GORM),并且我已经在conf/spring/resources.xml中为它成功配置了tomcat jndi连接,并且一切正常。然而,当我尝试配置Spring安全性时,我遇到了问题。我不使用spring安全插件,因为我想使用我们已经运行的另一个项目的xml安全配置。这使用Spring 3安全性。我已经按照各种博客以下步骤:配置没有插件web.xml问题的Spring Security
- 冉 '的Grails安装模板'
添加以下到模板/战争/ web.xml文件:
<filter>
<filter-name>Spring Security Filter Chain Proxy</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetBeanName</param-name>
<param-value>filterChainProxy</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Spring Security Filter Chain Proxy</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>
- 我将我的安全bean添加到了conf/spring目录中的 ,并让 验证了它们。
- 我已将弹簧安全罐 文件复制到grails库文件夹 目录中。版本3.0.2
当我运行“Grails的运行程序”我得到一个非常奇怪的异常,并在web.xml:
2010-11-26 12:16:02,512 INFO [startup.ContextConfig] No default web.xml
2010-11-26 12:16:02,518 ERROR [digester.Digester] End event threw exception
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:925)
...
Caused by: java.lang.IllegalArgumentException: Filter mapping specifies an unknown filter name hiddenHttpMethod
at org.apache.catalina.core.StandardContext.addFilterMap(StandardContext.java:2251)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:925)
at org.apache.tomcat.util.digester.SetNextRule.end(SetNextRule.java:193)
at org.apache.tomcat.util.digester.Rule.end(Rule.java:229)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1140)
... 437 more
我也复制了其他博客过滤代码建议:
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
但我仍然遇到同样的问题。
有没有人有关于我应该接下来尝试的建议?令人讨厌的是,我将这一切工作在安全模块版本2的旧版Grails(1.1.1)上,但现在我遇到了问题。
顺便说一下,我设法使用Spring Security 2.0.4来获得相同的应用程序。除了略有不同的安全性bean定义外,我以相同的方式配置了所有内容。安全性v3使用:org.springframework.web.filter.DelegatingFilterProxy,而v2使用:org.springframework.security.util.FilterToBeanProxy。我得到了上面的错误,并得到'没有名为'Spring Security Filter Chain Proxy'的bean被定义'。它在config/spring /中定义,但不在web-app/WEB-INF/ApplicationContext.xml中定义。虽然看起来不错,但在其中放置了bean defs。 – Matt 2010-11-26 15:48:54