I have developed a Spring web application and its working fine. I have bean creation mapping structure as like : My Controller:
@Controller
@RequestMapping("appointmentDiary")
public class AppointmentDiaryController {
private IAppointmentDiaryService appointmentDiaryService;
public IAppointmentDiaryService getAppointmentDiaryService() {
return appointmentDiaryService;
}
public void setAppointmentDiaryService(IAppointmentDiaryService appointmentDiaryService) {
this.appointmentDiaryService = appointmentDiaryService;
}
}
My Service Interface:
public interface IAppointmentDiaryService
{
public Integer getAppointmentDiaryNo();
}
My Impl Class:
public class AppointmentDiaryServiceImpl implements IAppointmentDiaryService{
private IAppointmentDiaryDAO appointmentDiaryDAO;
public IAppointmentDiaryDAO getAppointmentDiaryDAO(){
return appointmentDiaryDAO;
}
public void setAppointmentDiaryDAO(IAppointmentDiaryDAO appointmentDiaryDAO) {
this.appointmentDiaryDAO = appointmentDiaryDAO;
}
public Integer getAppointmentDiaryNo(){
InternalResultsResponse<Object> objResponse = getAppointmentDiaryDAO().getAppointmentDiaryNo();
return objResponse;
}
My DAO Interface:
public interface IAppointmentDiaryDAO extends IGenericDAO
{
public InternalResultsResponse<Object> getAppointmentDiaryNo();
}
My DAO Impl calss:
public class AppointmentDiaryDAOImpl extends GenericDAOImpl implements
IAppointmentDiaryDAO {
public InternalResultsResponse<Object> getAppointmentDiaryNo() {
InternalResultsResponse<Object> response = new InternalResultsResponse<Object>();
String sql = SqlProperties.getSQLStatement("getAppointmentDiaryNo");
Session session = getSession();
Transaction tr = session.beginTransaction();
response = HibernateUtil.executeSQLQuery(session, sql);
tr.commit();
return response;
}
}
Now, I don't want to use this structure, I want to create a jar file of all Service Interface, Impl class, DAO Interface and Impl Class that means except controller everything should be in jar file. But when I create a jar file and add in project's class path and run the project that time an exception occurred : Exception is:
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.nmmc.cess.service.impl.AppointmentDiaryServiceImpl] for bean with name 'appointmentDiaryServiceImpl' defined in ServletContext resource [/WEB-INF/config/cess-service-application-context.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: com/nmmc/cess/service/IAppointmentDiaryService
So, how can I configure that will map the beans defined in xml file by Spring. My bean configuration is working fine when I run project without using that jar file. Please give a solution. Thanks in advance.