Solved

Getting null pointer exception

Posted on 2011-02-21
6
299 Views
Last Modified: 2013-11-11
Getting null pointer exception at erros object in below code.

public void doSubmitAction(Object command){
            System.out.println(" in CompProgramController");
            Errors errors = null;
            CompProgram compProg = (CompProgram)command;
            
            System.out.println("Comp Program:"+ compProg.getCompProgDesc());
            
            CompProgramValidator rcv = new CompProgramValidator();
            rcv.validate(compProg, errors);
            
      

            if(!errors.hasErrors())
            {
                  CompProgramServiceImpl compPrImp = new CompProgramServiceImpl();
                  try {
                        String compId = compPrImp.addCompProgram(compProg);
                  }
                  catch(Exception e)
                  {
                        //throw new Exception();
                  }

            }
    }      

-------------
CompProgramController.java
CompProgramValidator.java
0
Comment
Question by:manu112233
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 20

Accepted Solution

by:
Sathish David  Kumar N earned 500 total points
ID: 34942016
your validator method is not called !! so

error is null  as per declartion   ///    Errors errors = null;So this line give if(!errors.hasErrors()) null pointer exection
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 34942028
Sorry your validator method nothing is return it dont have any error so it does not return anything

as per ur declartion ur error is null so its give null pointer exception
0
 
LVL 1

Expert Comment

by:dearkasi
ID: 35302261
Hi,

Put a null check while using errors. Replace the line with '  if(!errors.hasErrors())' with '  if(null != errors && !errors.hasErrors())'.
0
 
LVL 6

Expert Comment

by:Mahesh Bhutkar
ID: 35873537
I suggest to initialize errors object.
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 36935140
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
netstat -ano | find "8000" and taskkill /f /pid 2984 3 112
java stored proc example 9 65
ejb stateless example 2 67
junit as external jar or library 7 58
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question