java - 无法创建 PoolableConnectionFactory(用户 'root' @'localhost' 的访问被拒绝(使用密码 : YES))

标签 java mysql tomcat connection-pooling

我最近在我的本地主机上部署了一个工作网络应用程序到亚马逊网络服务。 我遇到的问题是 - 尽管 context.xml 的用户名是“james”,但异常堆栈跟踪另有说明。

org.apache.jasper.JasperException: org.apache.jasper.JasperException: org.apache.jasper.JasperException: javax.servlet.ServletException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

它正在尝试使用用户名“root”连接到数据库。是因为文件(context.xml)的缓存吗?我该如何解决?我也重新启动了网络服务器,但它没有生效。

提前致谢。

编辑:

这是 context.xml 的内容:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiResourceLocking="false" privileged="true" >
    <Resource 
       name="jdbc/NetmarketDB"
       auth="Container"
       type="javax.sql.DataSource"
       removeAbandoned="true"
       removeAbandonedTimeout="30"
       maxActive="100"
       maxIdle="30"
       maxWait="1000"
       username="james"
       password="xxxxxxxxxx"
       driverClassName="com.mysql.jdbc.Driver"
       url="jdbc:mysql://localhost:3306/ams"/>
</Context>

您可以通过单击页面上的LoginRegister 来查看它的发生: http://184.73.118.76/Links.jsp

我需要做些什么才能使 context.xml 更改生效吗? 我执行了两个操作:
1. touch web.xml在WEB-INF
2.重启tomcat服务器。

在这里迫切需要帮助。

再次感谢。 詹姆斯。

最佳答案

检查你的 $CATALINA_BASE/conf/[enginename]/[hostname]/[webapp].xml,在默认的 Tomcat 上这应该是 $CATALINA_BASE/conf/Catalina/localhost/[webapp].xml,tomcat 创建一个副本你的 context.xml 并且这可能在你更新你的 context.xml 时没有更新

Tomcat Context Container Reference

$CATALINA_BASE/conf/[enginename]/[hostname]/, in an individual file at /META-INF/context.xml inside the application files. If the web application is packaged as a WAR then /META-INF/context.xml will be copied to $CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to match the application's context path. Once this file exists, it will not be replaced if a new WAR with a newer /META-INF/context.xml is placed in the host's appBase.

关于java - 无法创建 PoolableConnectionFactory(用户 'root' @'localhost' 的访问被拒绝(使用密码 : YES)),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3299317/

相关文章:

java - 安装 TPTP 配置文件工具

MySQL:将列值转换为带有总计的标题

mysql - 无需任何键即可连接两个表

java - CAS 身份验证 - UrlRewriteFilter 使 request.getRemoteUser() 无效

java - Android客户端/Java服务器通信,无法接收服务器返回的数据

JAVA使用三元运算符调用方法

java - 对于 java spring hibernate 网站来说,哪个是最好的 Web 服务器

php - 如何根据用户单击的按钮在 $_SESSION 中存储正确的值?

tomcat - 控制 Jenkins 外部日志记录?

tomcat - 是否可以在嵌入式 Tomcat 7 中启用 JMX?