close

[Solved] Servlet.service() for servlet [dispatcherServlet] in context with path

Hello Guys, How are you all? Hope You all Are Fine. Today I am facing the following error Servlet.service() for servlet [dispatcherServlet] in context with path in Java. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Servlet.service() for servlet [dispatcherServlet] in context with path Error Occurs?

Today I am facing the following error Servlet.service() for servlet [dispatcherServlet] in context with path in Java.

How To Solve Servlet.service() for servlet [dispatcherServlet] in context with path Error ?

  1. How To Solve Servlet.service() for servlet [dispatcherServlet] in context with path Error ?

    To Solve Servlet.service() for servlet [dispatcherServlet] in context with path Error Please add the Proper Annotations in Model Class that will clear the issues.

  2. Servlet.service() for servlet [dispatcherServlet] in context with path

    To Solve Servlet.service() for servlet [dispatcherServlet] in context with path Error Please add the Proper Annotations in Model Class that will clear the issues.

Solution 1

You need to add @Autowired to bankCitiBankDAO too:

    @Autowired
    private BankOCBCDAO bankOCBCDAO;
    @Autowired
    private BankCitiBankDAO bankCitiBankDAO;

But as field injection is not the best thing todo , you should go with constructor injection:

@Service
public class PaymentServiceImpl implements PaymentService{

    private BankOCBCDAO bankOCBCDAO;
    private BankCitiBankDAO bankCitiBankDAO;

    public PaymentServiceImpl(BankOCBCDAO bankOCBCDAO, BankCitiBankDAO bankCitiBankDAO){
       this.bankOCBCDAO = bankOCBCDAO;
       this.bankCitiBankDAO = bankCitiBankDAO;
    }
...
}

Solution 2

Please add the Proper Annotations in Model Class that will clear the issues.

Reference

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="bank_id")
private int bankId;

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read