继续解决这个情况 https://stackoverflow.com/questions/6506476/java-lang-illegalstateexception-unread-block-data,我已经更新了hibernate
ond sqljdbc4
jars
现在例外情况已更改(请看下面)。
我在用着
- Hibernate v4.1.4 最终版
- JSF 2.1(莫哈拉)
- all my
@ManagedBeans
implements Serializable
和有一定的关系@ViewScoped
, 因为@SessionScoped
豆子还可以
我尝试过的:
enable <Manager pathname=""/> in context.xml
,是的,异常消失了,但是我确实丢失了持久会话,所以我必须在tomcat服务器重新启动后重新登录。
在 hibernate.cfg.xml 文件中进行更改(例如添加name="java:hibernate/SessionFactory"
to <session-factory>
标签),但没有成功
-
玩SESSIONS.ser
文件,该文件是在之后创建的STOPtomcat服务器。
- When I openser 文件,我可以找到类似的内容: ....
uuidq ~ xppt $e8906373-f31b-4990-833c-c7680b2a77ce
...
- if i START再次启动tomcat服务器,它报告
Could not find a SessionFactory [uuid=8906373-f31b-4990-833c-c7680b2a77ce,name=null]
- WHY???该会议似乎存在于SESSION.ser
file...
My 会话管理器:
@SessionScoped
@ManagedBean(name="userManager")
public class UserManager implements Serializable {
private static final long serialVersionUID = 1L;
private transient HttpSession session;
private String username;
private String password;
private User user;
public String login() {
// here is seraching for user in database (based on username and password)
if (user != null) {
FacesContext context = FacesContext.getCurrentInstance();
session = (HttpSession) context.getExternalContext().getSession(true);
session.setAttribute("id", user.getId());
session.setAttribute("username", user.getName());
...
return "success";
}
}
public String logout() {
user = null;
FacesContext context = FacesContext.getCurrentInstance();
session = (HttpSession) context.getExternalContext().getSession(true);
...
session.invalidate();
return "success";
}
// getters and setters ----------------------------------------------------
}
my 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>
and my 会话工厂:
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">
并且报告的错误已更改为:
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)
....
您没有遇到过此错误报告吗?