0
데이터베이스에서 데이터를 검색하고 데이터 테이블의 JSF 뷰로 가져 오려고하지만 해결할 수없는 문제가 있습니다. Exception
입니다. 나는 lib 폴더에 필요한 항아리를 복사하여 여기 목록입니다 :JSF 뷰가 데이터베이스의 데이터를 복구하지 못합니다.
- JSF-api.jar을
- JSF-impl.jar
- JSTL-API-1.2.jar
- JSTL-IMPL -1.2.jar 여기
는 JSF 뷰의 코드는 다음과 같습니다 listFournisseur.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<head>
<link rel="stylesheet" type="text/css" href="../css/styles.css"/>
</head>
<h:body>
<h:form>
<h:dataTable var="fournisseur" value="#{fournisseurBean.listFournisseurs}" border="1">
<h:column>
<f:facet name="header">
<h:outputLabel value="nom" />
</f:facet>
#{fournisseur.nomfour}
</h:column>
<h:column>
<f:facet name="header">
<h:outputLabel value="raison sociale" />
</f:facet>
#{fournisseur.raisonsfour}
</h:column>
<h:column>
<f:facet name="header">
<h:outputLabel value="Adresse" />
</f:facet>
#{fournisseur.adressef}
</h:column>
</h:dataTable>
</h:form>
</h:body>
</html>
,451,515,
다음은 ManagedBean은의 코드입니다 :
package com.fst.bibliotheque.beans;
import java.util.List;
import com.fst.bibliotheque.dao.FournisseurHome;
import com.fst.bibliotheque.persistance.Fournisseur;
import com.fst.bibliotheque.services.FournisseurService;
public class FournisseurBean {
private FournisseurService gestionFournisseur;
private List<Fournisseur> listFournisseurs;
private int tailleListe;
public List<Fournisseur> getListFournisseurs() {
if(gestionFournisseur==null)
gestionFournisseur=new FournisseurService();
listFournisseurs=gestionFournisseur.findAllList();
tailleListe=listFournisseurs.size();
return listFournisseurs;
}
public void setListFournisseurs(List<Fournisseur> listFournisseurs) {
this.listFournisseurs = listFournisseurs;
}
}
FournisseurBean.java
마지막으로 여기에 레이어의 서비스에 관련된 코드 : 데이터를 검색하기위한 메도의 responsable에 위치하고 있습니다 FournisseurServices.java가. Fournisseurdao.java :package com.fst.bibliotheque.services;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.fst.bibliotheque.dao.FournisseurHome;
import com.fst.bibliotheque.dao.HibernateUtil;
public class FournisseurService {
private FournisseurHome dao;
public FournisseurService() { dao = new FournisseurHome() ; }
public List findAllList() {
Session session=HibernateUtil.getSessionFactory().getCurrentSession();
Transaction tx= null ;
List l=null;
try{
tx=session.beginTransaction();
l=dao.findAll();
tx.commit() ;
}catch(RuntimeException ex){
if(tx!= null) tx.rollback();
ex.printStackTrace() ; }
return l;
}
}
함수 findAllList()는 DAO의 층에 위치한 findall은() 함수를 호출
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/BibliothequeJSFHib1] threw exception [org/hibernate/Session] with root cause
java.lang.ClassNotFoundException: org.hibernate.Session
:
package com.fst.bibliotheque.dao;
// Generated Dec 7, 2013 2:15:19 AM by Hibernate Tools 3.4.0.CR1
import java.util.List;
import javax.naming.InitialContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Criteria;
import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
import com.fst.bibliotheque.persistance.Fournisseur;
import static org.hibernate.criterion.Example.create;
/**
* Home object for domain model class Fournisseur.
* @see com.fst.bibliotheque.dao.Fournisseur
* @author Hibernate Tools
*/
public class FournisseurHome {
private static final Log log = LogFactory.getLog(FournisseurHome.class);
private final SessionFactory sessionFactory = getSessionFactory();
protected SessionFactory getSessionFactory() {
try {
return HibernateUtil.getSessionFactory();
} catch (Exception e) {
log.error("Could not locate SessionFactory in JNDI", e);
throw new IllegalStateException(
"Could not locate SessionFactory in JNDI");
}
}
public List findAll() {
Criteria crit =sessionFactory.getCurrentSession().createCriteria(Fournisseur.class);
return crit.list();
}
public List findAll (Order defaultOrder) {
Criteria crit = sessionFactory.getCurrentSession().createCriteria(Fournisseur.class);
if (null != defaultOrder) crit.addOrder(defaultOrder);
return crit.list();
}
}
실행 후를,이 예외를 가지고
누구든지 문제를 해결하는 방법을 알고 있습니까?
사실 나는 최대 절전 모드 jar ...를 추가 한 라이브러리를 만들었습니다.이 라이브러리를 제거하고 jar 파일을 lib 디렉토리에 복사했고 문제는 해결되었습니다. :) thx alot. – user3179505