wood burning stoves*
The moose likes Spring and the fly likes SEVERE: Error listenerStart Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "SEVERE: Error listenerStart" Watch "SEVERE: Error listenerStart" New topic
Author

SEVERE: Error listenerStart

Tsague ezequiel
Greenhorn

Joined: Nov 21, 2012
Posts: 9
hi,

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

nov. 19, 2012 6:25:45 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
nov. 19, 2012 6:25:45 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Erreur de démarrage du contexte [/contacts] suite aux erreurs précédentes
nov. 19, 2012 6:25:45 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
nov. 19, 2012 6:25:45 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8680"]
nov. 19, 2012 6:25:45 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8609"]
nov. 19, 2012 6:25:45 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 5812 ms
-----------------------------------------------------------------
web.xml file
-----------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>jsfexemple</display-name>
<welcome-file-list>
<welcome-file>login.xhtml</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<!-- Faces Servlet -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/ApplicationContext*.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value> /WEB-INF/faces-config.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>com.sun.facelets.FaceletViewHandler</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<listener>
<listener-class> org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>

<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>

<!-- sécurité de l'application -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
</web-app>
-------------------------------------------------------------------------
applicationContext-DAO file
------------------------------------------------------------------------
<?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>
-----------------------------------------------------------------------
applicationContext.xml file
----------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!-- DATASOURCE DEFINITON-->
<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.5.xsd">
<!-- HIBERNATE CONFIGURATION -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>db.contacts.service.contactServiceImpl</value>
<value>db.contacts.service.contratServiceImpl</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop
key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.use_outer_join">true</prop>
<prop key="hibernate.max_fetch_depth">1</prop>
<prop key="hibernate.jdbc.batch_size">0</prop>
<prop
key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
</props>
</property>
</bean>
</beans>
----------------------------------------------------------------------
applicationContext-security.xml file
-----------------------------------------------------------------------
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
<security:authentication-provider>
<security:user-service>
<security:user name="user" password="password" authorities="ROLE_USER"
/>
</security:user-service>
</security:authentication-provider>
<security:http>
<security:intercept-url pattern="/login.jsf" filters="none" />
<security:intercept-url pattern="/loginFailure.jsf" filters="none" />
<security:intercept-url pattern="/**" access="ROLE_USER"/>
<security:form-login
login-page="/login.jsf"
authentication-failure-url="/loginFailure.jsf" />
<security:anonymous />
<security:logout logout-success-url="/logout.jsf" logout-url="/logout"
/>
</security:http>
</beans>
-----------------------------------------------------------------------

thanks to help to solve this problem
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Tsague ezequiel
Greenhorn

Joined: Nov 21, 2012
Posts: 9
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:

<bean id="abstractHibernateDAO" class="org.springframework.orm.hibernate3.support.HibernateDaoSupport" abstract="true">
<constructor-arg>value="sessionFactory"</constructor-arg>
<!-- <property name="sessionFactory" ref="sessionFactory" /> -->
</bean>

i got this error:

cvc-complex-type.2.3: Element 'constructor-arg' cannot have character [children], because the type's content type is element-only.

please show how i can use the tag <constructor-arg>
Tsague ezequiel
Greenhorn

Joined: Nov 21, 2012
Posts: 9
hi,
-----------------------------------------------------------------------------------------------------------------------
my bean ContactCtr.java
-----------------------------------------------------------------------------------------------------------------------
package com.oxia.formation.ctr;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import org.springframework.dao.DataIntegrityViolationException;
import com.oxia.formation.Contacts;
import com.oxia.formation.Contrats;
import com.oxia.formation.dao.ContactsDao;
import com.oxia.formation.dao.ContratsDao;
public class ContactCtr implements Serializable {
private static final long serialVersionUID = 1L;
private ContratsDao contratsDao;
private ContactsDao contactsDao;
private DataModel features;
private Contacts selectedContact = new Contacts();
private Contacts contact;
private List<Contacts> contacts;
private List<Contrats> listeContrats;
private boolean creation;
@PostConstruct
public void init() {
contacts = contactsDao.getContacts();
features = new ListDataModel(contacts);
}
public DataModel getFeatures() {
contacts = contactsDao.getContacts();
features = new ListDataModel(contacts);
return features;
}
public List<Contacts> getContacts() {
contacts = contactsDao.getContacts();
features = new ListDataModel(contacts);
return contacts;
}
public String editContact() {
setSelectedContact(contacts.get(features.getRowIndex()));
setCreation(false);
return "success";
}
public String create() {
selectedContact = new Contacts();
setCreation(true);
return "success";
}
public String saveContact() {
contact = new Contacts();
contact.setCin(selectedContact.getCin());
contact.setFirstName(selectedContact.getFirstName());
contact.setLastName(selectedContact.getLastName());
contact.setEmail(selectedContact.getEmail());
try {
contactsDao.create(selectedContact);
} catch (DataIntegrityViolationException e) {
FacesContext.getCurrentInstance().addMessage(
"Exist",
new FacesMessage("L'identifiant saisi existe déjà dans la base"));
return "echec";
}
return "success";
}
public String updateContact() {
setCreation(false);
contactsDao.update(selectedContact);
return "success";
}
public String deleteContact() {
setCreation(false);
contactsDao.delete(contacts.get(features.getRowIndex()));
return "success";
}
public String getContactById() {
setCreation(false);
setSelectedContact(contactsDao.findById(selectedContact.getCin()));
listeContrats = contratsDao.findContratsByContact(selectedContact.getCin());
return "success";
}
public ContactsDao getContactDao() {
return contactsDao;
}
public void setContactsDao(ContactsDao contactsDao) {
this.contactsDao = contactsDao;
}
public Contacts getSelectedContact() {
return selectedContact;
}
public void setSelectedContact(Contacts selectedContact) {
this.selectedContact = selectedContact;
}
public boolean isCreation() {
return creation;
}
public void setCreation(boolean creation) {
this.creation = creation;
}
public ContratsDao getContratsDao() {
return contratsDao;
}
public void setContratsDao(ContratsDao contratsDao) {
this.contratsDao = contratsDao;
}
public List<Contrats> getListeContrats() {
return listeContrats;
}
public void setListeContrats(List<Contrats> listeContrats) {
this.listeContrats = listeContrats;
}
}

nobody to help me please ???
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

OK. my third request. USE CODE TAGS. No one will read your code or config without them.

Mark
Tsague ezequiel
Greenhorn

Joined: Nov 21, 2012
Posts: 9
thanks,
i use the code tag:
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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.

Thanks

Mark
Tsague ezequiel
Greenhorn

Joined: Nov 21, 2012
Posts: 9
all rights.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SEVERE: Error listenerStart
 
Similar Threads
No mapping found for HTTP request with URI - Why won't my page load?
Spring MVC - Url Handling Problem
first app
Problem finding index page under WEB-INF / Spring MVC
JSF 1.2 + Authentication with Spring Security 3.0.5