aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes No Such Object Exception Session has timed out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "No Such Object Exception Session has timed out" Watch "No Such Object Exception Session has timed out" New topic
Author

No Such Object Exception Session has timed out

raju svgk
Greenhorn

Joined: Sep 25, 2002
Posts: 14
Hi,
I am using Jdeveloper 9.0.2, Windows 2000 Professional, Oracle 8.1.6 database. My application consists of servlets, stateful session beans, and entity beans. When ever I get an exception in the stateful session bean I am catching it and throwing it to the servlet to display proper error messages. But once a session bean throws an exception, and after that if servlet trys to connect to the session bean I am getting the following error.


Actually I catching the appropriate exception in the session bean and throwing 'RemoteException' again in the servlet I am catching 'RemoteException' to display the error message.

How to keep the sesssion alive even if a session bean throws an exception.
Vinod John
Ranch Hand

Joined: Jun 23, 2003
Posts: 162
You can keep the session bean alive by pinging at a regular intervals, this is a resourse intensive method, in your case, I suspect, this would be of any help. Did try to confirm that the bean is getting passivated every time a (application)exception is thrown ? how do you access the session (thru remote interface or handle) ?, in case you aren't using the handle try it.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

What is the exception throen from the stateful session bean that you are catching?


Groovy
Bhupesh Kokate
Greenhorn

Joined: Jul 18, 2003
Posts: 22
Raju,
I think you need to cache ur handles for session bean and also increase the timeout for sessionbean ... Session beans does not collaps after throwing an exceptions if u make a call using cached handle.
If u r using websphere u can set timeout using AAT.
Bhupesh
raju svgk
Greenhorn

Joined: Sep 25, 2002
Posts: 14
Hi,
I am using Servlets and Stateful SessionBeans in my application. If I find any error in the sessionBean, I am catching it with an appropriate exception and throwing RemoteException. For Example there is a method called 'createUser' as follows:
public int createUser (String uname) throws RemoteException {
try {
.....
.....
......
} catch (FinderException fe) {
fe.printStackTrace();
throw new RemoteException ("Create User Failed: " + fe.getMessage(), fe);
} catch (NullPointerException npe) {
npe.printStackTrace();
throw new RemoteException ("Create User Failed: " + npe.getMessage(), npe);
} catch (DuplicateKeyException dke) {
dke.printStackTrace();
throw new RemoteException ("Create User Failed: " + dke.getMessage(), dke);
}
}
The intention here is to throw proper error messages to a servlet. In the Servlet I am catching RemoteException to show the error messages on a webpage as follows:
protected void doCreateUser (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
.....
.....
} catch (RemoteException rex) {
rex.printStackTrace();
errorPage(rex.getMessage()); // To show the errors on a webpage
}
}
Till now it is fine. When I am trying to access the session next time, it says
java.rmi.NoSuchObjectException: Session has timed out at com.evermind.server.ejb.StatefulSessionEJBObject.throwPassivisationException(StatefulSessionEJBObject.java:215)
at qReportSession_StatefulSessionBeanWrapper10.getRecordTypes(qReportSession_StatefulSessionBeanWrapper10.java:419)
at qtweb.qtReportServ.onRecTypeForm(qtReportServ.java:1648)
at qtweb.qtReportServ.doGet(qtReportServ.java:105)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:684)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:269)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:735)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:243)
at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64)
How do I make sure that session is not timedout when the session bean throws an exception.
I am accessing the session bean methods using remote inteface. First lookup for the home inteface and create a remote interface.
How to check whether a session bean is getting passivated or not?
Thanks and regds
-raju
Claudio Gualberto
Ranch Hand

Joined: Oct 13, 2002
Posts: 47
Ejb Containers treats two types of exceptions, the system exceptions and the application exception.
When you throw an system exception, the container takes some precautions like take the EJB reference off cache ( in case of Entity Bean ) , invalidate the proxy EJB and so on.
You can test this feature, changing the type of the exception you�re throwing. Subclass the java.lang.Exception to a AplicationException and throw it on your remote metodos instead of RemoteException when applications erros ocurs, let�s see what happen.
Claudio Gualberto
SCJP 1.4
Vinod John
Ranch Hand

Joined: Jun 23, 2003
Posts: 162
The exception seems more like the bean is passivated for some reason ?? Try this diable passivation, by setting this property in one of the config file (should be server.xml)
<sfsb-config enable-passivation="false"/>
Originally posted by raju svgk:

How to check whether a session bean is getting passivated or not?

You can add a trace to ejbPassivate method in the bean class, it would be nice to confirm whether the bean is getting passivated....
Dana Hanna
Ranch Hand

Joined: Feb 28, 2003
Posts: 227
Originally posted by Claudio Gualberto:
When you throw an system exception, the container takes some precautions like take the EJB reference off cache

I agree - Since the system exception "RemoteException" is thrown, the container assumes that the something is wrong.
Think about why this exception is required... It represents a problem dealing with the remote bean. Therefore, your container is assuming that the bean is no good anymore...
Declare another type of exception for you to use - and don't extend "RemoteException".
raju svgk
Greenhorn

Joined: Sep 25, 2002
Posts: 14
Yes, when I was using my own exception class, the session is not getting timed out.
Thank you for ur suggestions.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: No Such Object Exception Session has timed out