Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Spring, Hibernate, MySQL Stand-Alone App

  1. #11
    Join Date
    Oct 2007
    Posts
    26

    Default

    Quote Originally Posted by karldmoore View Post
    If you post the full stacktrace, then it's possible to see if a transaction proxy was applied. Is it also possible to see the code you are running here?
    You got the full relevant stack trace in the original post , but here we go, the absolutely full deal...

    This line triggers the stack trace below...thx...

    sessionFactory.getCurrentSession();


    16:45:30,843 INFO MyComponentEditorDao:24 - createMyComponent(aMyComponent)...
    16:45:30,859 DEBUG SessionFactoryUtils:315 - Opening Hibernate Session
    16:45:30,921 DEBUG SessionImpl:220 - opened session at timestamp: 11935287308
    16:45:30,921 DEBUG SessionFactoryUtils:771 - Closing Hibernate Session
    16:45:30,921 ERROR MyComponentEditorService:43 - ***Exception***
    org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
    at org.springframework.orm.hibernate3.AbstractSession FactoryBean$TransactionAwareInvocationHandler.invo ke(AbstractSessionFactoryBean.java:300)
    at $Proxy17.getCurrentSession(Unknown Source)
    at myco.dao.hibernate.HibernateDao.getSession(Hiberna teDao.java:28)
    at myco.MyComponent.dao.MyComponentEditorDao.createMy Component(MyComponentEditorDao.java:26)
    at myco.MyComponent.service.editor.MyComponentEditorS ervice.createMyComponent(MyComponentEditorService. java:38)
    at myco.MyComponent.tools.LoadMyComponentApp.go(LoadM yComponentApp.java:79)
    at myco.MyComponent.tools.LoadMyComponentApp.main(Loa dMyComponentApp.java:91)

  2. #12
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    The full stacktrace is useful, as you can clearly see there is no transactional proxy in there. So are you using beanFactory or applicationContext? Is it possible to see the code that you are trying to run? Can you wrap it in [code] [ /code] tags to make it readable.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  3. #13
    Join Date
    Oct 2007
    Posts
    26

    Default

    Here we go...thx!

    Code:
            ClassPathResource resource = new ClassPathResource("spring-context.xml");
            BeanFactory factory = new XmlBeanFactory(resource);
            editor = (MyComponentEditorService)factory.getBean("myComponentEditorService");        
            // Some code to build to request...and then
            editor.createMyComponent(req);
        // MyComponentEditorService...
    
        @Transactional(rollbackFor=Exception.class)
        public void createMyComponent(CreateReq aReq)
            throws MyException
        {
             editorDao.create(aReq.getData());
        }
    
             // Dao...
             // This line gives the propblem...
    public void create()
        throws Exception
    {
             sessionFactory.getCurrentSession()
    }
    Quote Originally Posted by karldmoore View Post
    The full stacktrace is useful, as you can clearly see there is no transactional proxy in there. So are you using beanFactory or applicationContext? Is it possible to see the code that you are trying to run? Can you wrap it in [code] [ /code] tags to make it readable.

  4. #14
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    Try using an ApplicationContext instead of a BeanFactory.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  5. #15
    Join Date
    Oct 2007
    Posts
    26

    Thumbs up

    Quote Originally Posted by karldmoore View Post
    Try using an ApplicationContext instead of a BeanFactory.
    I followed your recommendation and it worked like a charm.

    Thanks all for helping and thanks all for being persistent!!! Great crew hanging around here!!!

    Code:
    ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext("spring-context.xml");

  6. #16
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    Next time try to listen what people tell you from the start.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •