2016-11-25 40 views
-1

我正在开发在GlassFish 4.1上运行并使用Spring Security 4.2.0进行用户认证的Java应用程序。 Spring Security在我的开发环境和生产服务器上工作了好几个月,这意味着我可以成功验证存储在相应服务器(开发或生产)中的用户凭证并重定向到应用程序的主页面之后。Spring Security 4在一台机器上引发HTTP状态404错误,但在另一台机器上工作正常

但是本周,我公司的另一位开发人员开始研究这个项目,在获得源代码并配置他的开发环境后,当他运行应用程序时,点击登录按钮后,他会每隔一次:

enter image description here

这些都是我曾经在我的应用程序配置Spring Security的认证文件:

的web.xml

<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> 

<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 

的applicationContext.xml

<beans:beans xmlns="http://www.springframework.org/schema/security" 
    xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:jee="http://www.springframework.org/schema/jee" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/jee 
    http://www.springframework.org/schema/jee/spring-jee.xsd 
    http://www.springframework.org/schema/security 
    http://www.springframework.org/schema/security/spring-security.xsd"> 

    <http auto-config="true" use-expressions="true"> 
     <intercept-url pattern="/login*" access="permitAll"/> 
     <intercept-url pattern="/**" access="hasRole('ROLE_USER')" /> 
     <form-login 
      login-page="/login.jsp" 
      default-target-url="/BMSim.html" 
      always-use-default-target="true" 
      authentication-failure-url="/login.jsp?error" 
      username-parameter="username" 
      password-parameter="password" /> 
     <logout logout-url="/logout" logout-success-url="/login.jsp?logout" /> 
     <!-- disable csrf protection --> 
     <csrf disabled="true"/> 
     <!-- allow SmartGWT to create frames and call servlets from there --> 
     <headers> 
      <frame-options policy="SAMEORIGIN" /> 
     </headers> 
    </http> 

    <jee:jndi-lookup id="dataSource" jndi-name="jdbc/BMSim" expected-type="javax.sql.DataSource" /> 

    <authentication-manager> 
     <authentication-provider> 
      <jdbc-user-service data-source-ref="dataSource" 
       users-by-username-query="select username,password, enabled from users where username=?" 
       authorities-by-username-query="select username, authority from authorities where username =? " /> 
     </authentication-provider> 
    </authentication-manager> 

</beans:beans> 

的login.jsp

<html> 
    <body class="login t_center" onload="document.f.username.focus();"> 
     <form name="f" action="login" method="POST"> 
      <label>user: </label> 
      <input id="username" type="text" name="username" /> 

      <label>password: </label> 
      <input id="password" type="password" name="password" /> 

      <input class="login-button" name="submit" type="submit" value="login"/> 

     </form> 
    </body> 
</html> 

的glassfish-web.xml中

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd"> 
<glassfish-web-app> 
    <context-root>/BMSim</context-root> 
</glassfish-web-app> 

我们已经尝试了很多不同的东西,但在Spring Security(或者Spring框架的任何部分)方面并不是专家,所以我们似乎无法找到问题所在。

关于什么可以导致这种奇怪的行为(在某些环境中工作,但不在其他人)?

回答

0

这终于解决了,结果是它是在pom.xml(v4.2)中定义的SQL Server驱动程序的版本与放置在Glassfish域的lib文件夹中的实际jar之间的冲突(第4版.0)。

相关问题