小编gas*_*ldi的帖子

Tomcat 7中的org.apache.catalina.ServerFactory.getServer()等价物

org.apache.catalina.ServerFactory.getServer()Tomcat 7中的等价物或者检索org.apache.catalina.Session实例的最佳方法是什么?

以下是用于处理Tomcat 6.0的示例代码:

public List<org.apache.catalina.Session> findActiveSessions() throws ServiceException {
    StandardEngine engine = (StandardEngine) ServerFactory.getServer().findService("Catalina").getContainer();
    StandardContext  context = (StandardContext) engine.findChild(engine.getDefaultHost())
        .findChild(ServletActionContext.getServletContext().getContextPath()); 
    List<org.apache.catalina.Session> list = new ArrayList<org.apache.catalina.Session>();
    for (org.apache.catalina.Session session : context.getManager().findSessions()) {
        list.add(session);
    }
    return list;
}
Run Code Online (Sandbox Code Playgroud)

tomcat7

18
推荐指数
1
解决办法
8014
查看次数

Spring:为什么Hibernate 4中的SessionFactoryUtils类不提供getSession方法?

Spring 3.1.0中Hibernate 4的SessionFactoryUtils.getSession方法发生了什么变化?应该用什么呢?sessionFactory.getCurrentSession()不断给我这个异常:

org.hibernate.HibernateException: No Session found for current thread
at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:97)
at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:883)
Run Code Online (Sandbox Code Playgroud)

任何提示?

spring hibernate-4.x

8
推荐指数
2
解决办法
8944
查看次数

标签 统计

hibernate-4.x ×1

spring ×1

tomcat7 ×1