-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: BeanCreationException: Error creating bean with name...
PostPosted: Thu Mar 12, 2009 11:16 am 
Newbie

Joined: Wed Mar 11, 2009 8:31 am
Posts: 5
Hello, all!

problem:
+-------------------------------------------------------------------------------------------------------------+
%tomcat_home%\logs\localhost.log:
+-------------------------------------------------------------------------------------------------------------+
...
SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/hello.htm' defined in ServletContext resource [/WEB-INF/springapp-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'factoryManager' of bean class [springapp.web.FactoryController]: No property 'factoryManager' found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
...
+-------------------------------------------------------------------------------------------------------------+
%tomcat_home%\logs\stdout.log:
+-------------------------------------------------------------------------------------------------------------+
...
16:28:12,750 DEBUG DefaultListableBeanFactory:213 - Creating shared instance of singleton bean 'factoryManager'
16:28:12,750 DEBUG DefaultListableBeanFactory:383 - Creating instance of bean 'factoryManager'
16:28:12,750 DEBUG DefaultListableBeanFactory:459 - Eagerly caching bean 'factoryManager' to allow for resolving potential circular references
16:28:12,750 DEBUG DefaultListableBeanFactory:411 - Finished creating instance of bean 'factoryManager'
16:28:12,750 DEBUG DefaultListableBeanFactory:213 - Creating shared instance of singleton bean '/hello.htm'
16:28:12,750 DEBUG DefaultListableBeanFactory:383 - Creating instance of bean '/hello.htm'
16:28:12,750 DEBUG DefaultListableBeanFactory:459 - Eagerly caching bean '/hello.htm' to allow for resolving potential circular references
16:28:12,750 DEBUG DefaultListableBeanFactory:214 - Returning cached instance of singleton bean 'factoryManager'
16:28:12,750 INFO DefaultListableBeanFactory:399 - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@13936e1: defining beans [messageSource,factoryManager,/hello.htm,viewResolver]; root of factory hierarchy
16:28:12,750 ERROR DispatcherServlet:290 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/hello.htm' defined in ServletContext resource [/WEB-INF/springapp-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'factoryManager' of bean class [springapp.web.FactoryController]: No property 'factoryManager' found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
...
+-------------------------------------------------------------------------------------------------------------+

my settings:
+-------------------------------------------------------------------------------------------------------------+
WEB-INF\web.xml:
+-------------------------------------------------------------------------------------------------------------+
<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >

<servlet>
<servlet-name>springapp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>springapp</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>

<jsp-config>
<taglib>
<taglib-uri>/spring</taglib-uri>
<taglib-location>/WEB-INF/tld/spring-form.tld</taglib-location>
</taglib>
</jsp-config>

</web-app>
+-------------------------------------------------------------------------------------------------------------+
WEB-INF\springapp-servlet.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/b ... ns-2.5.xsd">

<!-- the application context definition for the springapp DispatcherServlet -->

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages"/>
</bean>

<bean id="factoryManager" class="springapp.service.FactoryManagerImpl">
</bean>

<!-- /index.htm(in root directory) is redirect to /hello.htm -->
<bean name="/hello.htm" class="springapp.web.FactoryController">
<property name="factoryManager" ref="factoryManager"/>
</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>

</beans>
+-------------------------------------------------------------------------------------------------------------+
WEB-INF\classes\hibernate.cfg.xml:
+-------------------------------------------------------------------------------------------------------------+
<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>

<property name="connection.url">jdbc:mysql://localhost/autopark</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">root</property>
<property name="connection.password">njkz1985</property>
<property name="connection.pool_size">1</property>
<property name="current_session_context_class">thread</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

<mapping resource="springapp/domain/Bus.hbm.xml"/>
<mapping resource="springapp/domain/Driver.hbm.xml"/>
<mapping resource="springapp/domain/Route.hbm.xml"/>

</session-factory>
</hibernate-configuration>
+-------------------------------------------------------------------------------------------------------------+
WEB-INF\classes\springapp\web\FactoryController.class:
+-------------------------------------------------------------------------------------------------------------+
package springapp.web;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import springapp.domain.Bus;
import springapp.service.FactoryManagerImpl;

public class FactoryController implements Controller {

protected final Log logger = LogFactory.getLog(getClass());

private FactoryManagerImpl factoryManager;

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

logger.info("FactoryController: handleRequest");
String now = (new java.util.Date()).toString();
List<Bus> busses = new ArrayList<Bus>();
try {
busses = factoryManager.getBusDAO().getAllBusses();
} catch (SQLException e) {
logger.info(e.toString());
}

Map<String, Object> myModel = new HashMap<String, Object>();
myModel.put("now", now);
myModel.put("busses", busses);

return new ModelAndView("model", myModel);
}

public void setProductManager(FactoryManagerImpl factoryManager) {
this.factoryManager = factoryManager;
}
}
+-------------------------------------------------------------------------------------------------------------+
mysql> select * from autopark.busses;
+--------+---------+----------+
| bus_id | number | route_id |
+--------+---------+----------+
| 1 | k254tr | 1 |
| 2 | t436ku | 1 |
| 3 | p398tm | 2 |
| 4 | p387ts | 4 |
| 5 | o567rp | 2 |
| 6 | a576rn | 1 |
| 7 | ch265ek | 2 |
| 8 | t764dl | 5 |
| 9 | p765ra | 5 |
| 10 | g459pi | 3 |
| 11 | c255ka | 3 |
+--------+---------+----------+
11 rows in set (0.00 sec)
+-------------------------------------------------------------------------------------------------------------+
WEB-INF\classes\springapp\domain\Bus.class:
+-------------------------------------------------------------------------------------------------------------+
package springapp.domain;

import java.util.Set;
import java.util.HashSet;

public class Bus {
private Long id;
private String number;
private Set drivers = new HashSet();
private Long route_id;

public Bus() {
}

public void setId(Long id) {
this.id = id;
}

public void setNumber(String number) {
this.number = number;
}

public void setDrivers(Set drivers) {
this.drivers = drivers;
}

public void setRoute_id(Long route_id) {
this.route_id = route_id;
}

public Long getId() {
return id;
}

public String getNumber() {
return number;
}

public Set getDrivers() {
return drivers;
}

public Long getRoute_id() {
return route_id;
}
}
+-------------------------------------------------------------------------------------------------------------+
WEB-INF\classes\springapp\domain\Bus.hbm.xml:
+-------------------------------------------------------------------------------------------------------------+
<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="springapp.domain.Bus" table="busses">
<id column="bus_id" name="id" type="java.lang.Long">
<generator class="increment"/>
</id>
<property column="number" name="number" type="java.lang.String"/>

<set name="drivers" table="busDriver" lazy="false">
<key column="bus_id"/>
<many-to-many column="driver_id" class="springapp.domain.Driver"/>
</set>

</class>
</hibernate-mapping>
+-------------------------------------------------------------------------------------------------------------+
WEB-INF\classes\springapp\repository\BusDAOImpl.class:
+-------------------------------------------------------------------------------------------------------------+
package springapp.repository;

import springapp.repository.BusDAO;
import springapp.domain.Bus;
import springapp.domain.Driver;
import springapp.domain.Route;
import java.sql.SQLException;
import java.util.Collection;
import java.util.ArrayList;
import java.util.List;
import springapp.util.HibernateUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;
import org.hibernate.Query;

public class BusDAOImpl implements BusDAO {

protected final Log logger = LogFactory.getLog(getClass());
public List<Bus> getAllBusses() throws SQLException {
Session session = null;
List<Bus> busses = new ArrayList<Bus>();
try {
session = HibernateUtil.getSessionFactory().openSession();
busses = session.createCriteria(Bus.class).list();
} catch (Exception e) {
logger.info("О...ка 'getAll'");
} finally {
if (session != null && session.isOpen()) {
session.close();
}
}
return busses;
}
}
+-------------------------------------------------------------------------------------------------------------+
WEB-INF\classes\springapp\service\FactoryManagerImpl.class:
+-------------------------------------------------------------------------------------------------------------+
package springapp.service;

import springapp.repository.*;
import springapp.service.FactoryManager;

public class FactoryManagerImpl implements FactoryManager {

private static BusDAO busDAO = null;

public BusDAO getBusDAO(){
if (busDAO == null) {
busDAO = new BusDAOImpl();
}
return busDAO;
}
}
+-------------------------------------------------------------------------------------------------------------+
WEB-INF\classes\springapp\util\HibernateUtil.class:
+-------------------------------------------------------------------------------------------------------------+
package springapp.util;

import org.hibernate.cfg.Configuration;
import org.hibernate.SessionFactory;

public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}

public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
+-------------------------------------------------------------------------------------------------------------+
my project tree: http://forum.springframework.org/attachment.php?attachmentid=2019&d=1236870710
my db schema: http://forum.springframework.org/attachment.php?attachmentid=2018&d=1236870705
+-------------------------------------------------------------------------------------------------------------+

Help me please to fix this issue.

Thanks in advance!


Top
 Profile  
 
 Post subject: solve
PostPosted: Thu Mar 12, 2009 1:21 pm 
Newbie

Joined: Wed Mar 11, 2009 8:31 am
Posts: 5
i solve problem, just add setter/getter in FactoryController on factoryManager


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.