You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tarin Gamberini <ta...@gmail.com> on 2018/03/08 16:26:39 UTC
Strange behavior on Tomcat 9.0.5 about ResourceLink's "name"
attribute in server.xml
Hi everybody,
I have found a strange behavior on Tomcat 9.0.5 (originally on Tomcat
8.5.28).
# PROBLEM
I have two datasources in the same web application:
<ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
type="javax.sql.DataSource"/>
<ResourceLink global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abc/jkl"
type="javax.sql.DataSource"/>
Starting the server I get an "java.lang.ClassCastException:
org.apache.tomcat.dbcp.dbcp2.BasicDataSource cannot be cast to
javax.naming.Context" ERROR.
# HOW TO REPRODUCE THE ERROR
In my Apache Tomcat 9.0.5's server.xml:
<GlobalNamingResources>
<Resource name="jdbc/abc/ABC"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@machine1:1678:DEV"
auth="Container" username="ABC"
password="**************************************"
maxTotal="8" maxIdle="4" logAbandoned="true"
/>
<Resource name="jdbc/abc/jkl/XXX_YYY"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@machine1:1678:DEV"
auth="Container" username="XXX_YYY"
password="**************************************"
maxTotal="8" maxIdle="4" logAbandoned="true"
/>
</GlobalNamingResources>
In C:\my-favourite-ide\abc\src\main\webapp\META-INF\context.xml (it's an
Apache Maven project):
<?xml version="1.0" encoding="UTF-8"?>
<Context useHttpOnly="true" path="/abc">
<!--
"global" attribute links to GlobalNamingResources in the
${catalina.base}/conf/server.xml (server administrator team)
"name" attribute is relative to the JNDI context java:comp/env/
and is looked up from the java application (application developer team)
-->
<ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
type="javax.sql.DataSource"/>
<ResourceLink global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abc/jkl"
type="javax.sql.DataSource"/>
</Context>
In C:\my-favourite-ide\abc\src\main\webapp\WEB-INF\web.xml:
<resource-ref>
<description>Datasource ofv</description>
<res-ref-name>jdbc/abc</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>Datasource ofv</description>
<res-ref-name>jdbc/abc/jkl</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Starting the server I get the "java.lang.ClassCastException:
org.apache.tomcat.dbcp.dbcp2.BasicDataSource cannot be cast to
javax.naming.Context" ERROR:
Using CATALINA_BASE: "C:\java\apache-tomcat-9.0.5-catalina-base"
Using CATALINA_HOME: "C:\java\apache-tomcat-9.0.5"
Using CATALINA_TMPDIR: "C:\java\apache-tomcat-9.0.5-catalina-base\temp"
Using JRE_HOME: "C:\java\jdk1.8.0_111"
Using CLASSPATH:
"C:\java\apache-tomcat-9.0.5\bin\bootstrap.jar;C:\java\apache-tomcat-9.0.5\bin\tomcat-juli.jar"
06-Mar-2018 10:23:07.968 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log Server version:
Apache Tomcat/9.0.5
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log Server built:
Feb 6 2018 21:42:23 UTC
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log Server number:
9.0.5.0
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log OS Name:
Windows 7
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log OS Version:
6.1
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log Architecture:
amd64
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log Java Home:
C:\java\jdk1.8.0_111\jre
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log JVM Version:
1.8.0_111-b14
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:
Oracle Corporation
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:
C:\java\apache-tomcat-9.0.5-catalina-base
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:
C:\java\apache-tomcat-9.0.5
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log Command line
argument:
-Djava.util.logging.config.file=C:\java\apache-tomcat-9.0.5-catalina-base\conf\logging.properties
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: -Djdk.tls.ephemeralDHKeySize=2048
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: -Dignore.endorsed.dirs=
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: -Dcatalina.base=C:\java\apache-tomcat-9.0.5-catalina-base
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: -Dcatalina.home=C:\java\apache-tomcat-9.0.5
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: -Djava.io.tmpdir=C:\java\apache-tomcat-9.0.5-catalina-base\temp
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR
based Apache Tomcat Native library [1.2.16] using APR version [1.6.3].
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR
capabilities: IPv6 [true], sendfile [true], accept filters [false], random
[true].
06-Mar-2018 10:23:07.984 WARN [main]
org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL
configuration: useAprConnector [false], useOpenSSL [true]
06-Mar-2018 10:23:08.545 WARN [main]
org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL
successfully initialized [OpenSSL 1.0.2m 2 Nov 2017]
06-Mar-2018 10:23:08.920 WARN [main]
org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler
["http-nio-8080"]
06-Mar-2018 10:23:08.966 WARN [main]
org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared
selector for servlet write/read
06-Mar-2018 10:23:08.966 WARN [main]
org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler
["ajp-nio-8009"]
06-Mar-2018 10:23:08.966 WARN [main]
org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared
selector for servlet write/read
06-Mar-2018 10:23:08.966 WARN [main]
org.apache.catalina.startup.Catalina.load Initialization processed in 1349
ms
06-Mar-2018 10:23:08.998 WARN [main]
org.apache.catalina.core.StandardService.startInternal Starting service
[Catalina]
06-Mar-2018 10:23:08.998 WARN [main]
org.apache.catalina.core.StandardEngine.startInternal Starting Servlet
Engine: Apache Tomcat/9.0.5
06-Mar-2018 10:23:09.029 WARN [main]
org.apache.catalina.startup.HostConfig.deployDescriptor Deploying
configuration descriptor
[C:\java\apache-tomcat-9.0.5-catalina-base\conf\Catalina\localhost\manager.xml]
06-Mar-2018 10:23:09.668 WARN [main]
org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned
for TLDs yet contained no TLDs. Enable debug logging for this logger for a
complete list of JARs that were scanned but no TLDs were found in them.
Skipping unneeded JARs during scanning can improve startup time and JSP
compilation time.
06-Mar-2018 10:23:09.715 WARN [main]
org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of
configuration descriptor
[C:\java\apache-tomcat-9.0.5-catalina-base\conf\Catalina\localhost\manager.xml]
has finished in [686] ms
06-Mar-2018 10:23:09.715 WARN [main]
org.apache.catalina.startup.HostConfig.deployDescriptor Deploying
configuration descriptor
[C:\java\apache-tomcat-9.0.5-catalina-base\conf\Catalina\localhost\abc.xml]
06-Mar-2018 10:23:12.773 GRAVE [main]
org.apache.catalina.core.ContainerBase.addChildInternal
ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/abc]]
at
org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:441)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:740)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:716)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:703)
at
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:619)
at
org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1829)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at
java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
at
org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:530)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:429)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1575)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:308)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at
org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:964)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1425)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1415)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at
java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:682)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
Caused by: java.lang.ClassCastException:
org.apache.tomcat.dbcp.dbcp2.BasicDataSource cannot be cast to
javax.naming.Context
at
org.apache.catalina.core.NamingContextListener.createSubcontexts(NamingContextListener.java:1310)
at
org.apache.catalina.core.NamingContextListener.addResourceLink(NamingContextListener.java:1156)
at
org.apache.catalina.core.NamingContextListener.createNamingContext(NamingContextListener.java:655)
at
org.apache.catalina.core.NamingContextListener.lifecycleEvent(NamingContextListener.java:249)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4997)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 38 more
06-Mar-2018 10:23:12.898 GRAVE [main]
org.apache.catalina.startup.HostConfig.deployDescriptor Error deploying
configuration descriptor
[C:\java\apache-tomcat-9.0.5-catalina-base\conf\Catalina\localhost\abc.xml]
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/abc]]
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:744)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:716)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:703)
at
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:619)
at
org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1829)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at
java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
at
org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:530)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:429)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1575)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:308)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at
org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:964)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1425)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1415)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at
java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:682)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
06-Mar-2018 10:23:12.898 WARN [main]
org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of
configuration descriptor
[C:\java\apache-tomcat-9.0.5-catalina-base\conf\Catalina\localhost\abc.xml]
has finished in [3,183] ms
06-Mar-2018 10:23:12.898 WARN [main]
org.apache.catalina.startup.HostConfig.deployDescriptor Deploying
configuration descriptor
[C:\java\apache-tomcat-9.0.5-catalina-base\conf\Catalina\localhost\ROOT.xml]
06-Mar-2018 10:23:13.475 WARN [main]
org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned
for TLDs yet contained no TLDs. Enable debug logging for this logger for a
complete list of JARs that were scanned but no TLDs were found in them.
Skipping unneeded JARs during scanning can improve startup time and JSP
compilation time.
06-Mar-2018 10:23:13.475 WARN [main]
org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of
configuration descriptor
[C:\java\apache-tomcat-9.0.5-catalina-base\conf\Catalina\localhost\ROOT.xml]
has finished in [577] ms
06-Mar-2018 10:23:13.475 WARN [main]
org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler
["http-nio-8080"]
06-Mar-2018 10:23:13.490 WARN [main]
org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler
["ajp-nio-8009"]
06-Mar-2018 10:23:13.490 WARN [main]
org.apache.catalina.startup.Catalina.start Server startup in 4521 ms
## NOTES
The error seems realted only to ResourceLink's "name" attribute, and not to
"global" attribute, in server.xml:
ERROR
<ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
type="javax.sql.DataSource"/>
<ResourceLink global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abc/jkl"
type="javax.sql.DataSource"/>
The error disappears with the following "name" attribute values (of course
when I change the "name" attribute value I change accordingly the
"<res-ref-name>" tag body in the web.xml):
WORKS FINE
<ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
type="javax.sql.DataSource"/>
<ResourceLink global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abx/jkl"
type="javax.sql.DataSource"/>
WORKS FINE
<ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
type="javax.sql.DataSource"/>
<ResourceLink global="jdbc/abc/jkl/XXX_YYY" name="jdbc/axc/jkl"
type="javax.sql.DataSource"/>
WORKS FINE
<ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
type="javax.sql.DataSource"/>
<ResourceLink global="jdbc/abc/jkl/XXX_YYY" name="jdbc/xbc/jkl"
type="javax.sql.DataSource"/>
WORKS FINE
<ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
type="javax.sql.DataSource"/>
<ResourceLink global="jdbc/abc/jkl/XXX_YYY" name="jdbc/aabc/jkl"
type="javax.sql.DataSource"/>
WORKS FINE
<ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
type="javax.sql.DataSource"/>
<ResourceLink global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abcc/jkl"
type="javax.sql.DataSource"/>
Thank you very much for your help.
Best regards,
Tarin
www.taringamberini.com/en/blog
Re: Strange behavior on Tomcat 9.0.5 about ResourceLink's "name"
attribute in server.xml
Posted by Tarin Gamberini <ta...@jugpadova.it>.
On 08/03/2018 17:33, Christopher Schultz wrote:
> Tarin,
>
> On 3/8/18 11:26 AM, Tarin Gamberini wrote:
>> ## NOTES
>
>> The error seems realted only to ResourceLink's "name" attribute,
>> and not to "global" attribute, in server.xml:
>
>> ERROR <ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
>> type="javax.sql.DataSource"/> <ResourceLink
>> global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abc/jkl"
>> type="javax.sql.DataSource"/>
>
>> The error disappears with the following "name" attribute values (of
>> course when I change the "name" attribute value I change
>> accordingly the "<res-ref-name>" tag body in the web.xml):
>
>> WORKS FINE <ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
>> type="javax.sql.DataSource"/> <ResourceLink
>> global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abx/jkl"
>> type="javax.sql.DataSource"/>
>
> This looks like exactly the same as above (except for the likely type
> of 'x' -> 'c' in the second config). Am I missing something?
That's right, they differ only from a single character.
> -chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Kind regards,
Tarin
www.taringamberini.com/en/blog
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Strange behavior on Tomcat 9.0.5 about ResourceLink's "name"
attribute in server.xml
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Tarin,
On 3/8/18 11:26 AM, Tarin Gamberini wrote:
> ## NOTES
>
> The error seems realted only to ResourceLink's "name" attribute,
> and not to "global" attribute, in server.xml:
>
> ERROR <ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
> type="javax.sql.DataSource"/> <ResourceLink
> global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abc/jkl"
> type="javax.sql.DataSource"/>
>
> The error disappears with the following "name" attribute values (of
> course when I change the "name" attribute value I change
> accordingly the "<res-ref-name>" tag body in the web.xml):
>
> WORKS FINE <ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
> type="javax.sql.DataSource"/> <ResourceLink
> global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abx/jkl"
> type="javax.sql.DataSource"/>
This looks like exactly the same as above (except for the likely type
of 'x' -> 'c' in the second config). Am I missing something?
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQJRBAEBCAA7FiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlqhZeQdHGNocmlzQGNo
cmlzdG9waGVyc2NodWx0ei5uZXQACgkQHPApP6U8pFhsbg/+K7BIB3uSvj6UUq4+
HhebXBiSbrbw769wUK9YAmaLYsXU43TswRI5g05pSOZ6jQx4sR/z+GU6zPbeLapP
fC10BlzU3fPsHLWBZKb2pDisTcPS6uK/ByI30nqf2wESRmY3CJTyaGuEVfGYQ+Gg
Zb07KMEMVtEIFZaULhUrlLqgxBQ9kNC8jjutAQiEqArKa7LvdwuKQ66brwvSQMbL
c1Y4d+3cmYl78rLPrX82K4evwfWKheB1TYzA+oDmjYSJj95s3KWn1p2VEKH3bUG4
BJADrOweOvVv1IcrzcyCzArTqsntAickPZz/gLi5r1SaULggHoWs7Ci2dp6osynP
G+Wnj86DeIpA2eyK16vaZPPKTOLq5z5mfNKroF1d/L2vb0v/WpbYXk6bQpM3HFW4
zR8S3vFYuRHq8ES/Vubs9qhAmZtdJGK9HqTMCsLISZ2EKtsjlJApmFMA41iAknHw
jamg/uYT2FV8synobGU9Ikht5fMTg14NaQ0uztXEIO20YiP22bTvstYERqx35iUZ
nVs8eYoWEjlekbInHTXBdZ15AAN1TvAEqWQUX81WKRN4Jdqc1XoTMPSp8SELRpAw
US/4eUowux13KnKxfPkG54kDo454K5OATYVAZO5zrNYeIU7eVHXYT+05+e0jXIoC
fihQasr9cTp9P/IjTsQ2Ujd8bZU=
=+Iam
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Strange behavior on Tomcat 9.0.5 about ResourceLink's "name"
attribute in server.xml
Posted by Mark Thomas <ma...@apache.org>.
On 09/03/18 08:42, Tarin Gamberini wrote:
> On 8 March 2018 at 20:44, Christopher Schultz <ch...@christopherschultz.net>
> wrote:
>
>> [cut]
>> On 3/8/18 1:56 PM, Mark Thomas wrote:
>>> On 08/03/18 18:53, Tarin Gamberini wrote:
>>>> On 08/03/2018 17:52, Rémy Maucherat wrote:
>>>>> On Thu, Mar 8, 2018 at 5:26 PM, Tarin Gamberini
>>>>>> [cut] # PROBLEM
>>>>>>
>>>>>> I have two datasources in the same web application:
>>>>>>
>>>>>> <ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
>>>>>> type="javax.sql.DataSource"/> <ResourceLink
>>>>>> global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abc/jkl"
>>>>>> type="javax.sql.DataSource"/> [cut]
>>>>>
>>>>> Well, you have "abc" that s already bound and is a datasource,
>>>>> then you try to create a subcontext "abc" and it doesn't work.
>>>>>
>>>> Sorry, I'm not sure I have understood what you mean.
>> [cut]
>> each part has to have the expected type,
>> like this:
>>
>> comp:env -> context
>> java -> context
>> jdbc -> context
>> abc -> DataSource
>> [can't create a path below a DS]
>>
>> Hope that helps,
>>
> Yes, it have helped me a lot.
>
> I know about JNDI hierarchy but not about the type.
>
> Sorry for bothering you all, I'll review JNDI during this weekend.
No need to apologise. You asked a good (clear, well-written) question
and the community provided the answer. I learned something along the way
and I'm sure others did to. That is the mailing list worked exactly as
it is meant to.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Strange behavior on Tomcat 9.0.5 about ResourceLink's "name"
attribute in server.xml
Posted by Tarin Gamberini <ta...@gmail.com>.
On 8 March 2018 at 20:44, Christopher Schultz <ch...@christopherschultz.net>
wrote:
> [cut]
> On 3/8/18 1:56 PM, Mark Thomas wrote:
> > On 08/03/18 18:53, Tarin Gamberini wrote:
> >> On 08/03/2018 17:52, Rémy Maucherat wrote:
> >>> On Thu, Mar 8, 2018 at 5:26 PM, Tarin Gamberini
> >>>> [cut] # PROBLEM
> >>>>
> >>>> I have two datasources in the same web application:
> >>>>
> >>>> <ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
> >>>> type="javax.sql.DataSource"/> <ResourceLink
> >>>> global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abc/jkl"
> >>>> type="javax.sql.DataSource"/> [cut]
> >>>
> >>> Well, you have "abc" that s already bound and is a datasource,
> >>> then you try to create a subcontext "abc" and it doesn't work.
> >>>
> >> Sorry, I'm not sure I have understood what you mean.
> [cut]
> each part has to have the expected type,
> like this:
>
> comp:env -> context
> java -> context
> jdbc -> context
> abc -> DataSource
> [can't create a path below a DS]
>
> Hope that helps,
>
Yes, it have helped me a lot.
I know about JNDI hierarchy but not about the type.
Sorry for bothering you all, I'll review JNDI during this weekend.
> - -chris
> [cut]
Best regards,
Tarin
www.taringamberini.com/en/blog
Re: Strange behavior on Tomcat 9.0.5 about ResourceLink's "name"
attribute in server.xml
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Tarin,
On 3/8/18 1:56 PM, Mark Thomas wrote:
> On 08/03/18 18:53, Tarin Gamberini wrote:
>> On 08/03/2018 17:52, Rémy Maucherat wrote:
>>> On Thu, Mar 8, 2018 at 5:26 PM, Tarin Gamberini
>>>> [cut] # PROBLEM
>>>>
>>>> I have two datasources in the same web application:
>>>>
>>>> <ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
>>>> type="javax.sql.DataSource"/> <ResourceLink
>>>> global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abc/jkl"
>>>> type="javax.sql.DataSource"/> [cut]
>>>
>>> Well, you have "abc" that s already bound and is a datasource,
>>> then you try to create a subcontext "abc" and it doesn't work.
>>>
>> Sorry, I'm not sure I have understood what you mean. Just for
>> clarification:
>>
>> 1. By «you have "abc" that s already bound and is a datasource»
>> are you thinking about the "abc" just after "jdbc/" in
>> «global="jdbc/abc/ABC"» ?
>>
>> 2. By «then you try to create a subcontext "abc"» are you
>> thinking about the ending ABC in «global="jdbc/abc/ABC"» ?
>
> No. Look at the names, not the global names.
It might help to understand a bit about how JNDI works. It's very much
like a filesystem where you have directories and files. A particular
path name can either be a file or a directory, but not both.
For example, on a standard *NIX system, you can't have a file called
/etc because there needs to be an /etc directory with files in it.
In your case, you are first creating a DataSource (the analogy here is
a file) called "jdbc/abc", and then you are trying to create another
DataSource "inside" that path "jdbc/abc" called "jdbc/abd/ABC". In
order to create "jdbc/abc/ABC", the path "jdbc/abc" must be a
directory, not a file. (In JNDI, it must be a Context, but it's a
DataSource instead).
If you were thinking that the JNDI namespace was like a map of
full-paths -> objects:
comp:env/java/jdbc/abc -> DataSource
comp:env/java/jdbc/abc/ABC -> DataSource
It doesn't work that way. Instead, the / character actually separates
parts of the hierarchy and each part has to have the expected type,
like this:
comp:env -> context
java -> context
jdbc -> context
abc -> DataSource
[can't create a path below a DS]
Hope that helps,
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQJRBAEBCAA7FiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlqhkqQdHGNocmlzQGNo
cmlzdG9waGVyc2NodWx0ei5uZXQACgkQHPApP6U8pFhrTg/+Ie9oIxVnXmoufSO/
vb0kRtrdhPx4KVCqVbsU9imOPpgXD6aDIxdIHs0iIFCxuQTVsJ7duIa5n9Dd3MDp
zM9E17L/wIHvGTeiuwvb6a6OWgnX1MDS9HX3UC1X9dd11DKVpWDyOeywTPiSSUn5
DWtGPyjwThVRlvX6anOUZfcNWkoGxaB/3TSyA02n6eeuhCSNLQgJJLNddwIwJTDy
/EJs2/u3HBS1KrH0aRHyPmsPEdishgbXCqj3n+AKeE6jeJvNS3VSaWbtgZ+2EHto
0f1QDSwrfOd0LEx0tv8z9TuF3cyH4F8NObnK6p9s50ogZjnjLG9kPENKe6gNznEJ
QIjzrtSr4ba8gCrmQ9hnYO40p+fiwFpCFkg2LRMmhzWHsuEfifNogud3yEmqg4+L
7s/zpL5qz0NA+LypX2mPZZq7DW893icZbncn9e/z7krQVz9gn/ETi0ejhwMBsi8n
UVlGbc9HzsUBVHD/XVMPuX3INM/ycQZHfShKK4NIp7tea/K9xQADox4yBOMzKUFM
JHZc/uPePuGAKQcN7bZkGLtVZ8Jk5sjV8uA8uayb3kWF3wRF/EdwkoebXDBArmcd
dpSJOp6u7J3QdaR63Lx9QeI1GOqzJWDrH3KGqpoOmAw4sOXBROWdAl3VtpluonTE
ri5hYpkVOQvrO5svchLr8QLn+Og=
=70hm
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Strange behavior on Tomcat 9.0.5 about ResourceLink's "name"
attribute in server.xml
Posted by Tarin Gamberini <ta...@gmail.com>.
On 8 March 2018 at 19:56, Mark Thomas <ma...@apache.org> wrote:
> On 08/03/18 18:53, Tarin Gamberini wrote:
> > On 08/03/2018 17:52, Rémy Maucherat wrote:
> >> On Thu, Mar 8, 2018 at 5:26 PM, Tarin Gamberini
> >>> [cut]
> >>> # PROBLEM
> >>>
> >>> I have two datasources in the same web application:
> >>>
> >>> <ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
> >>> type="javax.sql.DataSource"/>
> >>> <ResourceLink global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abc/jkl"
> >>> type="javax.sql.DataSource"/>
> >>> [cut]
> >>
> >> Well, you have "abc" that s already bound and is a datasource, then you
> try
> >> to create a subcontext "abc" and it doesn't work.
> > Sorry, I'm not sure I have understood what you mean. Just for
> clarification:
> >
> > 1.
> > By «you have "abc" that s already bound and is a datasource» are you
> > thinking about the "abc" just after "jdbc/" in «global="jdbc/abc/ABC"» ?
> >
> > 2.
> > By «then you try to create a subcontext "abc"» are you thinking about
> > the ending ABC in «global="jdbc/abc/ABC"» ?
>
> No. Look at the names, not the global names.
> Mark
I have understood, thanks for clarifying it.
Best regards,
Tarin
www.taringamberini.com/en/blog
Re: Strange behavior on Tomcat 9.0.5 about ResourceLink's "name"
attribute in server.xml
Posted by Mark Thomas <ma...@apache.org>.
On 08/03/18 18:53, Tarin Gamberini wrote:
> On 08/03/2018 17:52, Rémy Maucherat wrote:
>> On Thu, Mar 8, 2018 at 5:26 PM, Tarin Gamberini
>>> [cut]
>>> # PROBLEM
>>>
>>> I have two datasources in the same web application:
>>>
>>> <ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
>>> type="javax.sql.DataSource"/>
>>> <ResourceLink global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abc/jkl"
>>> type="javax.sql.DataSource"/>
>>> [cut]
>>
>> Well, you have "abc" that s already bound and is a datasource, then you try
>> to create a subcontext "abc" and it doesn't work.
> Sorry, I'm not sure I have understood what you mean. Just for clarification:
>
> 1.
> By «you have "abc" that s already bound and is a datasource» are you
> thinking about the "abc" just after "jdbc/" in «global="jdbc/abc/ABC"» ?
>
> 2.
> By «then you try to create a subcontext "abc"» are you thinking about
> the ending ABC in «global="jdbc/abc/ABC"» ?
No. Look at the names, not the global names.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Strange behavior on Tomcat 9.0.5 about ResourceLink's "name"
attribute in server.xml
Posted by Tarin Gamberini <ta...@gmail.com>.
On 08/03/2018 17:52, Rémy Maucherat wrote:
> On Thu, Mar 8, 2018 at 5:26 PM, Tarin Gamberini
>> [cut]
>> # PROBLEM
>>
>> I have two datasources in the same web application:
>>
>> <ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
>> type="javax.sql.DataSource"/>
>> <ResourceLink global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abc/jkl"
>> type="javax.sql.DataSource"/>
>>[cut]
>
> Well, you have "abc" that s already bound and is a datasource, then you try
> to create a subcontext "abc" and it doesn't work.
Sorry, I'm not sure I have understood what you mean. Just for clarification:
1.
By «you have "abc" that s already bound and is a datasource» are you
thinking about the "abc" just after "jdbc/" in «global="jdbc/abc/ABC"» ?
2.
By «then you try to create a subcontext "abc"» are you thinking about
the ending ABC in «global="jdbc/abc/ABC"» ?
> Try using better paths
> instead so that "abc" doesn't have to be both a subcontext and a datasource.
To get things works I have already used a different path, something like
the once tagged with "WORKS FINE" in the ending note of the original email.
Trying to rephrasing the problem: Am I wrong asking Tomcat to understand
JNDI name with subcontext for datasources, or should Tomcat accept
global/name attributes values with subcontext?
> Rémy
>
Thank you in advance for your kind help.
Tarin
www.taringamberini.com/en/blog
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Strange behavior on Tomcat 9.0.5 about ResourceLink's "name"
attribute in server.xml
Posted by Rémy Maucherat <re...@apache.org>.
On Thu, Mar 8, 2018 at 5:26 PM, Tarin Gamberini <ta...@gmail.com>
wrote:
> Hi everybody,
>
> I have found a strange behavior on Tomcat 9.0.5 (originally on Tomcat
> 8.5.28).
>
>
> # PROBLEM
>
> I have two datasources in the same web application:
>
> <ResourceLink global="jdbc/abc/ABC" name="jdbc/abc"
> type="javax.sql.DataSource"/>
> <ResourceLink global="jdbc/abc/jkl/XXX_YYY" name="jdbc/abc/jkl"
> type="javax.sql.DataSource"/>
>
> Starting the server I get an "java.lang.ClassCastException:
> org.apache.tomcat.dbcp.dbcp2.BasicDataSource cannot be cast to
> javax.naming.Context" ERROR.
>
Well, you have "abc" that s already bound and is a datasource, then you try
to create a subcontext "abc" and it doesn't work. Try using better paths
instead so that "abc" doesn't have to be both a subcontext and a datasource.
Rémy