Solved

Stateful EJB remove problem

Posted on 2007-03-22
9
425 Views
Last Modified: 2013-11-24
Hi folks,

One of my colleagues has been facing issues with a J2EE 1.3 application deployed on Weblogic. The basic flow of the application is:

JSP -> Servlet -> EJB (Stateful session bean) -> CORBA (Visibroker 6.0) -> Toplink -> Oracle/ DB2

Don't ask me why the CORBA layer is there :) it seems quite redundant to me but when they designed it 8 years back they probably wanted to use it as it was more mature than J2EE.

Anyway, the issue is that when the user logs out and tries to log in again, he gets an exception saying "EJB session context could not be released". Any idea why it is trying to release the EJB on login?

I see that on logout, the attributes are being removed from the HttpSession (one of the attributes is the EJB handle and that is also being removed by a call to remove ()). Also - how does this work in case the user closes the window by clicking on the X button on the browser instead of logging out?

Thanks,
Mayank.
0
Comment
Question by:Mayank S
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 9

Expert Comment

by:owenli27
ID: 18773568
>>Also - how does this work in case the user closes the window by clicking on the X button on the browser instead of logging out?
The server side may never know when a client closed his broswer.  I guess that it has to wait for HttpSession time out, then start to remove EJB object instance and release resource for cleaning up.   You can create a class to implements HttpSessionBindingListener in web tier. then implement valueUnbound() for getting EJB reference.

>>gets an exception saying "EJB session context could not be released".
I don't know why the msg come out after user relogin.  I guess that EJB session context never been released yet although the remove() called from from EJBObject or remove(Handle handle) called from EJBHome because a call to one of these remove() method does not necessarily remove the actual Access EJB instance;  It just notify the EJB container that the instance can be removed if no other client components are currently using it. But it is not guaranteed.
0
 
LVL 30

Author Comment

by:Mayank S
ID: 18774453
>> You can create a class to implements HttpSessionBindingListener in web tier.

Yeah I checked - they are doing that.

>>  But it is not guaranteed.

Is that so? Do you have any documentation/ link which explains this?
0
 
LVL 9

Expert Comment

by:owenli27
ID: 18774679
Sorry, I should change it to: "it is not guaranteed to be happened right after called removed()"  :)
0
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
LVL 9

Expert Comment

by:owenli27
ID: 18774712
http://publib.boulder.ibm.com/infocenter/wbihelp/v6rxmx/index.jsp?topic=/com.ibm.wics_developer.doc/doc/access_dev_ejb/access_dev_ejb26.htm

"The client component is responsible for requesting that an Access EJB instance be created or removed. However, the EJB container within the application server determines when such activities actually occur."
0
 
LVL 30

Author Comment

by:Mayank S
ID: 18774724
Ok. I noticed something more in the login.jsp. It has a scriptlet:

<%
  if ( ! session.isNew () )
  {
    // loops through all session parameters and removes them

  }

%>

Any idea why the session would not be new if it is going there after a logout?
0
 
LVL 9

Accepted Solution

by:
owenli27 earned 500 total points
ID: 18774936
Did you actually invaliad session before user logout?
BTW, when HttpSession timeout and unbind the HttpSessionBindingListener from session attribute,  the user identity(principal-name) may become anonymous. If the related EJB method has access permission, you may need to define new <security-role> and setup <security-role-assignment> for <principal-name>.  Also, in ejb-jar DD that stateful session bean, you may need to add something like:
     <security-identity>
      <run-as>
          <role-name>abcdefg-role</role-name>
      </run-as>
      </security-identity>
0
 
LVL 30

Author Comment

by:Mayank S
ID: 18776159
>> Did you actually invaliad session before user logout?

It is being invalidated upon logout using session.invalidate ()
0
 
LVL 30

Author Comment

by:Mayank S
ID: 18776162
>> If the related EJB method has access permission

No, it doesn't.
0
 
LVL 30

Author Comment

by:Mayank S
ID: 18776167
I found a solution - the ejbRemove () method was throwing a NullPointerException because of bad coding - a null check was not being done there for an object which could be null on some circumstances.... so the EJB was not being properly released. I'll give you points for the help though.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet example 11 59
ejb stateless example 2 43
Need Help! Getting a syntax error and don't understand why 3 41
learn programming 8 72
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question