Error getting property from beanjava.lang.NullPointerException

I have a servlet, I can see it and can bind to it. However when I run I get the error

javax.faces.el.EvaluationException: Error getting property 'objectEmbedTag' from bean of type idface.id4start: java.lang.NullPointerException

I have been trying several weeks to get this to work, any help would be greatly appreciated

[341 byte] By [rtaylor185a] at [2007-11-27 9:47:53]
# 1

Simply being able to "see" and bind to an object at design time doesn't mean it exists when you want to use it at runtime.

I can declare any type of object I want at design time and bind to that object's properties. But at runtime, that object has to be instantiated somewhere prior to the point where it's bound values are needed.

Try running the program in the debugger to see if the object has been instantiated.

Futeleufu_Johna at 2007-7-13 0:00:57 > top of Java-index,Development Tools,Java Tools...
# 2
it stops at my serverlet public String getObjectEmbedTag() {return webkey.getObjectEmbedTag(); }}
rtaylor185a at 2007-7-13 0:00:57 > top of Java-index,Development Tools,Java Tools...
# 3
That means webkey is null, which means it hasn't been instantiated.When and where is the webkey object created?
Futeleufu_Johna at 2007-7-13 0:00:57 > top of Java-index,Development Tools,Java Tools...
# 4
right herepublic class id4start extends AbstractPageBean { public Server webkey;then webkey = new Server(); webkey.initialize(application, session);// SET THE WEB-key SERVER OBJECT PROPERTIES
rtaylor185a at 2007-7-13 0:00:57 > top of Java-index,Development Tools,Java Tools...
# 5

In which method is webkey created? init? prerender? preprocess?

In which method(s) is webkey referenced?

Have you considered making webkey a property of a session bean?

One thing you can try is to include the following check before referencing webkey.if(webkey == null) {

createWebkey();

}

and to include the following method to create and initialize webkeyprivate void createWebkey() {

webkey = new Server();

// Other initialization code here...

}

Futeleufu_Johna at 2007-7-13 0:00:57 > top of Java-index,Development Tools,Java Tools...
# 6
ok i will give this a shot
rtaylor185a at 2007-7-13 0:00:57 > top of Java-index,Development Tools,Java Tools...
# 7
i am not sure how to make it a property of a bean
rtaylor185a at 2007-7-13 0:00:57 > top of Java-index,Development Tools,Java Tools...
# 8

I'm using JSC 2. Update 1

I'm assuming you created the page using the IDE, so helper methods like getSessionBean1() are defined.

Let's assume you want to store webkey in SessionBean1.

In the Projects tab, right-click on SessionBean1 and select Add|Property from the pop-up menu.

The New Property Pattern dialog box opens. Type webkey in the Name field and Server in the Type field. Leave everything else alone. Click OK.

You can create and initiailize webkey in SessionBean's init method as you showed in an earlier post.

To get a reference to webkey in the page bean, just callgetSessionBean1().getWebkey()

That should do it.

Futeleufu_Johna at 2007-7-13 0:00:57 > top of Java-index,Development Tools,Java Tools...