-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Strange Error when using Hibernate in a web application
PostPosted: Fri Mar 15, 2013 4:43 am 
Beginner
Beginner

Joined: Tue Feb 05, 2013 10:04 am
Posts: 20
Hello I'm new to Hibernate.

I have generated with Hibernate Tools a database access module. The generator generates the code of the DAOS and Hibernate Beans. When I test this module in a simple Java application all works fine, but when I test
it in a Spring Web application I get a very strange error. Since my module is an independent jar it should access the database without regarding the circumstance of being executed in a simple Java application or a Web application. The code of my web application is:

Code:
/**
* Handles requests for the application home page.
*/
@Controller
@RequestMapping("/")
public class Controller implements ApplicationContextAware
{
   

   private ApplicationContext applicationContext;
   
   /**
    * Simply selects the home view to render by returning its name.
    */
   @RequestMapping(value = "/purchased/songs", method = RequestMethod.GET)
   public String home(Model model)
   {   
      
      SessionManager.startOperation();
      
      ChargeTryDAOBase ctdb=new ChargeTryDAOBase();
      
       List <ChargeTry> data=ctdb.findByRemoteId("dsfsdfsdf8");
      
      
      SessionManager.endOperation();
      
      model.addAttribute("result", "data" );
   
      return "home";
   }
   
   

   @Override
   public void setApplicationContext(ApplicationContext arg0) throws BeansException
   {
     this.applicationContext = arg0;
   }
   
}


When running this code on Tomcat I get following error:

Code:
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.SessionFactory.getCurrentSession()Lorg/hibernate/Session;
   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:949)
   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
   org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:722)



When I change some Hibernate dependencies I get following error:

Code:
        java.lang.IllegalStateException: Could not locate SessionFactory in JNDI


When I test the above code in a simple Java application all works fine.

Is this a spring-hibernate configuration problem?

Thank you for your help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.