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
# 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.
# 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...
}
# 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.