Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Bean Losing Data  RSS feed

 
Sean Dobbins
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Web application that uses Java Beans to store user data as it is entered, until it is stored in a backend Oracle database. The application is running on WebLogic 8.1 on a Sun box. This app worked fine in our development and testing environments and was working fine in our production environment.

At one point of the app, the user is displayed the information that they have entered to verify. This information is retrieved from the beans using the getter methods in the bean. Now in production, data from the beans is being "lost". When the information is displayed back to the user, many of the fields are returned with no values.

The beans all implement serializable and are all called as session beans. The same code works fine in the other two environments. I do not have access to the actual servers, as I am a developer and there is another group that handles the servers and deployments. They are telling me that nothing has changed, and the environments are the same, but I cannot verify.

Obviously, I know I am not giving anyone much to work with on this problem. I am basically just looking for some outside ideas as to what could cause this. Whether it be in the code or in the environment. This is the first full Java Web app that I have created, so any ideas, no matter how simple, would be appreciated. I don't think that I missed anything in the code, but I'm not ruling it out either.

Thanks in advance for the help.
[ May 20, 2005: Message edited by: Sean Dobbins ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not clear on exactly at what point the data is lost. Is it between the time the info is submitted from the form on the page, or on the way to populate that form in the first place?
[ May 20, 2005: Message edited by: Bear Bibeault ]
 
Sean Dobbins
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the data is submitted on the form, the page that it is posted to stores the data in a bean using the beans setter methods. The data is being lost somewhere between that point, and when it is retrieved from the bean using the getter methods. The worst part is that it is not consistent. different amounts of data are lost on different attempts.

It almost seems as if the faster you go through, the less you lose, but the session timeout is set to 30 minuites. I have a session timeout page that the user is redirected to once that happens, so it should not be losing the session.

The beans are structured as follows:

package myBeans;
import java.beans.*;
public class myClass extends Object implements java.io.Serializable
{
private static String firstName = "";

public myClass() {}

public static String getFirstName()
{ return firstName; }
public static void setFirstName(String newFirstName)
{ firstName = NewFirstName; }

public static void cleanOut()
{ shipFirstName = ""; }
}

The beans are used in the JSP like this:

<jsp:useBean id="myBean" scope="session" class="myBeans.myClass" />
<% myBean.setFirstName(request.getParameter("firstName")); %>
<%= myBean.getFirstName() %>
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would start by putting some way of seeing the sessionId in the page.

To see if the session is getting lost.

You may also want to put the server IP and the user's IP (request.getRemoteAddr()) in the HTML comments.
If you're using IP load balancing and the load balancer isn't keeping the user on the same machine, this could happen.
Also, some ISPs use very short leases on IP numbers (around 5 minutes).
 
Sean Dobbins
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will try adding the session ID to the page output.

We are using load balancing, but we have already eliminated that as the problem. To bypass the load balancing I have been going strait to the IP of each of the app servers, and the problem is still present.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to add some code that logs the sessionID, UserId, User's IP, and the dateTime.

A nice clean log file with only those fields (or any others that you deem relevant) would probably go a long way toward solving this.
 
Sean Dobbins
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have now verified that the same session id is persisting throughout the application, but the data still is not. And this is still only happening in our production environment, not development or testing. I can't think of any environment variables that would cause this sort of behavior.
[ May 23, 2005: Message edited by: Sean Dobbins ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If Weblogic supports it you could add some more debugging, triggered by a SessionBindingEvent:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSessionBindingListener.html

With it you can see exactly when the object was removed from session.
I think this has been around since Servlet Spec 2.3.
 
Sean Dobbins
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added logging in my beans that will log any time that a bean is connected to or removed from a session. I will be testing this today. Hopefully this will be able to tell me something.

Thanks for the suggestion!
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just noticed something:

Do you really want that to be a static variable? Shared by all instances of the class!

Bill
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Brogden:
I just noticed something:

Do you really want that to be a static variable? Shared by all instances of the class!

Bill


That would explain why it works in test (one user) and fails in production (multiple users).
 
Sean Dobbins
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You know, I never even paid any attention to the fact that I was declaring my variables as static. Can you tell this is my first large scale, from scratch java project.

I will remove "static" from my variables and methods and give this another try tomorrow. If that solves the problem, I may just have to shoot myself in the foot.

I'll post an update tomorrow.

Thanks!
 
Sean Dobbins
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It appears that my issue has been resolved.

What a difference a little word like "static" can make!

Thanks so much for everyone's help!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!