?
Solved

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

Posted on 2007-03-25
3
Medium Priority
?
438 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 450 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 600 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 450 total points
ID: 18790995
check your log, I'd say something is failing during startup.
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month12 days, 16 hours left to enroll

777 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