i am newer in webapp application. i am using framework hibernate + spring + spring security + Jsf (facelets). i have this error since 2 days when i try to execute the webapp application.
---------------------------------------------------------------
INFO: Initializing Spring root WebApplicationContext
nov. 19, 2012 6:25:45 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactService' defined in ServletContext resource [/WEB-INF/ApplicationContext-Dao.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [db.contacts.service.contactServiceImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: db.contacts.service.contactServiceImpl.<init>()
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [db.contacts.service.contactServiceImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: db.contacts.service.contactServiceImpl.<init>()
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877)
... 26 more
Caused by: java.lang.NoSuchMethodException: db.contacts.service.contactServiceImpl.<init>()
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:54)
... 27 more
First. Please post any config or code using the CODE tags so we can read it. If you don't use those tags (you can click on the Code button to add them) then all the indentation goes away, therefore unreadable.
But the exception states specifically your problem
"Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [db.contacts.service.contactServiceImpl]: No default constructor found; "
You are trying to tell Spring to instantiate that class via a no-args constructor, in which the class doesn't have a no-args constructor. Which means it has at least one constructor that takes a parameter or more, and you need to put that in your bean tags with <constructor-arg value|ref="">
value|ref means value or ref attribute set to a value or referencing another bean to inject into the constructor arg.
hi mark,
thanks for your response,
here is the file which generate error (applicationContext-Dao):
----------------------------------------------------
<?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">
<!-- Application context DAO layer -->
<!-- General -->
<bean id="abstractHibernateDAO" class="org.springframework.orm.hibernate3.support.HibernateDaoSupport" abstract="true">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="contactService" class="db.contacts.service.contactServiceImpl" parent="abstractHibernateDAO">
</bean>
<bean id="contratService" class="db.contacts.service.contratServiceImpl" parent="abstractHibernateDAO">
</bean>
</beans>
--------------------------------------------------------------------------------
when i try to add tag <constructor-arg value|ref =""/> like this:
But you just copied and pasted what was in the post, which already had lost all its nice pretty indentation.
I don't mean to be mean about this. But having clean easy to read code with indentation is a sign of pride in your code, makes it easier to maintain (which is 80% of your costs) and is one sign of a good developer versus someone who isn't.