无法实例化bean类[org.hibernate.cfg.AnnotationConfiguration]:

时间:2013-02-11 14:19:46

标签: java tomcat servlets

我在eclipse中使用servlet创建了一个简单的动态项目,并试图使hibernate与它一起工作

           protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    out.println("Hello World");
    getIntravues();
}

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
}

private ArrayList<String> getIntravues() {
    // this method will use hibernate to get the names of intravues and their ip addresses
    ArrayList<String> list = new ArrayList<String>();

    Intravue intravue = new Intravue();
    intravue.setIvid(11);
    intravue.setName("hibernate tes");
    ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
    QueriesClass queriesClass = (QueriesClass) ctx.getBean("TestThree");
    queriesClass.saveInterVue(intravue);
}

我的ApplicationContext.xml类

                 <?xml version="1.0" encoding="UTF-8"?>

    <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
default-lazy-init="true">

<!-- Datasource for LOCAL database connection -->

<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost:3306/dashboardsupervisor" />
    <property name="username" value="root" />
    <property name="password" value="0502" />
</bean>


<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="annotatedClasses">
        <list>

            <value>svr.Intravue</value>

        </list>
    </property>
</bean>
<bean id="TestThree" class="svr.QueriesClass">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

我的构建路径

enter image description here

我的Tomcat构建路径

enter image description here

错误是:

               nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.hibernate.cfg.AnnotationConfiguration]: Constructor threw exception; nested exception is java.lang.ExceptionInInitializerError

0 个答案:

没有答案