aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Listener class not mapping Hibernate xmls Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Listener class not mapping Hibernate xmls" Watch "Listener class not mapping Hibernate xmls" New topic
Author

Listener class not mapping Hibernate xmls

Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 103
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.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18135
    
    8

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

Joined: Jun 21, 2010
Posts: 103
Paul, I tried your change, and it didn't work. Here is the structure that I found Eclipse deployed to.

Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

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

Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 103
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
Bartender

Joined: Oct 14, 2005
Posts: 18135
    
    8

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

Joined: Jun 21, 2010
Posts: 103
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

Joined: Jun 21, 2010
Posts: 103
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

Joined: Jun 21, 2010
Posts: 103
Okay, let's try this question. What is the correct deployment process?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18135
    
    8

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

Joined: Jun 21, 2010
Posts: 103
If it helps, I am using Eclipse Galileo.
Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 103
Forget it, everyone. I'll just figure it out myself.
Frank Serkland
Ranch Hand

Joined: Jun 21, 2010
Posts: 103
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Listener class not mapping Hibernate xmls
 
Similar Threads
Value not being sent to DAO class from Struts form in JSP
Hibernate query not mapped
Session problem in custom tag
Cookie not being sent back to browser
Struts action not returning page on first click of button