Solved

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

Posted on 2007-03-25
3
426 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Understanding websocket example in spring 1 57
Non-recursive backtracking, using a stack 1 101
Where to store the queries for modification of table 4 55
factorial example 4 34
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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 learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now