我得到一個nullPointerException
進行部署時,當返回null我Maven Web Application JSF-2.2 +Hibernate
:的getCurrentSession創建會話
ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host]
.[/maven-project].[FacesServlet]] (http-localhost/127.0.0.1:8080-1)
JBWEB000236: Servlet.service() for servlet FacesServlet threw exception:
java.lang.NullPointerException
at com.ubosque.mb.CiudadanoMB.getAllCiudadanos(CiudadanoMB.java:28)
[classes:]
當我看看com.ubosque.mb.CiudadanoMB.getAllCiudadanos(CiudadanoMB.java:28)
這件事是排隊:
sesion = HibernateSessionFactory.getSessionFactory().getCurrentSession();
HibernateSessionFactory類:
private static SessionFactory sessionFactory = setSessionFactory();
private static SessionFactory setSessionFactory() {
try {
if (sessionFactory == null) { // if session == null
Configuration config = new Configuration().configure();
StandardServiceRegistryBuilder regbuild = new StandardServiceRegistryBuilder();
StandardServiceRegistry builder = regbuild.applySettings(config.getProperties()).build();
sessionFactory = config.buildSessionFactory(builder);
}// if session == null
} catch (Exception e) {
e.printStackTrace();
}// try - catch
return sessionFactory;
}// setSessionFactory
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
似乎無法找到我的問題所在,我只是在瞭解Hibernate
。提前Thanx。