Hello,
This was posted on the Spring forums, but we're not sure if it's a problem related
to our project setup or jboss.. so hopefully one of these two sites can help shed some
light!
We have a project using Spring 3.0.0 RC1 with Hibernate 3, running on JBoss 4.2.2.GA, and
have a small but annoying issue republishing the war. Every time we do, we receive the
following error and must restart the container. Once it has been restarted, it initializes
everything fine. We are hoping to eliminate the task of restarting the container every
time we make a change and republish.
There appears to be an issue injecting the session factory the second time around.
10:15:44,296 INFO [STDOUT] [DEBUG] 10:15:44 org.hibernate.cfg.AnnotationConfiguration -
Process hbm files
| 10:15:44,296 INFO [STDOUT] [DEBUG] 10:15:44 org.hibernate.cfg.AnnotationConfiguration
- Process annotated classes
| 10:15:44,296 INFO [STDOUT] [ INFO] 10:15:44
org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying
singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@10d2cf0: defining
beans
[org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,disDao,trPlDao,disService,trPlService,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,dataSource,sessionFactory,transactionManager];
root of factory hierarchy
| 10:15:44,312 INFO [STDOUT] [DEBUG] 10:15:44
org.springframework.beans.factory.support.DisposableBeanAdapter - Invoking destroy method
'close' on bean with name 'dataSource'
| 10:15:44,312 INFO [STDOUT] [ERROR] 10:15:44
org.springframework.web.context.ContextLoader - Context initialization failed
| org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean
with name 'disDao' defined in file
[C:\jboss\jboss-4.2.2.GA\server\default\tmp\deploy\tmp6306950577408655593PathwaysCAS-exp.war\WEB-INF\classes\main\java\com\xxxx\pcas\repository\DisDaoImpl.class]:
Unsatisfied dependency expressed through constructor argument with index 0 of type
[org.hibernate.SessionFactory]: : Error creating bean with name 'sessionFactory'
defined in ServletContext resource [/WEB-INF/pcas-data.xml]: Invocation of init method
failed; nested exception is java.lang.reflect.UndeclaredThrowableException; nested
exception is org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'sessionFactory' defined in ServletContext resource
[/WEB-INF/pcas-data.xml]: Invocation of init method failed; nested exception is
java.lang.reflect.UndeclaredThrowableException
| at
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:698)
| at
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:192)
| at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:978)
| at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:880)
| at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
| at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
| at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:289)
| at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
| at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:286)
| at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:188)
| at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:543)
| at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:730)
| at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:387)
| at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:270)
| at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
| at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
| at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
| at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
| at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
| at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
| at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
| at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
| at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at
org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
| at
org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
| at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
| at org.jboss.web.WebModule.startModule(WebModule.java:83)
| at org.jboss.web.WebModule.startService(WebModule.java:61)
| at
org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
| ...
| ...
Below is the xml configuration:
<?xml version="1.0" encoding="UTF-8"?>
| <beans
xmlns="http://www.springframework.org/schema/beans"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
|
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
http://www.springframework.org/schema/beans/spring-beans.xsd
|
http://www.springframework.org/schema/context
|
http://www.springframework.org/schema/context/spring-context-2.5.xsd
|
http://www.springframework.org/schema/tx
|
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
| default-autowire="byName">
|
| <!-- enable declarative transaction management -->
| <tx:annotation-driven/>
|
| <context:annotation-config/>
|
| <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
| <property name="location"
value="classpath:hibernate.properties" />
| </bean>
|
| <bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
| destroy-method="close">
| <property name="driverClassName"
value="${hibernate.connection.driver_class}" />
| <property name="url" value="${hibernate.connection.url}"
/>
| <property name="username"
value="${hibernate.connection.username}" />
| <property name="password"
value="${hibernate.connection.password}" />
| </bean>
|
| <bean id="sessionFactory"
|
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
| <property name="dataSource" ref="dataSource" />
| <property name="packagesToScan"
value="main.java.com.xxxx.pcas.entity" />
| <property name="hibernateProperties">
| <props>
| <prop key="hibernate.dialect">${hibernate.dialect}</prop>
| <prop key="hibernate.show_sql">true</prop>
| <prop key="hibernate.format_sql">true</prop>
| </props>
| </property>
| </bean>
|
| <bean id="transactionManager"
|
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
| <property name="sessionFactory" ref="sessionFactory" />
| </bean>
|
| </beans>
And the DisDaoImpl.java file:
@Repository("disDao")
| public class DisDaoImpl extends AbstractHibernateDao<Dis> implements DisDao {
|
| @Autowired
| public DisDaoImpl(SessionFactory sessionFactory) {
| super(Dis.class, sessionFactory);
| }
|
| public Dis findById(Short id) {
| return get(id);
| }
|
| public List<Dis> findAll() {
| return all();
| }
|
| public void save(Dis dis) {
| currentSession().saveOrUpdate(dis);
| }
|
| public void delete(Dis dis) {
| currentSession().delete(dis);
| }
|
| }
If there is any other information I can provide that might help out, just let me know.
Thanks for your time,
Beau
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4266658#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...