Je suis en train d'interagir veille prolongée avec le printemps dans mon projet GWT, voici mon codeImpossible instancier classe de haricots
public class MyWebServiceImpl extends RemoteServiceServlet implements
MyWebService {
public void myfirstmethod() {
// TODO Auto-generated method stub
}
public String signIn(String userid, String password) {
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"applicationContext.xml");
MySQLRdbHelper rdbHelper = (MySQLRdbHelper) ctx.getBean("ManagerJobs");
**//THIS IS THE POINT WHERE IT THROWS THE EXCEPTION**
return rdbHelper.getAuthentication(userid, password);
}
}
public class MySQLRdbHelper {
private Session session;
private SessionFactory sessionFactory;
/* FOR COUNT QUERY
* session.createCriteria(RuleSet .class)
.setProjection(Projections.projectionList()
.add(Projections.rowCount()))
.add(Subqueries.geAll("entry_id", bolgsEntries))
.list();
*/
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
public String getAuthentication(String userid, String password)
{
//Some detals like credit card are commented in the class
User users = null;
session = sessionFactory.openSession();
Criteria crit = session.createCriteria(User.class);
crit.add(Restrictions.eq("userName", userid));
crit.add(Restrictions.eq("password", password));
List rsList = crit.list();
for(Iterator it=rsList.iterator();
it.hasNext();
)
{
users = (User)it.next();
System.out.println(users.getUserName());
}
session.close();
return users.getUserName();
}
}
APPLICATIONCONTEXT.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/beans/spring-beans-2.0.xsd"
default-lazy-init="true">
<!-- Datasource for database connection -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url"
value="jdbc:mysql://localhost:3306/patients" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.Patient.shared.User</value>
</list>
</property>
</bean>
<bean id ="ManagerJobs" class= "patient.persistence.MySQLRdbHelper">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
C'EST L'EXCEPTION
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ManagerJobs' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.hibernate.cfg.AnnotationConfiguration]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
merci, j'ai ajouté slf4j-api-1.3.1.jar et slf4j-log4j12-1.5.6.jar, mais le problème est toujours là toute suggestion grâce – junaidp
@junaidp ajouter des pots de SLF4J avec le même versions. Est-ce que le même problème signifie que vous voyez le même 'java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory'? –
@junaidp aussi où mettez-vous vos pots? Je me souviens qu'en mode hébergé, je devais mettre des fichiers slf4j dans WEB-INF/lib. Ils n'ont pas été récupérés dans les cours classiques. –