[Clustering] - HTTP Session passivation - How to survive server restarts?
by RichardTaylor
Note: It was suggested that I move this post to this forum from JBoss Cache Users (the original post was here: http://www.jboss.org/index.html?module=bb&op=viewtopic&t=162299 No content there)
I'd like to enable HTTP Session passivation so that all active sessions are passivated to disk during a graceful server restart. I'd like users to stay logged in through a server restart (single server). This is especially helpful in a development environment.
JBoss 5.1.0
JBoss Cache 3.2.1
I've read the following and have followed the instructions:
http://www.jboss.org/community/wiki/HttpSessionPassivationDesign
http://www.jboss.org/community/wiki/DistributableHttpSessionPassivation
Session passivation works in the sense that when my specified time limits are hit, sessions are written to disk. However when I gracefully shut down the server, all passivated sessions are deleted from disk.
In the section describing passivation being triggered by a server shutdown it says:
anonymous wrote : If the session is valid, then it's passivated to allow for reconstruction of the session
This implies either that my sessions are being considered invalid, a configuration issue, or possibly a bug. My HTTP session timeout is 20 minutes, so I should be fine in that regard.
Relevant configuration:
>From our jboss-web.xml
<passivation-config>
| <use-session-passivation>true</use-session-passivation>
| <passivation-min-idle-time>-1</passivation-min-idle-time>
| <passivation-max-idle-time>300</passivation-max-idle-time>
| </passivation-config>
|
>From the http session cache section of jboss-cache-manager-jboss-beans:
<property name="cacheLoaderConfig">
| <bean class="org.jboss.cache.config.CacheLoaderConfig">
| <!-- Do not change these -->
| <property name="passivation">true</property>
| <property name="shared">false</property>
|
| <property name="individualCacheLoaderConfigs">
| <list>
| <bean class="org.jboss.cache.loader.FileCacheLoaderConfig">
| <!-- Where passivated sessions are stored -->
| <property name="location">${jboss.server.data.dir}${/}session2</property>
| <!-- Do not change these -->
| <property name="async">false</property>
| <property name="fetchPersistentState">true</property>
| <property name="purgeOnStartup">true</property>
| <property name="ignoreModifications">false</property>
| <property name="checkCharacterPortability">false</property>
| </bean>
| </list>
| </property>
| </bean>
| </property>
|
Is there a trick to getting this going? This should be possible, correct?
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4259929#4259929
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4259929
16 years, 8 months
[EJB 3.0 Users] - Re: Multiple default PostConstruct method not called
by debasish.raychawdhuri
I was not calling ictx.proceed from PostConstruct (It should have thrown exception anyway). I had aroundInvoke also in those incerceptors (The spec says you can do that 12.4 "Lifecycle callback interceptor methods and business method interceptor methods may be defined on the same interceptor class."). Now lets try a simpler test case: [Since I cannot attach the jar here, I will write the whole code]
The bean class
| package com.ejb.demo;
|
| import java.util.Date;
|
| import javax.annotation.Resource;
| import javax.ejb.SessionContext;
| import javax.ejb.Stateless;
| import javax.ejb.Timer;
| import javax.ejb.TimerService;
| import javax.ejb.TransactionAttribute;
| import javax.ejb.TransactionAttributeType;
| import javax.jms.Connection;
| import javax.jms.JMSException;
| import javax.jms.MessageProducer;
| import javax.jms.Session;
| import javax.jms.TextMessage;
| import javax.jms.Topic;
| import javax.jms.TopicConnectionFactory;
|
| import org.javaeeutils.logger.annotation.Logger;
| import org.springframework.beans.factory.annotation.Configurable;
| import org.springframework.context.ApplicationContext;
| import org.springframework.context.support.ClassPathXmlApplicationContext;
|
| /**
| * Session Bean implementation class DemoFirstEJB
| */
| @Stateless
|
| public class DemoFirstEJB implements DemoFirstEJBRemote, DemoFirstEJBLocal {
|
| /**
| * Default constructor.
| */
| @Resource
| private SessionContext ctx;
|
|
| @Resource
| private TimerService timerService;
|
| public DemoFirstEJB() {
| // TODO Auto-generated constructor stub
| }
|
| @Override
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public void setTimer() {
|
|
| System.out.println("Inside setTimer");
|
| }
|
|
| }
|
The bean interface
|
| package com.ejb.demo;
| import javax.ejb.Remote;
|
| @Remote
| public interface DemoFirstEJBRemote {
| public void setTimer();
| }
|
|
The First Interceptor
| package com.ejb.demo.interceptors;
|
| import javax.annotation.PostConstruct;
| import javax.interceptor.AroundInvoke;
| import javax.interceptor.InvocationContext;
|
|
|
| public class DemoInterceptor {
|
| @AroundInvoke
| public Object aroundTimeout(InvocationContext ictx) throws Exception{
| System.out.println("Interceptor 1: AroundInvoke");
| return ictx.proceed();
| }
| @PostConstruct
| public void postConstruct(InvocationContext ictx){
| System.out.println("Interceptor 1: PostConstruct");
| }
| }
|
The second Interceptor
|
| package com.ejb.demo.interceptors;
|
| import javax.annotation.PostConstruct;
| import javax.ejb.Timer;
| import javax.interceptor.AroundInvoke;
| import javax.interceptor.InvocationContext;
|
| public class DemoInterceptor2 {
| @AroundInvoke
| public Object aroundTimeout(InvocationContext ictx) throws Exception{
| System.out.println("Interceptor 2: AroundInvoke");
| return ictx.proceed();
| }
| @PostConstruct
| public void postConstruct(InvocationContext ictx){
| System.out.println("Interceptor 2: PostConstruct");
| }
| }
|
|
The deployment descriptor
| <?xml version="1.0" encoding="UTF-8"?>
| <ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">
| <display-name>DemoEJB </display-name>
| <enterprise-beans>
| <session>
| <ejb-name>DemoFirstEJB</ejb-name>
| <business-local>com.ejb.demo.DemoFirstEJBLocal</business-local>
| <transaction-type>Container</transaction-type>
|
|
|
| </session>
|
| </enterprise-beans>
|
| <assembly-descriptor>
| <container-transaction>
|
| <method>
| <ejb-name>DemoFirstEJB</ejb-name>
| <method-name>*</method-name>
| </method>
| <trans-attribute>Required</trans-attribute>
| </container-transaction>
|
| <interceptor-binding>
| <ejb-name>*</ejb-name>
|
| <interceptor-class>com.ejb.demo.interceptors.DemoInterceptor2</interceptor-class>
| <interceptor-class>com.ejb.demo.interceptors.DemoInterceptor</interceptor-class>
| </interceptor-binding>
|
|
|
| </assembly-descriptor>
|
| </ejb-jar>
|
The remote client (stand alone java application]
| package com.demo.ejb.test;
|
| import java.util.Properties;
|
| import javax.naming.InitialContext;
| import javax.naming.NamingException;
| import javax.rmi.PortableRemoteObject;
|
| import com.ejb.demo.DemoFirstEJBRemote;
|
| public class Main {
|
| /**
| * @param args
| * @throws NamingException
| */
| public static void main(String[] args) throws NamingException {
| Properties p = new Properties();
| p.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
| p.put("java.naming.provider.url", "jnp://localhost:1099");
| p.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
|
|
| InitialContext ctx = new InitialContext(p);
| Object rem=ctx.lookup("DemoFirstEJB/remote");
| DemoFirstEJBRemote remote=(DemoFirstEJBRemote) PortableRemoteObject.narrow(rem, DemoFirstEJBRemote.class);
| remote.setTimer();
|
| }
|
| }
|
And here is the output of JBoss console when we run the client
|
| 22:24:45,610 INFO [STDOUT] Interceptor 2: PostConstruct
| 22:24:45,611 WARN [InterceptorsFactory] EJBTHREE-1246: Do not use InterceptorsFactory with a ManagedObjectAdvisor, InterceptorRegistry should be used via the bean container
| 22:24:45,611 WARN [InterceptorsFactory] EJBTHREE-1246: Do not use InterceptorsFactory with a ManagedObjectAdvisor, InterceptorRegistry should be used via the bean container
| 22:24:45,612 INFO [STDOUT] Interceptor 2: AroundInvoke
| 22:24:45,612 INFO [STDOUT] Interceptor 1: AroundInvoke
| 22:24:45,613 INFO [STDOUT] Inside setTimer
|
|
Thus only the PostConstruct of Interceptor2 is called
Now if I change the interceptor-binding to the following
| <interceptor-binding>
| <ejb-name>*</ejb-name>
| <interceptor-class>com.ejb.demo.interceptors.DemoInterceptor</interceptor-class>
| <interceptor-class>com.ejb.demo.interceptors.DemoInterceptor2</interceptor-class>
| </interceptor-binding>
|
Here is the output
| 22:46:44,446 INFO [STDOUT] Interceptor 1: PostConstruct
| 22:46:44,447 WARN [InterceptorsFactory] EJBTHREE-1246: Do not use InterceptorsFactory with a ManagedObjectAdvisor, InterceptorRegistry should be used via the bean container
| 22:46:44,447 WARN [InterceptorsFactory] EJBTHREE-1246: Do not use InterceptorsFactory with a ManagedObjectAdvisor, InterceptorRegistry should be used via the bean container
| 22:46:44,448 INFO [STDOUT] Interceptor 1: AroundInvoke
| 22:46:44,449 INFO [STDOUT] Interceptor 2: AroundInvoke
| 22:46:44,449 INFO [STDOUT] Inside setTimer
|
Thus only the PostConstruct of Inceptor1 is only called
Thus we can see only the first in the list of interceptors is called
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4259922#4259922
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4259922
16 years, 8 months
[JBoss Tools Users] - HelloWorld Tutorial Does Not Work
by gavinlam
Hi,
I'm trying to run the helloworld example provided by JBoss Tools. I am running JBossAS 4.2.2 with ESB 4.6 and the latest version of AOP and the latest JBoss Messaging. The helloworld project is published to the runtime server without any problems. However, when I run the SendEsbMessage application, I'm get the following stack trace. I'm completely new to JBoss and I don't know where to go from here. Any help will be great. Thanks.
| Usage SendEsbMessage <category> <name> <text to send>
| Exception in thread "main" org.jboss.soa.esb.listeners.message.MessageDeliverException: Failed to deliver message [header: [ ]] to Service [JBossESB-Internal:DeadLetterService]. Check for errors.
| at org.jboss.soa.esb.client.ServiceInvoker.post(ServiceInvoker.java:425)
| at org.jboss.soa.esb.client.ServiceInvoker.deliverAsync(ServiceInvoker.java:250)
| at org.jboss.soa.esb.client.ServiceInvoker.deliverToDeadLetterService(ServiceInvoker.java:292)
| at org.jboss.soa.esb.client.ServiceInvoker.deliverAsync(ServiceInvoker.java:260)
| at org.jboss.soa.esb.samples.quickstart.helloworld.test.SendEsbMessage.main(SendEsbMessage.java:56)
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4259918#4259918
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4259918
16 years, 8 months
[EJB] - Re: generic business interface
by mlieshoff
Thank you for fast answering, the correct signatures are here :
Business interface is following :
| public interface Business {
| // returns all elements of type t founded by name
| List<Item> getElementsByName(String name) throws Exception;
| }
|
My remote is type for items of type Item :
| public interface ItemRemote extends EJBObject, Business {
| // returns all elements of type t founded by name
| List<Item> getElementsByName(String name) throws RemoteException;
| }
|
My bean :
| public ItemBean implements SessionBean, Business {
| public<Item> List getElementsByName(String name) throws RemoteException {
| // do some magic to get list of item
| }
| }
|
Deploying fails because of this reason :
| Bean must implement all remote interface methods :
|
| List<Object> getElementsByName(String name) throws RemoteException;
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4259908#4259908
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4259908
16 years, 8 months