Results 1 to 6 of 6
  1. #1
    kishan's Avatar
    kishan is offline Member
    Join Date
    Apr 2009
    Posts
    57
    Rep Power
    0

    Default How to set ClassPath?

    Hi,

    I am writing a sample testcase for my struts applications. I got some errors.
    error is
    log4j:WARN No appenders could be found for logger (servletunit.struts.MockStrutsTestCase).
    log4j:WARN Please initialize the log4j system properly.


    For that i got a solution that i have to set class path.But i dont know where and How to set to class path..........
    plz help me friends.........

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default

    That's not classpath stuff.
    That's setting up log4J.
    And they're runtime warnings, not errors as such.

  3. #3
    kishan's Avatar
    kishan is offline Member
    Join Date
    Apr 2009
    Posts
    57
    Rep Power
    0

    Default

    thank u tolls.........
    but when i run the test case it shows always a red bar eventhough the logic is correct, I dont know how to handle it, can u check it where the mistake is.....


    Test Case Code:
    Java Code:
    public class TestSuccess extends MockStrutsTestCase {
    
    	protected void setUp() throws Exception {
    		super.setUp();
    	}
    
    	protected void tearDown() throws Exception {
    		super.tearDown();
    	}
    	public  TestSuccess(String testName) 
        {
    		super(testName); 
    	}
    	public void testSuccessfulLogin() {
    		//setServletConfigFile("/WEB-INF/web.xml");
    		 
    		setRequestPathInfo("/LoginAction");
    		setConfigFile("/WEB-INF/struts-config.xml"); 
    		 addRequestParameter("userName","deryl");
    		 addRequestParameter("passWord","radar");
    		 actionPerform();
    		 verifyForward("success");
    		 assertEquals("deryl",(String) getSession().getAttribute("authentication"));
    		 verifyNoActionErrors();
    	}
    }
    Action Class code:

    Java Code:
    public class loginAction extends BaseAction{
    	 public ActionForward execute(ActionMapping mapping,
                 ActionForm form,
                 HttpServletRequest request,
                 HttpServletResponse response)
    {
    		 try {
    			 loginform Loginform=(loginform)form;
    			 String username = Loginform.getUserName();
    			 String password = Loginform.getPassWord();
    
    			 ActionErrors errors = new ActionErrors();
    			
    			 if ((!username.equals("deryl")) || (!password.equals("radar")))
    			 errors.add("password",new ActionError("error.password.mismatch"));
    
    			 if (errors.size()>0) {
    			 saveErrors(request,errors);
    			 return mapping.findForward("ProjectAction");
    			 }
    //			  store authentication info on the session
    			 HttpSession session = request.getSession();
    			 session.setAttribute("authentication", username);
    
    //			  Forward control to the specified success URI
    			
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    		 return mapping.findForward("success");
    
    }
    }
    In struts Config file I gave mapping like the following:
    Java Code:
    <form-beans>
     <form-bean name="LoginForm" type="loginform"/>
    </form-beans>	
    <action-mappings>    
    <action path="/LoginAction" type="loginAction" name="LoginForm" scope="request" input="/web/login.jsp">
    		     <forward name="success" path="/web/login.jsp"/>		      
            </action>
     </action-mappings>

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Can you bit explain how you configured the log4j? Seems that's much related with the log4j, nothing to do with classpath.

  5. #5
    kishan's Avatar
    kishan is offline Member
    Join Date
    Apr 2009
    Posts
    57
    Rep Power
    0

    Default

    i am using log4j-1.2.9.jar file.When I am running the above mentioned page , it works correctly.But in the case of running testcase only in cosole it showing the warning as mentioned and junit shows red bar always.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Classpath
    By JavaJunkie in forum New To Java
    Replies: 1
    Last Post: 04-07-2009, 07:17 AM
  2. help me to set classpath
    By srinivaspuvvala in forum Java Servlet
    Replies: 3
    Last Post: 01-18-2009, 07:13 PM
  3. j3d classpath
    By sales1 in forum New To Java
    Replies: 3
    Last Post: 12-23-2008, 01:51 AM
  4. Classpath
    By Preethi in forum New To Java
    Replies: 5
    Last Post: 06-20-2008, 09:00 AM
  5. Classpath on mac osx
    By jacobb in forum JDBC
    Replies: 0
    Last Post: 06-12-2008, 09:41 PM

Posting Permissions

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