You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jakub 1983 <jj...@gmail.com> on 2013/04/18 00:40:57 UTC

context.xml.Resource and web.xml.resource-ref

such scenario works fine for me:

jdbc.xml in C:\test\catalina_base\conf\Catalina\localhost

<Context >
    <Resource name="jdbc/Test" auth="Container" type="javax.sql.DataSource"
        username="sa" password="" driverClassName="org.h2.Driver"
        url="jdbc:h2:tcp://localhost/databases/test1"
        maxActive="3"
        removeAbandoned="true"
        removeAbandonedTimeout="20"
            logAbandoned="true"

    />
</Context>

web.xml:
    <resource-ref>
        <description></description>
        <res-ref-name>jdbc/Test</res-ref-name>
<!--
        <jndi-name>jdbc/TestChanged</jndi-name>
-->
        <res-type> javax.sql.DataSource </res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

but fails when I change    Resource name="jdbc/Test" in jbc.xml to Resource
name="jdbc/TestChanged"
what should I do, to be able to still call it jdbc/Test in my jdbc.war ?
I thought that I should uncomment <jndi-name>jdbc/TestChanged</jndi-name>
in web.xml_resource-ref but it doesn't work.

How should I configure it ?

what are differences/similarities and dependencies between
<Environment name...
<Resource name=...
<ResourceLink name=...
from context.xml and
<resource-ref>
<resource-ref-link>
from web.xml ?

now I get stack trace in browser:
org.apache.jasper.JasperException: javax.servlet.ServletException:
javax.naming.NameNotFoundException: Name [Test] is not bound in this
Context. Unable to find [Test].

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

root cause

javax.servlet.ServletException: javax.naming.NameNotFoundException: Name
[Test] is not bound in this Context. Unable to find [Test].

org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:912)

org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
    org.apache.jsp.select_jsp._jspService(select_jsp.java:135)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

root cause ...

Regards
Jakub

Re: context.xml.Resource and web.xml.resource-ref

Posted by Mark Thomas <ma...@apache.org>.
On 17/04/2013 23:40, Jakub 1983 wrote:
> what are differences/similarities and dependencies between
> <Environment name...
> <Resource name=...
> <ResourceLink name=...
> from context.xml and
> <resource-ref>
> <resource-ref-link>
> from web.xml ?

http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org