M
M
MrD2013-09-01 14:13:25
Java
MrD, 2013-09-01 14:13:25

Creating a Spring project with HIbernate connection?

I'm trying to do a project on the article . An error occurred while deploying to the server, namely:

13:55:23,225 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-5) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/spring/data.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/data.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException:
class path resource [hibernate.cfg.xml] cannot be resolved to URL because it does not exist

<bean id="sessionFactory"<br>
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><br>
    <property name="dataSource" ref="dataSource" /><br>
    <property name="configLocation"><br>
      <value>classpath:hibernate.cfg.xml</value><br>
    </property><br>


The hibernate.cfg.xml file is in /src/main/resources/hibernate.cfg.xml.

Tried googling. One of the suggestions to move this file does not work. Since then he does not see my essence. I also tried to change the line so that the file was visible. Did not help Although you can offer your options on this matter. In general, what are the solutions to this problem. Maybe I missed the answer to this problem somewhere.

<value>classpath:hibernate.cfg.xml</value><br>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
J
javax, 2013-09-01
@javax

Check inside the WAR - maybe the file really isn't there? Maybe they made a mistake with the path, or with the name

M
MrD, 2013-09-01
@MrD

Yes, indeed, hibernate.cfg.xml, as well as classes, did not get into the WAR file. Maybe I'm not reassembling correctly. Or is there something else that needs to be described?
I launch the JBoss server in Eclipse, then right on the project - Export - WAR file and already choose where to send it (deployments JBoss directory).
Before that, I didn’t use Spring, I wrote everything with my hands, everything was a little different there. Entities and beans were collected in a jar, servlets and the entire web in a war file, and then everything in ear and already on the server.

M
MrD, 2013-09-02
@MrD

Thank you, now I'm just figuring out how to do it all. Seems like it should be done

right-click on your project then Maven > Update Project

But in jBoss, a directory with classes is simply created. jsp pages are not included.
The type costs war.
I'm looking for how to do all this correctly from Eclipse. I am using Maven as a plugin.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question