reset password
Author Message
vluu2
Posts: 64
Posted 17:12 Feb 03, 2015 |

Hi guys, so I keep getting these 3 errors whenever I try to run my code on eclipse (localhost) and I have no idea if it's my code or something else 

1) java.util.concurrent.ExecutionException
2) org.apache.catalina.LifecycleException
3) java.lang.IllegalArgumentException

This is my code, as you can see I've barely did anything so far but it's still giving me this error.... 

Can anyone help me? 

package cs320.Homework2;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cs320.homework1.*;
@WebServlet("/Homework2/Login")

public class Login extends HttpServlet 
{
    private static final long serialVersionUID = 1L;
    
    ArrayList<Homework1User> newUser = new ArrayList<Homework1User>();

    public void init() throws ServletException {
        
        ServletContext context = this.getServletContext();

        if(context.getAttribute("UserInfo") == null) 
        {
            newUser.add(new Homework1User("John", "Doe", "john@doe.com", "aa1!", "aa1!", "91100"));
            newUser.add(new Homework1User("Bobby", "White", "bobby@white.com", "5sf1@", "5sf1@", "92314"));
            context.setAttribute("UserInfo", newUser);
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
    {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        
        out.println("<!DOCTYPE html><html lang=\"en\">");
        
        out.println("<html>");
        
        out.println("<head>");
//            out.println("<meta charset=\"UTF-8\">");
            out.println("<title>Login Page</title><small>CS 320</small>");
                out.println("<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css\">");
        out.println("</head>");
        
        out.println("<body>");
        
        out.println("</body>");
        out.println("/html>");
        
        
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

}

hippiewho
Posts: 46
Posted 17:25 Feb 03, 2015 |

I think - and i could be wrong - something is wrong in your java class possibly in ur constructor.

 

EDIT: also your closing html tag is missing an <

Last edited by hippiewho at 17:26 Feb 03, 2015.
vluu2
Posts: 64
Posted 17:28 Feb 03, 2015 |

That could be the case if I didn't copy and paste this from my Homework 1... which worked last week. 

Also, when I go back to Lab 2, it doesn't work either. 

I checked my Java Complier, yes it's Java 1.7. and I am using Tomcat 7.0 as well, 

so... idk 

hal255
Posts: 51
Posted 17:29 Feb 03, 2015 |

I just copied your code and fixed the package names, and it ran without errors.

hippiewho
Posts: 46
Posted 17:30 Feb 03, 2015 |

have u created a new web.xml? maybe the records are missing? 

hippiewho
Posts: 46
Posted 17:32 Feb 03, 2015 |

@hal yea i did the same and had no problem which is why i thought maybe the class was messed up or the arguments being passed which may be why ur getting an illegal argument exception

vluu2
Posts: 64
Posted 17:33 Feb 03, 2015 |

@HIPPIEWHO This is on my localhost, they run fine on the server. 

@HAL255 Thanks for testing on your localhost. 

In this case, I guess i'll have to keep uploading to the server just to test things..... 

unless I find a solution to this