无法创建 PoolableConnectionFactory(用户“root”@“localhost”访问被拒绝(使用密码:YES))
我最近在我的本地主机上部署了一个可用的 Web 应用程序到亚马逊 Web 服务。 我遇到的问题是 - 尽管 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>
您可以通过单击页面上的登录
或注册
来查看它的发生: http://184.73.118.76/Links.jsp
我需要做些什么来提供上下文。 xml修改后有效果吗? 我已执行两项操作:
1. WEB-INF 中touch web.xml
2. 重新启动tomcat服务器。
这里迫切需要帮助。
再次感谢。 詹姆斯.
I recently deployed a working webapp on my localhost to amazon web services.
The problem i'm encountering is - though context.xml has username as 'james', the exception stacktrace mentions otherwise.
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)
It is trying to connect to database with username 'root'. It it be because of caching of the file(context.xml)? How do I tackle that? I have restarted the web server as well, but it's not coming to effect.
Thanks in Advance.
EDIT:
Here's the content of 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>
You can see it happening by clicking on Login
or Register
on the page:
http://184.73.118.76/Links.jsp
Is there anything I need to do to bring context.xml changes to effect?
I have carried out two actions:
1. touch web.xml
in WEB-INF
2. Restart tomcat server.
Desperately need help here.
Thanks again.
James.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查您的 $CATALINA_BASE/conf/[enginename]/[hostname]/[webapp].xml,在默认 Tomcat 上,这应该是 $CATALINA_BASE/conf/Catalina/localhost/[webapp].xml,tomcat 创建您的上下文的副本。当您更新 context.xml 时,这可能没有更新
Tomcat 上下文容器参考
Check your $CATALINA_BASE/conf/[enginename]/[hostname]/[webapp].xml, on default Tomcat this should be $CATALINA_BASE/conf/Catalina/localhost/[webapp].xml, tomcat create a copy of your context.xml and this probably was not updated when you update your context.xml
Tomcat Context Container Reference
确保不存在名为 $CATALINA_BASE/conf/Catalina/localhost/yourapp.xml 的文件,或者它不包含用户名“james”的同一数据库的另一个数据源定义。
Make sure there isn't a file named $CATALINA_BASE/conf/Catalina/localhost/yourapp.xml or that it doesn't contain another datasource definition to the same database with the username 'james'.