Solved

ApplicationContext.xml...Can't find sessionFactory error??

Posted on 2007-03-25
3
434 Views
Last Modified: 2010-05-18
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
      <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
            <property name="url"><value>jdbc:mysql://localhost/myDB</value></property>
            <property name="username"><value>root</value></property>
            <property name="password"><value></value></property>
  </bean>  
      <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
            <property name="dataSource">
                  <ref bean="dataSource" />
            </property>
            <!-- XML Mapping files -->
            <property name="mappingResources">
                  <list>
            <value>Project.hbm.xml</value>
            <value>Employee.hbm.xml</value>
            <value>Tasks.hbm.xml</value>
               </list>
         </property>
         <property name="hibernateProperties">
          <props>
              <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
              <prop key="hibernate.show_sql">true</prop>
              <prop key="hibernate.format_sql">true</prop>
                           <prop key="hibernate.hbm2ddl.auto">create-drop</prop>
          </props>
     </property>
      </bean>            
  <bean id="employeeDao" class="EmployeeDaoImp">
        <property name="sessionFactory" ref="sessionFactory"/>
  </bean>  
=============
I am using SPring Hibernate DAO and I am not sure how does this Dependency Injection work??

In my driver,
ClassPathResource classPathResource = new ClassPathResource("applicationContext.xml");
        XmlBeanFactory beanFactory = new XmlBeanFactory(classPathResource);
           
    ==>    EmployeeDaoImp employeeDao = (EmployeeDaoImp) beanFactory.getBean("employeeDao");

I get an error from here which says the sessionFactory class not be found when it gets referenced from EmployeeDao bean.

Wha does that mean??
can you help??

       
0
Comment
Question by:dkim18
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 150 total points
ID: 18790608
You need to add it to your classpath I guess.

http://www.mindprod.com/jgloss/classpath.html
0
 
LVL 8

Accepted Solution

by:
mnrz earned 200 total points
ID: 18790768
if you are running this from Eclipse or any other IDE you should add the folder in which your applicationContext.xml exists to the classpath or in Eclipse as "class folder"
0
 
LVL 92

Assisted Solution

by:objects
objects earned 150 total points
ID: 18790995
check your log, I'd say something is failing during startup.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question