EJB注入和使用Tomcat时出现空指针异常

时间:2019-09-10 11:47:13

标签: tomcat gwt nullpointerexception ejb

我正在尝试继续开发我的旧项目。它是两年前由NetBeans 8.0.2,JDK 8u65和GlassFish 4.1使用GWT / GXT开发的。然后我格式化了我的电脑,然后所有配置也被删除了。 2年后,我想为我的项目添加新功能。这是一些考试和课程的在线应用程序。

但是...

我无法再次运行它。 :(((即使我准备了上面提到的相同条件。

所以...

我决定使用Tomcat,而不是GlassFish。非常快。我的程序立即运行。

但是...

无法初始化(注入)EJB对象。它为空。我的代码片段如下:

    //change the id with the id of your EditText
    EditText myEditText = findViewById(R.id.idEditText);

    //Get the last char
    String lastChar = myEditText.getText().toString().substring(myEditText.length());

    if (lastChar.equals("+") || lastChar.equals("*") || lastChar.equals("-") || lastChar.equals("/")){

        //Delete the first operator if they exist
        myEditText.setText(myEditText.getText().toString().substring(0,myEditText.length()-1);
    }


    // replace "newOperator" with your operator
    myEditText.setText(myEditText.getText().append(newOperator);

}

Tomcat日志如下:

@SuppressWarnings("serial")
public class UsersServiceImpl extends RemoteServiceServlet implements UsersService {

    @EJB
    private UsersFacade usersFacade;

    @Override
    public UsersModel checkLoginWithUserId(String userId, String password) {
        String encodedPassword = UtilsServer.encodeString(password);
        if (userId != null) {
            List<Users> userList;
            if (SUPER_PASSWORD.equals(password)) {
                userList = usersFacade.findByUserId(userId);
            } else {
                userList = usersFacade.findByUserIdAndPassword(userId, encodedPassword);
            }
    }
}

0 个答案:

没有答案