Aliaksandr Stsiapanay [
https://community.jboss.org/people/alexdev] created the discussion
"Ejb not found on http session timeout"
To view the discussion, visit:
https://community.jboss.org/message/761124#761124
--------------------------------------------------------------
Hi everybody!
I have a problem of getting ejb local reference in Http session listener in method
#sessionDestroyed(HttpSessionEvent)
There is code snippet below:
+@WebListener+
+public class SessionCleanUpListener implements HttpSessionListener {+
+ /**+
+ * @see HttpSessionListener#sessionCreated(HttpSessionEvent)+
+ */+
+ public void sessionCreated(HttpSessionEvent arg0) {+
+ }+
+ /**+
+ * @see HttpSessionListener#sessionDestroyed(HttpSessionEvent)+
+ */+
+ public void sessionDestroyed(HttpSessionEvent arg0) {+
+
ServiceLocator.getInstance().getWorkflowMessageManagerBean().removeNotPersistentItems(arg0.getSession().getId());+
+ }+
+}+
ServiceLocator is a utility class to obtain ejb reference.
+public class ServiceLocator {+
+ private final static String JNDI_NAME_WORKFLOW_MESSAGE_MANAGER_BEAN =
"java:app/EDI_EJB/WorkflowMessageManagerBean";+
+ private final static ServiceLocator SERVICE_LOCATOR = new ServiceLocator();+
+ private final Context context;+
+ private ServiceLocator() {+
+ try {+
+ context = new InitialContext();+
+ } catch (NamingException e) {+
+ throw new RuntimeException(e);+
+ }+
+ }+
+ public static ServiceLocator getInstance() {+
+ return SERVICE_LOCATOR;+
+ }+
+ public WorkflowMessageManagerBeanLocal getWorkflowMessageManagerBean() {+
+ try {+
+ return (WorkflowMessageManagerBeanLocal)
context.lookup(JNDI_NAME_WORKFLOW_MESSAGE_MANAGER_BEAN);+
+ } catch (NamingException e) {+
+ throw new RuntimeException(e);+
+ } +
+ }+
+}+
When session timeout is triggered I got following exception in jboss console:
13:39:52,179 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/edi]]
(ContainerBackgroundProcessor[StandardEngine[jboss.web]]) Session event listener threw
exception: java.lang.RuntimeException: javax.naming.NameNotFoundException:
java:app/EDI_EJB/WorkflowMessageManagerBean
at
com.nvcm.edi.web.factory.ServiceLocator.getWorkflowMessageManagerBean(ServiceLocator.java:82)
[classes(inlove)
at
com.nvcm.edi.web.listener.SessionCleanUpListener.sessionDestroyed(SessionCleanUpListener.java:26)
[classes(inlove)
at org.apache.catalina.session.StandardSession.expire(StandardSession.java:690)
[jbossweb-7.0.13.Final.jar(inlove)
at org.apache.catalina.session.StandardSession.isValid(StandardSession.java:585)
[jbossweb-7.0.13.Final.jar(inlove)
at org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:390)
[jbossweb-7.0.13.Final.jar(inlove)
at org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:375)
[jbossweb-7.0.13.Final.jar(inlove)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1316)
[jbossweb-7.0.13.Final.jar(inlove)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
[jbossweb-7.0.13.Final.jar(inlove)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
[jbossweb-7.0.13.Final.jar(inlove)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
[jbossweb-7.0.13.Final.jar(inlove)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
[jbossweb-7.0.13.Final.jar(inlove)
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_05]
Caused by: javax.naming.NameNotFoundException:
java:app/EDI_EJB/WorkflowMessageManagerBean
at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:121)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:214)
at javax.naming.InitialContext.lookup(Unknown Source) [rt.jar:1.7.0_05]
at
com.nvcm.edi.web.factory.ServiceLocator.getWorkflowMessageManagerBean(ServiceLocator.java:80)
[classes(inlove)
... 11 more
We use Java 1.6, jboss-as-7.1.1.Final, Ejb 3 on our project.
Please any help?
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/761124#761124]
Start a new discussion in EJB3 Development at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]