Tomcat 8.5.4 javax.naming.NameNotFoundException

时间:2016-08-17 16:30:47

标签: java tomcat

我正在使用Tomcat 8.5.4开发Web应用程序。我正在使用配置为资源的属性。所以,我的$ TOMCAT_HOME / conf / server.xml包含

<Context antiResourceLocking="true" path="/mywebapp">
  <ResourceLink global="properties/global" name="properties/global" type="java.util.Properties"/>
</Context>

我的webapp的META-INF / context.xml有

Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
(Properties) envContext.lookup("properties/global");

我正在查找资源,如下所示

javax.naming.NameNotFoundException: Name [properties/global] is not bound in this Context. Unable to find [properties].

但是,我得到了例外

int totalAttempts = 3;

private void executeLogin() {

    String userNameStr = userNameTF.getText();
    String passWordStr = passWordTF.getText();

    if (totalAttempts != 0) {
        if (userNameStr == "temp" && passWordStr == "pass") {
            System.out.println("Correct");
        else {
            System.out.println("Incorrect");
            totalAttempts--;

    } else {
        System.out.println("Maximum number of attempts exceeded");
    }
}

怎么了?感谢。

0 个答案:

没有答案