我正在尝试将 Tomcat 7 配置为使用 RDS/MySQL 实例,但我没有运气。我怀疑问题出在我的 context.xml 中。存在 context.xml 时,会发生一些不好的事情,例如无法通过 Eclipse 进行远程调试,因此无法调试我的数据库代码正在发生的事情。我的 context.xml(删除了用户名/密码等详细信息以保护无辜者):
<?xml version='1.0' encoding='utf-8'?>
<Context path="/puppy" reloadable="true" crossContext="true">
<Resource name="jdbc/myDB"
auth="Container"
type="javax.sql.DataSource"
username="username"
password="password"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://rds-instance:3306/myDB?autoReconnect=true"
validationQuery="select 1"
maxActive="10"
maxIdle="4"/>
</Context>
部署应用程序后,我在日志中得到以下信息:
WARNING: Failed to retrieve JNDI naming context for container [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/puppy]] so no cleanup was performed for that container
javax.naming.NameNotFoundException: Name comp is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:803)
at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
at org.apache.catalina.deploy.NamingResources.cleanUp(NamingResources.java:975)
at org.apache.catalina.deploy.NamingResources.stopInternal(NamingResources.java:957)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5504)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3847)
at org.apache.catalina.manager.ManagerServlet.reload(ManagerServlet.java:949)
at org.apache.catalina.manager.HTMLManagerServlet.reload(HTMLManagerServlet.java:676)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:214)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:187)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:572)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:403)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:301)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:162)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
Jul 6, 2011 4:44:52 AM org.apache.catalina.core.NamingContextListener lifecycleEvent
SEVERE: Creation of the naming context failed: javax.naming.NamingException: Context is read only
知道发生了什么吗?人们不将 JNDI 与 RDS 一起使用吗?最好的方法是什么?