Java Google应用程序引擎文本的NullPointerException

Java Google应用程序引擎文本的NullPointerException,java,google-app-engine,struts2,nullpointerexception,Java,Google App Engine,Struts2,Nullpointerexception,我有以下带有Text属性的概要bean: import com.google.appengine.api.datastore.Text; public class Profile { ... private Text aboutMySelf = null; public String getAboutMySelf() { return aboutMySelf.getValue(); } public void setAboutMySe

我有以下带有
Text
属性的概要bean:

import com.google.appengine.api.datastore.Text;

public class Profile {
    ... 
    private Text aboutMySelf = null;

    public String getAboutMySelf() {
        return aboutMySelf.getValue();
    }
    public void setAboutMySelf(String aboutMySelf) {
        this.aboutMySelf = new Text(aboutMySelf);
    }
    ...
}
当获得关于你自己的
时,我有ff条件

if (profile.getAboutMySelf() != null){
    ...
}
问题是我仍然遇到了行
if(profile.getAboutMySelf()!=null)
为什么?如何修复它

堆栈跟踪:

Uncaught exception from servlet
java.lang.NullPointerException
    at Profile.getAboutMySelf(Profile.java:263)
    at ...(.....java:137)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:45)
    at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:453)
    at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:292)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:255)
    at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)

您需要检查配置文件是否为空。如果(profile!=null)我确定profile不是null,那么只有
aboutMySelf
,因为profile.getAboutMySelf(profile.java:263)上还有profileat.getAboutMySelf的其他属性。这行中的u代码是什么?让
return(aboutMySelf==null)可以吗?“”:aboutMySelf.getValue()在getter中?是的,我想你可以试试。