Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error in ActionServlet

807591Mar 13 2008 — edited Mar 13 2008
Hi All,

I am using a Struts application wherein i am using a LoginControl class
which is extending ActionServlet such that it act as a controller.

Code for the LoginControl.
public class LoginControl extends  ActionServlet{

	private static final Logger logger = Logger.getLogger(LoginControl.class.getName());


	public void init() {

		try {
			   super.init();
			  // String prefix =  getServletContext().getRealPath("/");

			   String propFile = "myapp.properties";
			   File file = new File(propFile);

			   // if the log4j-init-file is set
			   if(propFile != null) {
				   PropertyConfigurator.configure(file.getAbsolutePath());
				   GlobalValues.configure(file.getAbsolutePath());
				}
		   }
		   catch(Exception e) {
			logger.error("myappApplication has an error", e);


		   }
	}

	protected void process(HttpServletRequest request, HttpServletResponse response)
	throws IOException, ServletException
	{
		System.out.println("1");
		try
		{
			if (sessionValidate(request))
			{
				logger.debug("validation is true");
				System.out.println("inside validation");
				HttpSession session=request.getSession();
				request.setAttribute("interval",new Integer(session.getMaxInactiveInterval()));
				super.process(request ,response);
			}
			else
			{
				logger.debug("validation is false");
				response.sendRedirect(request.getContextPath()+"/jsp/LogOut.jsp");
			}
		}
		catch(Exception e)
		{
			logger.debug("error occurred in LoginControl:",e);
			e.printStackTrace();
		}
	
	private boolean sessionValidate(HttpServletRequest request)
	{
		
			HttpSession session = request.getSession();
			String reqUid=(String)request.getParameter("uid");
			String sessUid=(String)session.getAttribute("uid");
			
			logger.debug("the session id"+sessUid);
			logger.debug("the request id"+reqUid);
			if(null==reqUid && null==sessUid)
			{
				sessUid=(new Guid()).toString();
				session.setAttribute("uid", sessUid);
				request.setAttribute("uid", sessUid);
				return true;
			}
			f(null!=reqUid && null!=sessUid && reqUid.equals(sessUid)&& !("popup").equals(request.getParameter("pFlag"))&&!"false".equals(request.getParameter("vAction")))
			{
				sessUid=(new Guid()).toString();
				session.setAttribute("uid", sessUid);
				request.setAttribute("uid", sessUid);
				
				logger.debug("validation:true");
				return true;
			}
			else
			{
				logger.debug("validation:false");
				return false;
			}
		
	}
while trying to run the application from the login page i am getting the null pointer
excpetiuon at the ActionServlet.process.
and the first two SOP's are printed but the logs are not coming through.

the log
[13/Mar/2008:14:59:48] INFO ( 5424): CORE3282: stdout: inside validation
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: java.lang.NullPointerException
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at org.apache.struts.action.ActionServlet.getRequestProcessor(ActionServlet.java:854)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at 
com.myapp.action.LoginControl.process(Unknown Source)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:720)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at org.apache.catalina.core.StandardWrapperValve.access$000(StandardWrapperValve.java:118)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at org.apache.catalina.core.StandardWrapperValve$1.run(StandardWrapperValve.java:278)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at java.security.AccessController.doPrivileged(Native Method)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:274)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:203)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:158)
[13/Mar/2008:14:59:48] WARNING ( 5424): CORE3283: stderr: 	at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598)
my real botheration is why the logs are not getting printed.I was able to do so before.

Any pointers would be hugely appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 10 2008
Added on Mar 13 2008
3 comments
232 views