Solved

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

Posted on 2007-03-25
3
420 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:mayankeagle
mayankeagle earned 150 total points
Comment Utility
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
Comment Utility
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
Comment Utility
check your log, I'd say something is failing during startup.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
topping3 challenge 14 48
wordcount challenge 11 72
Requested array size exceeds VM limit 3 44
Java Timer (static) 9 0
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…
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…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

762 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

13 Experts available now in Live!

Get 1:1 Help Now