Menu

ServletException: Error matching patterns

Help
goane
2005-12-09
2013-04-15
  • goane

    goane - 2005-12-09

    hey all,
    i am new with securityFilter.
    I use Tomcat5.5 and SecurityFilter2.2.
    At the beginning i used realm with a Postgresql DB. It worked very fine. But i wanted to use SecurityFilter, here comes the pb.

    I get a HTPP 500 error by tomcat with a "ServletException: Error matching patterns"

    -------------------------->the stacckTrace:

    exception

    javax.servlet.ServletException: Error matching patterns
    org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:148)

    cause mère

    java.lang.NullPointerException
    org.securityfilter.realm.catalina.CatalinaRealmAdapter.authenticate(CatalinaRealmAdapter.java:95)
    org.securityfilter.authenticator.FormAuthenticator.processLogin(FormAuthenticator.java:178)
    org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:138)

    ---------------------> securityFilter-config.xml

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <!DOCTYPE securityfilter-config PUBLIC
        "-//SecurityFilter.org//DTD Security Filter Configuration 2.0//EN"
        "http://www.securityfilter.org/dtd/securityfilter-config_2_0.dtd">

    <securityfilter-config>

       <security-constraint>
          <web-resource-collection>
             <web-resource-name>Secure Page</web-resource-name>
             <url-pattern>/pages/clients/*</url-pattern>
          </web-resource-collection>
          <auth-constraint>
             <role-name>admin</role-name>
          </auth-constraint>
       </security-constraint>

       <security-constraint>
          <web-resource-collection>
             <web-resource-name>Secure page that the example user is not authorized to view</web-resource-name>
             <url-pattern>/forbiddenPage.jsp</url-pattern>
          </web-resource-collection>
          <auth-constraint>
             <role-name>notinthisrole</role-name>
          </auth-constraint>
       </security-constraint>

       <login-config>
          <auth-method>FORM</auth-method>
          <form-login-config>
             <form-login-page>/index.jsp</form-login-page>
             <form-error-page>/pages/loginError.jsp</form-error-page>
             <form-default-page>/pages/clients/logged.jsp</form-default-page>
          </form-login-config>
       </login-config>

       <!-- start with a Catalina realm adapter to wrap the Catalina realm defined below -->
       <realm className="org.securityfilter.realm.catalina.CatalinaRealmAdapter" />

        <Realm className="org.apache.catalina.realm.JDBCRealm">
            <realm-param name="driverName" value="org.postgresql.Driver"/>
            <realm-param name="connectionURL" value="jdbc:postgresql://192.168.1.142:5432/goane_db" />
            <realm-param name="connectionName" value="goane" />
            <realm-param name="connectionPassword" value="goane"/>
            <realm-param name="userTable" value="users"/>
            <realm-param name="userRoleTable" value="user_roles"/>
            <realm-param name="userNameCol" value="user_name"/>
            <realm-param name="userCredCol" value="user_password"/>
            <realm-param name="roleNameCol" value="role_name"/>
        </Realm>
    </securityfilter-config>

    -------------------------------> web.xml

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        version="2.4">
       
        <display-name>security</display-name>

        <context-param>
            <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
            <param-value>resources.application</param-value>
        </context-param>
        <servlet>
             <!-- Standard Action Servlet Configuration (with debugging) -->
            <servlet-name>action</servlet-name>
            <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
            <init-param>
                <param-name>config</param-name>
                <param-value>/WEB-INF/config/struts-config.xml</param-value>
            </init-param>
            <init-param>
                <param-name>debug</param-name>
                <param-value>2</param-value>
            </init-param>
            <init-param>
                <param-name>detail</param-name>
                <param-value>2</param-value>
            </init-param>
            <load-on-startup>2</load-on-startup>
        </servlet>
        <servlet-mapping>
             <!-- Standard Action Servlet Mapping -->
            <servlet-name>action</servlet-name>
            <url-pattern>*.do</url-pattern>
        </servlet-mapping>
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
        <jsp-config>
            <taglib>
                <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
                <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
                <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>http://java.sun.com/jsp/jstl/sql</taglib-uri>
                <taglib-location>/WEB-INF/tld/sql.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>http://java.sun.com/jsp/jstl/xml</taglib-uri>
                <taglib-location>/WEB-INF/tld/x.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>http://java.sun.com/jsp/jstl/functions</taglib-uri>
                <taglib-location>/WEB-INF/tld/fn.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>/tags/struts-bean</taglib-uri>
                <taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>/tags/struts-html</taglib-uri>
                <taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>/tags/struts-logic</taglib-uri>
                <taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>
            </taglib>
            <taglib>
                <taglib-uri>/tags/struts-tiles</taglib-uri>
                <taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location>
            </taglib>
           
            <taglib>
                <taglib-uri>/tags/struts-nested</taglib-uri>
                <taglib-location>/WEB-INF/tld/struts-nested.tld</taglib-location>
            </taglib>
        </jsp-config>
          <!-- make the session time-out after one minute -->
       <session-config>
          <session-timeout>1</session-timeout>
       </session-config>
       <filter>
          <filter-name>Security Filter</filter-name>
          <filter-class>org.securityfilter.filter.SecurityFilter</filter-class>
          <init-param>
             <param-name>config</param-name>
             <param-value>/WEB-INF/securityfilter-config.xml</param-value>
             <description>Configuration file location (this is the default value)</description>
          </init-param>
          <init-param>
             <param-name>validate</param-name>
             <param-value>true</param-value>
             <description>Validate config file if set to true</description>
          </init-param>
       </filter>
       <!-- map all requests to the SecurityFilter, control what it does with configuration settings -->
       <filter-mapping>
          <filter-name>Security Filter</filter-name>
          <url-pattern>/*</url-pattern>
       </filter-mapping>
    </web-app>

    ----------------------------> login.jsp

    <%@ page import="org.securityfilter.example.*"%>
    <div id="login">
             <form id="<%=Constants.LOGIN_FORM_ID%>" action="<%=response.encodeURL(Constants.LOGIN_FORM_ACTION)%>" method="POST">

    Username:
    <input type="text"
       name="<%=Constants.LOGIN_USERNAME_FIELD%>"
       value="<%=Constants.VALID_USERNAME%>"
       />
    Password:
    <input type="password"
       name="<%=Constants.LOGIN_PASSWORD_FIELD%>"
       value="<%=Constants.VALID_PASSWORD%>"
        />
    </div>
    <div id="submit">
            <input type=submit value="Login">
        </form>
    </div>

    I really don't understand why thi error happend.
    Any help would be very appreciate.
    Thx.

    --
    goane

     
    • goane

      goane - 2005-12-10

      ok i've found the pb.
      This is in the securityFilter-config.xml.
      I've written <Realm>...</Realm> and it is <realm>...</realm>.
      Everything works fine now.

      --
      goane

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.