繼續解決問題this situation,我已更新hibernate
ond sqljdbc4
jars
現在異常情況已改變(請看下圖)。tomcat restart =>無法找到SessionFactory [uuid = ...,name = null]
我使用
- 休眠v4.1.4 FINAL
- JSF 2.1(鑽嘴魚科)
- 我所有的
@ManagedBeans
implements Serializable
它有一些關係@ViewScoped
,因爲@SessionScoped
豆是好的
我已經試過什麼:
使
<Manager pathname=""/> in context.xml
,是的,異常消失了,但我真的失去了持續性的會議,所以我必須Tomcat服務器重新啓動後,重新登錄。使hiberanate.cfg.xml文件的更改(例如添加
name="java:hibernate/SessionFactory"
到<session-factory>
標籤),但沒有成功把玩
SESSIONS.ser
文件,該文件後STOP Tomcat服務器創建的。- 當我打開SER文件,我可以發現有這樣的:....
uuidq ~ xppt $e8906373-f31b-4990-833c-c7680b2a77ce
... - 如果我再次啓動 Tomcat服務器,它報告
Could not find a SessionFactory [uuid=8906373-f31b-4990-833c-c7680b2a77ce,name=null]
- 爲什麼???該會話似乎存在於SESSION.ser
文件中...
- 當我打開SER文件,我可以發現有這樣的:....
我會話管理器:
我hibernate.cfg.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:sqlserver://localhost;databaseName=RXP</property>
<property name="connection.username">user</property>
<property name="connection.password">password</property>
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="dialect">org.hibernate.dialect.SQLServer2008Dialect</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping class="tables.User"/>
</session-factory>
</hibernate-configuration>
和我會話工廠:
public final class DaoSF implements Serializable {
private static final long serialVersionUID = 1L;
private static SessionFactory sessionFactory;
private static ServiceRegistry serviceRegistry;
public static SessionFactory getSessionFactory() {
try {
Configuration configuration = new Configuration();
configuration.configure("hibernate.cfg.xml");
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
}
catch (HibernateException he) {
...
}
}
}
例外:
30.6.2012 13:29:07 org.apache.catalina.session.StandardManager doLoad
SEVERE: IOException while loading persisted sessions: java.io.InvalidObjectException: Could not find a SessionFactory [uuid=f9c33312-cf7f-4f65-ae5f-44261705c18e,name=null]
java.io.InvalidObjectException: Could not find a SessionFactory [uuid=f9c33312-cf7f-4f65-ae5f-44261705c18e,name=null]
at org.hibernate.internal.SessionFactoryImpl.locateSessionFactoryOnDeserialization(SessionFactoryImpl.java:2007)
at org.hibernate.internal.SessionFactoryImpl.deserialize(SessionFactoryImpl.java:2037)
....
我試圖編輯我hibernate.cfg.xml
文件是這樣的:
<session-factory name="java:hibernate/SessionFactory">
和錯誤reportd已更改爲:
30.6.2012 13:38:23 org.apache.catalina.session.StandardManager startInternal
SEVERE: Exception loading sessions from persistent storage
java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.get(Unknown Source)
at org.hibernate.internal.SessionFactoryRegistry.getSessionFactory(SessionFactoryRegistry.java:140)
at org.hibernate.internal.SessionFactoryRegistry.getNamedSessionFactory(SessionFactoryRegistry.java:135)
at org.hibernate.internal.SessionFactoryImpl.locateSessionFactoryOnDeserialization(SessionFactoryImpl.java:2000)
at org.hibernate.internal.SessionFactoryImpl.deserialize(SessionFactoryImpl.java:2037)
....
你有沒有遇到過這個錯誤報告?
你指定Hibernate的會話視圖/會話的財產範圍內管理豆?這是非常奇怪的設計,但這種例外情況表明如此。 – BalusC
BalusC,你可以看看我更新的問題,主要是關於SER文件的一部分?這似乎是確定的,但它不是:( – gaffcz
@gaffcz:你不想會話,會話工廠或DaoSF的情況下被序列化它們是短暫的,不能從一個文件中恢復你最好弄清楚在何處以及爲什麼他們被序列化到一個文件中,這就是你需要修復的地方 – Codo