2010-07-21 354 views
1

我最近在本地主機上部署了一個可用的Web應用程序,用於創建亞馬遜Web服務。 我遇到的問題是 - 雖然context.xml具有用戶名作爲'詹姆斯',異常stacktrace否則提到。無法創建PoolableConnectionFactory(拒絕用戶root'@'localhost'(使用密碼:YES))

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)?我如何解決這個問題?我也重新啓動了Web服務器,但它不會生效。

在此先感謝。

EDIT:

這裏的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. WEB-INF中的touch web.xml
2.重新啓動tomcat服務器。

在這裏非常需要幫助。

再次感謝。 James。

+0

這看起來非常像一個MySQL錯誤。我想你需要配置你的mysql服務器接受來自本地主機的root登錄,或者更好的:設置一個合適的用戶! – thatsdisgusting 2010-07-21 12:52:37

+0

MySQL錯誤?我不這麼認爲。如果是mysql錯誤,爲什麼它會嘗試在context.xml中使用'root'而不是'james'來登錄? '詹姆斯'是一個正確的用戶。即使我們將用戶名更改爲「root」,它仍然不起作用,因爲緩存(我強烈認爲這是原因)文件可能對密碼有一些價值,這與 不符合實際的根數據庫密碼。 – James 2010-07-21 13:03:27

+0

你可以發佈dbcp配置嗎? – 2010-07-21 13:33:21

回答

1

檢查你的$ 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目錄/ [引擎]/[主機名] /,在 一個單獨的文件/ META-INF/context.xml在應用程序文件中。如果Web 應用程序打包爲WAR,則將/META-INF/context.xml複製到$ CATALINA_BASE/conf/[enginename]/[hostname] /並將 複製到 以匹配應用程序的上下文路徑。一旦這個文件存在,如果新的/META-INF/context.xml中的新WAR被放置在主機的appBase中,則 不會被替換。

0

確保沒有一個名爲$ CATALINA_BASE/conf目錄/卡塔利娜/本地主機/ yourapp.xml文件或者它不包含另一個數據源定義與用戶名「詹姆斯」相同的數據庫。

相關問題