UnknownServiceException: Unknown service requested (Hibernate/Spring)

前端 未结 1 1998
逝去的感伤
逝去的感伤 2020-12-07 04:58

This problem bothers me now for days ..

I\'m trying to get the current session from my sessionFactor but receive an org.hibernate.service.UnknownS

相关标签:
1条回答
  • 2020-12-07 05:21

    So, I don't know why it came up to me to comment out the line

    ((ConfigurableApplicationContext)applicationContext).close();
    

    in init(ServletConfig config) as such

    @Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("/appServlet/servlet-context.xml");
    
        this.restaurantOwnerRepository = (RestauranOwnerDAO)applicationContext.getBean("restaurantOwnerRepository");
    
        //((ConfigurableApplicationContext)applicationContext).close();
    }
    

    but not closing the application context sure did help here..

    I didn't thought about this. I just followed the warning in Eclipse

    Resource leak: 'applicationContext' is never closed

    and closed it without thinking obviously..

    0 讨论(0)
提交回复
热议问题