Results 1 to 5 of 5
  1. #1
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    8

    Default SecurityFilter.doFilter(SecurityFilter.java:120)

    I'm developing a web server, with tomcat 5.0 as server IDE netbeans
    I have a problem with login page
    I have this web.xml file:

    Java Code:
    <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>GlucoWeb</realm-name>
    <form-login-config>
    <form-login-page>/login.htm</form-login-page>
    <form-error-page>/login.htm</form-error-page>
    </form-login-config>
    </login-config>
    Then when I execute it, this problem appears:
    Java Code:
    java.lang.NullPointerException
    org.securityfilter.filter.SecurityFilter.doFilter( SecurityFilter.java:120)
    2007-06-21 10:23:30 StandardWrapperValve[jsp]: Servlet.service()
    java.lang.NullPointerException
    at org.securityfilter.filter.SecurityFilter.doFilter( SecurityFilter.java:120)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:186)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:214)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:152)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:540)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:102)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:137)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:118)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:102)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:929)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:160)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:799)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:705)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:577)
    at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:683)
    at java.lang.Thread.run(Thread.java:595)
    any ideas???????
    Last edited by Heather; 06-30-2007 at 01:29 AM.

  2. #2
    Ed
    Ed is offline Senior Member
    Join Date
    Jun 2007
    Posts
    110
    Rep Power
    0

    Default

    can you paste the code?

  3. #3
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    8

    Default

    yes
    Java Code:
    package glucoweb;
    
    import javax.naming.*;
    import javax.sql.*;
    import java.sql.*;
    
    import java.io.IOException;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.io.*;
    
    import org.apache.struts.* ;
    
    
    
    public class LoginFilter implements Filter
    {
    private ServletContext context = null;
    private DataSource dataSource = null;
    
    protected FilterConfig filterConfig;
    
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
     throws IOException, ServletException
    {
    /* org.apache.log4j.BasicConfigurator.configure(); */
    String userID = null;
    
    HttpSession session = ((HttpServletRequest)request).getSession();
    
    //check if object userbean is present in session
    if (session.getAttribute("user") == null)
    {
    //if not, get user data and load it as a session bean
    userID = ((HttpServletRequest)request).getRemoteUser();
    
    User user = new User();
    
    String.
    context = filterConfig.getServletContext();
    dataSource = (DataSource) context.getAttribute(Globals.DATA_SOURCE_KEY);
    
    try {
    user = GlucoWebData.getUser(userID,dataSource);
    System.err.println("LoginFilter: " + user.getUserID());
    System.err.println("LoginFilter: " + user.getRole());
    } catch( Exception e ) {
    
    System.err.println("LoginFilter - Setting target to error");
    
    }
    session.setAttribute("user", user);
    
    
    } else if (((User)session.getAttribute("user")).getUserID() == null)
    {
    //if not, get user data and load it as a session bean
    userID = ((HttpServletRequest)request).getRemoteUser();
    
    User user = new User();
    
    
    
     String.
    context = filterConfig.getServletContext();
    dataSource = (DataSource) context.getAttribute(Globals.DATA_SOURCE_KEY);
    
    try {
    user = GlucoWebData.getUser(userID,dataSource);
    System.err.println("LoginFilter: " + user.getUserID());
    System.err.println("LoginFilter: " + user.getRole());
    } catch( Exception e ) {
    
    System.err.println("LoginFilter - Setting target to error");
    
    }
    session.setAttribute("user", user);
    
    }
    
    // pass the request on
    chain.doFilter(request, response);
    }
    
    public void init(FilterConfig config) throws ServletException
    {
    this.filterConfig = config;
    }
    
    public void destroy()
    {
    }
    
    }

  4. #4
    Ed
    Ed is offline Senior Member
    Join Date
    Jun 2007
    Posts
    110
    Rep Power
    0

    Default

    Check line 120
    there is the problem
    I don't know what is it because I don't have the numbers.

  5. #5
    Peter is offline Senior Member
    Join Date
    Jun 2007
    Posts
    119
    Rep Power
    0

    Default

    I think that you are using an object without a correct initializing
    check it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •