I am trying to create a spring + hibernate application. I am getting exceptions when I run the application on the Tomcat server. Show root-context.xml: servlet-context.xml: <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd 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.xsd"> <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure --> <!-- Enables the Spring MVC @Controller programming model --> <annotation-driven /> <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory --> <resources mapping="/resources/**" location="/resources/" /> <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory --> <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <beans:property name="prefix" value="/WEB-INF/views/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> <context:component-scan base-package="com.gestEtu.project" /> </beans:beans>CompteController.java: competeService: package com.gestEtu.project.model.service; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.stereotype.Service; import com.gestEtu.project.model.bo.Compte; import com.gestEtu.project.model.bo.Utilisateur; import com.gestEtu.project.model.dao.CompteDAOHib; @Service @Transactional(readOnly = true) public class CompteServiceImp implements CompteService { private CompteDAOHib compteDAO; @Autowired public void setCompteDAO(CompteDAOHib compteDAO) { this.compteDAO = compteDAO; } @Override public void ajouterCompte(Compte compte) { compteDAO.ajouterCompte(compte); } @Override public List<Compte> getComptes() { return compteDAO.getComptes(); } @Override public Compte findCompteByLogin(String login) { return compteDAO.findCompteByLogin(login); } @Override public void ajouterUtilisateur(Compte compte, Utilisateur utilisateur) { this.ajouterCompte(compte); } @Override public Utilisateur getUtilisateurById(int id) { return null; } @Override public List<Utilisateur> getUtilisateurs() { return null; } }CompteDAOHib: CompteService Code: package com.gestEtu.project.model.service; import java.util.List; import com.gestEtu.project.model.bo.Compte; import com.gestEtu.project.model.bo.Utilisateur; public interface CompteService { public void ajouterCompte(Compte compte); public List<Compte> getComptes(); public Compte findCompteByLogin(String login); public List<Utilisateur> getUtilisateurs(); public Utilisateur getUtilisateurById(int id); public void ajouterUtilisateur(Compte compte, Utilisateur utilisateur); }Can anybody help to resolve this? What is org Springframework beans factory BeanCreationException?Cause: org.springframework.beans.factory.CannotLoadBeanClassException. Spring throws this exception when it can't load the class of the defined bean. This may occur if the Spring XML Configuration contains a bean that simply doesn't have a corresponding class.
How do you fix bean instantiation through factory method failure?Solution 1
It is necessary to create a new class that extends the abstract class. If the bean factory is attempting to get the bean by using the abstract class name, it can find and associate the implemented class. The exception would then be resolved.
What is error creating bean with name?BeanCreationException: Error creating bean with name happens when a problem occurs when the BeanFactory creates a bean. If the BeanFactory encounters an error when creating a bean from either bean definition or auto-configuration, the BeanCreationException will be thrown.
Can not create bean Spring?There could be numerous reasons why Spring could not able to create a bean with name X, but clue always lies on the detailed stack trace. This error always has some underlying cause e.g. a ClassNotFoundException or a NoClassDefFoundError, which potentially signal a missing JAR file in the classpath.
|