• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Listener class not mapping Hibernate xmls

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I feel like an idiot for asking this, so I hope you all won't hold it against me. I'm hard enough on myself. My listener class is failing because it can't find my Hibernate configuration files. I'm just about positive it's because I'm specifying the wrong location. Here is the operative part of my listener class.



Here is my error message.


Here is my file structure. I'm using Eclipse, if it makes any difference.
 
Sheriff
Posts: 28411
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, you aren't using Eclipse. You're using some servlet container. And you have to specify the paths based on where the files are in the container, not where they were in your development environment.

So there's no "src" directory in your web application when it's in the servlet container. There's a WEB-INF/classes directory and hopefully Eclipse's deploy procedure copied the files from your project's src directory to there. If that's the case then I would recommend this sort of change:
 
Frank Serkland
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul, I tried your change, and it didn't work. Here is the structure that I found Eclipse deployed to.

 
Ranch Hand
Posts: 577
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

this.configuration.addResource("/src/Comment.hbm.xml");


Resources have to be accessed from the application classpath if they are in "src" folder. Try using



Cheers,
Naren
 
Frank Serkland
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Naren Chivukula wrote:

this.configuration.addResource("/src/Comment.hbm.xml");


Resources have to be accessed from the application classpath if they are in "src" folder. Try using



Cheers,
Naren



I tried your change, Naren, and I got this error.


I then moved the xml files to the model package, without changing the code. I then got this.


Any ideas out there?
 
Paul Clapham
Sheriff
Posts: 28411
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Frank Serkland wrote:Paul, I tried your change, and it didn't work. Here is the structure that I found Eclipse deployed to.



Again, irrelevant. Forget about Eclipse for now. You're using a servlet container to run these things, right? And you're deploying your web application into it, right?

(If your answers aren't "Yes" so far then you're doing it wrong.)

Okay. So in that servlet container's directories, after you deploy the web application, you should find a directory for the web app. And under it there should be a WEB-INF directory, and under that a classes directory. If your Hibernate resources aren't in that classes directory then you didn't do the deployment correctly. And if they are, then one of the proposed code fragments should have worked.
 
Frank Serkland
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Again, irrelevant. Forget about Eclipse for now. You're using a servlet container to run these things, right? And you're deploying your web application into it, right?

(If your answers aren't "Yes" so far then you're doing it wrong.)



Well, I'm running this using Tomcat, but nothing has been copied over to Tomcat's installation. It's always just run from my project directory, so I guess I'm doing something wrong. I've got a WebContent folder with my JSPs and a WEB-INF. The WEB-INF has the web.xml, hibernate.cfg.xml, a few tlds and the lib folder. Something's crazy here, I know. Any ideas, anybody?
 
Frank Serkland
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Frank Serkland wrote:Well, I'm running this using Tomcat, but nothing has been copied over to Tomcat's installation. It's always just run from my project directory, so I guess I'm doing something wrong. I've got a WebContent folder with my JSPs and a WEB-INF. The WEB-INF has the web.xml, hibernate.cfg.xml, a few tlds and the lib folder. Something's crazy here, I know. Any ideas, anybody?



I've moved compiled classes into /WEB-INF/classes (they now reside in their respective packages under that) and the Hibernate files reside directly in /WEB-INF/classes. I am getting this message in addition to the previous message. What am I doing wrong?
 
Frank Serkland
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, let's try this question. What is the correct deployment process?
 
Paul Clapham
Sheriff
Posts: 28411
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Frank Serkland wrote:Okay, let's try this question. What is the correct deployment process?



And that question is not about Object Relational Mapping (although to be frank, neither was the original question). It's a question about Eclipse, so it would get better coverage in the forum about Eclipse. So let's zap it over there and see what people have to say...
 
Frank Serkland
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it helps, I am using Eclipse Galileo.
 
Frank Serkland
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forget it, everyone. I'll just figure it out myself.
 
Frank Serkland
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Frank Serkland wrote:Forget it, everyone. I'll just figure it out myself.



This problem was resolved when I removed the files from my listener files. They were already specified in hibernate.cfg.xml, so they didn't need to be repeated in the listener class.
reply
    Bookmark Topic Watch Topic
  • New Topic