Cannot invoke “” because “” is null

We Are Going To Discuss About Cannot invoke “” because “” is null. So lets Start this Java Article.

Cannot invoke “” because “” is null

  1. Cannot invoke “” because “” is null

    I think your problem is related with the lack of a @Component annotation in your BoardDao class.
    The component should have a @Component annotation to instantiate the singleton to be injected in your Service Layer.

  2. Cannot invoke “” because “” is null

    I think your problem is related with the lack of a @Component annotation in your BoardDao class.
    The component should have a @Component annotation to instantiate the singleton to be injected in your Service Layer.

Solution 1

I think your problem is related with the lack of a @Component annotation in your BoardDao class.
The component should have a @Component annotation to instantiate the singleton to be injected in your Service Layer.

@Component
public class BoardDao extends SqlSessionDaoSupport{

    @Autowired
    SqlSessionTemplate session;

    public List<BoardDto> listboard(BoardDto dto) {
        System.out.println("dao.");
        List<BoardDto> result = session.selectList("boarddate.listboard", dto);
        return result;
    }

}

If the problem persist, you may try with the @Repository annotation. Sadly I haven’t used the class SqlSessionDaoSupport, so I don’t know exactly the best annotation for that.

Original Author Of This Content

Solution 2

In my case it was with a Map, I wanted to increase its value, but this initial one will not exist, therefore it is null.

map.put(0, map.get(0) 1);

It was fixed by adding a validation, like so:

map.put(0, map.get(0) != null ? map.get(0) + 1 : 1);

Original Author Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment