https://issues.apache.org/bugzilla/show_bug.cgi?id=57380
Bug ID: 57380
Summary: Misleading NameNotFoundException from DataSourceRealm
Product: Tomcat 8
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
Assignee: [email protected]
Reporter: [email protected]
Imagine we have the following context descriptor, and the application is
protected with security constraints:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/FooDB"
type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql:foo"
... />
<Realm className="org.apache.catalina.realm.DataSourceRealm"
dataSourceName="jdbc/FooDB"
... />
</Context>
If DataSource has any problems (driver class not found, connection refused,
username/password mismatch, no database etc.), login attempt will give the
following in the log:
21-Dec-2014 03:08:58.707 SEVERE [http-nio-8080-exec-1]
org.apache.catalina.realm.DataSourceRealm.open Exception performing
authentication
javax.naming.NameNotFoundException: Name [jdbc/FooDB] is not bound in this
Context. Unable to find [jdbc].
at org.apache.naming.NamingContext.lookup(NamingContext.java:818)
at org.apache.naming.NamingContext.lookup(NamingContext.java:166)
at org.apache.catalina.realm.DataSourceRealm.open(DataSourceRealm.java:363)
at
org.apache.catalina.realm.DataSourceRealm.authenticate(DataSourceRealm.java:260)
at
org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthenticator.java:111)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:576)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
at
org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
The message is completely misleading, since the actual cause is not printed.
Obtaining actual cause requires the knowledge of initialSize="1" hint.
Moreover, if we disable security constraints, and (provided that driver is
present) try to resolve java:comp/env/jdbc/FooDB from an application, it turns
out that the resource in fact *is* bound and alive.
It would be great if Tomcat did actually log the relevant stacktrace, making
easy to diagnose network or database problems with JNDI DataSource +
DataSourceRealm combo.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]