“Could not locate SessionFactory in JNDI” with Hibernate in Jetty under Eclipse Juno

冷暖自知 提交于 2019-12-10 19:06:27

问题


I've spent a few days understanding this problem, but I have not come up with a solution. The following are posts that are having similar problems: Similar Post 1, Similar Post 2, Similar Post 3. I have tried some of the partial solutions there, but nothing has resolved the problem.

Problem

I'm developing a Google Web Application and using Hibernate for the persistence layer to connect to a Postgresql database. I run it in development mode with the built-in Jetty server that comes with the GWT Eclipse plugin. I have received some help from this post in configuring the Jetty server.

I have used the Hibernate Tools to reverse engineer and export the following:

  • Domain Code (.java)
  • Hibernate XML Mappings (.hbm.xml)
  • DAO code (.java)
  • Hibernate XML Configuration

These have all been exported to the src folder, and I've verified using the Hibernate Tool that the configurations are at least able to pull schema information.

Now the problem comes after the Jetty server starts running. As soon as you visit the site associated with the application, it reports the following errors in Eclipse's debug console:

    com.site.application.<reverse engineered DAO> getSessionFactory
    SEVERE: Could not locate SessionFactory in JNDI
    javax.naming.NameNotFoundException; remaining name 'SessionFactory'
        at org.mortbay.naming.NamingContext.lookup(NamingContext.java:578)
        at org.mortbay.naming.NamingContext.lookup(NamingContext.java:680)
        at org.mortbay.naming.local.localContextRoot.lookup(localContextRoot.java:164)
        at javax.naming.InitialContext.lookup(InitialContext.java:411)
        at com.site.application.<reverse engineered DAO>.getSessionFactory(<reverse engineered DAO>.java:31)

Ending with:

    [ERROR] 500 - POST <application path> (127.0.0.1) xxxx bytes

Please let me know if you need any more details. I did not want to inundate the page with debug information.

Environment

  • Ubuntu 12.04 LTS
  • Eclipse Juno 4.2 Build id: 20120614-1722
  • GWT SDK 2.4.0
  • Hibernate 4.0
  • Postgresql 9.1

来源:https://stackoverflow.com/questions/12926398/could-not-locate-sessionfactory-in-jndi-with-hibernate-in-jetty-under-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!