无法创建 PoolableConnectionFactory(用户“root”@“localhost”访问被拒绝(使用密码:YES))

发布于 2024-09-11 03:15:04 字数 1807 浏览 5 评论 0原文

我最近在我的本地主机上部署了一个可用的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痕至 2024-09-18 03:15:05

检查您的 $CATALINA_BASE/conf/[enginename]/[hostname]/[webapp].xml,在默认 Tomcat 上,这应该是 $CATALINA_BASE/conf/Catalina/localhost/[webapp].xml,tomcat 创建您的上下文的副本。当您更新 context.xml 时,这可能没有更新

Tomcat 上下文容器参考

$CATALINA_BASE/conf/[enginename]/[hostname]/,位于以下位置的单个文件中
应用程序文件内的 /META-INF/context.xml。如果网络
应用程序打包为 WAR,然后 /META-INF/context.xml 将是
复制到 $CATALINA_BASE/conf/[enginename]/[hostname]/ 并重命名为
匹配应用程序的上下文路径。一旦该文件存在,它将
如果使用较新的 /META-INF/context.xml 的新 WAR 不被替换
放置在主机的appBase中。

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/[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.

蓝眸 2024-09-18 03:15:05

确保不存在名为 $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'.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文