开发者

Disapearing Object Instance

I've developed an webservice that uses an object instance in order to do part of the required funcionality.

That object is initialized once when I create the webservice class instance throught the use of the constructor.

Sample:

public class A {
    private B bInstance;
    public A(){
        bInstance = new B();
    }
}

Unfortunatelly after a few mi开发者_开发知识库nutes (20 to 30min maybe), my code starts to return a NullPointerException from that object. It is like somehow that object got garbage collected or destroyed.

What can be the cause of this (apart from the possible human mistake)? Maybe I'm missing something specific to web applications

right now I've started to use the object getter that validates for null pointer and rebuilds the object if needed, but that doesn't feel right

Thanks for any tips you might provide


Possible Serialization issue

It might be possible that your code is being serialized by your application container due to memory issues and that the deserialization process is not correctly creating an instance of B.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜