You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Eugeny N Dzhurinsky <eu...@jdevelop.com> on 2006/02/22 14:58:45 UTC

JNDI resource configuration (Tomcat 5.0)

I seem to miss something - I configured JNDI resource in context like this

<Context path="/myapp">
    <Realm className="org.apache.catalina.realm.JAASRealm" appName="PortalRealm"
    userClassNames="com.liferay.portal.jaas.PortalPrincipal"
    roleClassNames="com.liferay.portal.jaas.PortalRole" debug="99"
    useContextClassLoader="false" />
    <Resource name="jdbc/DBConn" auth="Container" type="javax.sql.DataSource" />
    <ResourceParams name="jdbc/DBConn">
        <parameter>
            <name>factory</name>
            <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
        </parameter>

        <parameter>
            <name>username</name>
            <value>root</value>
        </parameter>

        <parameter>
            <name>password</name>
            <value>
            </value>
        </parameter>

        <parameter>
            <name>driverClassName</name>
            <value>org.gjt.mm.mysql.Driver</value>
        </parameter>

        <parameter>
            <name>url</name>
            <value>jdbc:mysql://localhost/database</value>
        </parameter>
    </ResourceParams>
</Context>

in iBATIS I configured mapping.xml to use it

<transactionManager type="JDBC">
    <dataSource type="JNDI">
	<property name="DataSource" value="java:jdbc/DevCase" />
    </dataSource>
</transactionManager>

but application complains about it can't find 'jdbc' resource. Any
suggestions?

-- 
Eugene N Dzhurinsky

Re: JNDI resource configuration (Tomcat 5.0)

Posted by Ben Munat <be...@munat.com>.
Yeah... I remember having to do this when I used JBoss 3.26...

b

Jeff Butler wrote:
> The "java:comp/env" prefix is part of the J2EE specification - so it's 
> not Tomcat or iBATIS specific.  But Tomcat JNDI works a little different 
> than other app servers.  With most app servers, the "java:comp/env" 
> prefix gets added when resource references are defined in web.xml or 
> ejb-jar.xml.
>  
> Jeff Butler
> 
> 
>  
> On 2/22/06, *Eugeny N Dzhurinsky* <eugenydzh@jdevelop.com 
> <ma...@jdevelop.com>> wrote:
> 
>     On Wed, Feb 22, 2006 at 03:37:26PM +0100, Cimballi wrote:
>      > This a Tomcat specific prefix, not iBatis.
>      > Cimballi
> 
>     Well, I'm not sure about that, because I'm using OSWorkflow and it uses
>     another JNDI resource, specified like this:
> 
>     <propertysets>
>        <propertyset name="jdbc"
>        class="
>     com.merrimacind.devcase.devCase.workflow.storage.JDBCStoragePropertySetWrapper">
>            <arg name="datasource" value="jdbc/DefaultDS" />
> 
>            <arg name=" table.name <http://table.name>"
>     value="OS_PROPERTYENTRY" />
> 
>            <arg name="col.globalKey" value="GLOBAL_KEY" />
> 
>            <arg name="col.itemKey" value="ITEM_KEY" />
> 
>            <arg name="col.itemType" value="ITEM_TYPE" />
> 
>            <arg name="col.string" value="STRING_VALUE" />
> 
>            <arg name="col.date" value="DATE_VALUE" />
> 
>            <arg name="col.data" value="DATA_VALUE" />
> 
>            <arg name="col.float" value="FLOAT_VALUE" />
> 
>            <arg name="col.number" value="NUMBER_VALUE" />
>        </propertyset>
> 
>        <propertyset name="memory"
>       
>     class="com.opensymphony.module.propertyset.memory.MemoryPropertySet" />
>     </propertysets>
> 
>     no comp/env or whatever, and OSWorkflow isn't tomcat-related
>     application.
> 
>     --
>     Eugene N Dzhurinsky
> 
> 

Re: JNDI resource configuration (Tomcat 5.0)

Posted by Cimballi <ci...@gmail.com>.
Thanks for correcting me ;-)

Cimballi


On 2/22/06, Jeff Butler <je...@gmail.com> wrote:
> The "java:comp/env" prefix is part of the J2EE specification - so it's not
> Tomcat or iBATIS specific.  But Tomcat JNDI works a little different than
> other app servers.  With most app servers, the "java:comp/env" prefix gets
> added when resource references are defined in web.xml or ejb-jar.xml.
>
> Jeff Butler

Re: JNDI resource configuration (Tomcat 5.0)

Posted by Jeff Butler <je...@gmail.com>.
The "java:comp/env" prefix is part of the J2EE specification - so it's not
Tomcat or iBATIS specific.  But Tomcat JNDI works a little different than
other app servers.  With most app servers, the "java:comp/env" prefix gets
added when resource references are defined in web.xml or ejb-jar.xml.

Jeff Butler



On 2/22/06, Eugeny N Dzhurinsky <eu...@jdevelop.com> wrote:
>
> On Wed, Feb 22, 2006 at 03:37:26PM +0100, Cimballi wrote:
> > This a Tomcat specific prefix, not iBatis.
> > Cimballi
>
> Well, I'm not sure about that, because I'm using OSWorkflow and it uses
> another JNDI resource, specified like this:
>
> <propertysets>
>    <propertyset name="jdbc"
>    class="
> com.merrimacind.devcase.devCase.workflow.storage.JDBCStoragePropertySetWrapper
> ">
>        <arg name="datasource" value="jdbc/DefaultDS" />
>
>        <arg name="table.name" value="OS_PROPERTYENTRY" />
>
>        <arg name="col.globalKey" value="GLOBAL_KEY" />
>
>        <arg name="col.itemKey" value="ITEM_KEY" />
>
>        <arg name="col.itemType" value="ITEM_TYPE" />
>
>        <arg name="col.string" value="STRING_VALUE" />
>
>        <arg name="col.date" value="DATE_VALUE" />
>
>        <arg name="col.data" value="DATA_VALUE" />
>
>        <arg name="col.float" value="FLOAT_VALUE" />
>
>        <arg name="col.number" value="NUMBER_VALUE" />
>    </propertyset>
>
>    <propertyset name="memory"
>    class="com.opensymphony.module.propertyset.memory.MemoryPropertySet" />
> </propertysets>
>
> no comp/env or whatever, and OSWorkflow isn't tomcat-related application.
>
> --
> Eugene N Dzhurinsky
>

Re: JNDI resource configuration (Tomcat 5.0)

Posted by Cimballi <ci...@cimballi.net>.
Each components chooses its "root" namespace. In Tomcat "All
configured entries and resources are placed in the java:comp/env
portion of the JNDI namespace" :

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

Other components can choose a different "root" namespace, like OSWorkflow.

Cimballi


On 2/22/06, Eugeny N Dzhurinsky <eu...@jdevelop.com> wrote:
> On Wed, Feb 22, 2006 at 03:37:26PM +0100, Cimballi wrote:
> > This a Tomcat specific prefix, not iBatis.
> > Cimballi
>
> Well, I'm not sure about that, because I'm using OSWorkflow and it uses
> another JNDI resource, specified like this:
>
> <propertysets>
>     <propertyset name="jdbc"
>     class="com.merrimacind.devcase.devCase.workflow.storage.JDBCStoragePropertySetWrapper">
>         <arg name="datasource" value="jdbc/DefaultDS" />
>
>         <arg name="table.name" value="OS_PROPERTYENTRY" />
>
>         <arg name="col.globalKey" value="GLOBAL_KEY" />
>
>         <arg name="col.itemKey" value="ITEM_KEY" />
>
>         <arg name="col.itemType" value="ITEM_TYPE" />
>
>         <arg name="col.string" value="STRING_VALUE" />
>
>         <arg name="col.date" value="DATE_VALUE" />
>
>         <arg name="col.data" value="DATA_VALUE" />
>
>         <arg name="col.float" value="FLOAT_VALUE" />
>
>         <arg name="col.number" value="NUMBER_VALUE" />
>     </propertyset>
>
>     <propertyset name="memory"
>     class="com.opensymphony.module.propertyset.memory.MemoryPropertySet" />
> </propertysets>
>
> no comp/env or whatever, and OSWorkflow isn't tomcat-related application.
>
> --
> Eugene N Dzhurinsky
>

Re: JNDI resource configuration (Tomcat 5.0)

Posted by Eugeny N Dzhurinsky <eu...@jdevelop.com>.
On Wed, Feb 22, 2006 at 03:37:26PM +0100, Cimballi wrote:
> This a Tomcat specific prefix, not iBatis.
> Cimballi

Well, I'm not sure about that, because I'm using OSWorkflow and it uses
another JNDI resource, specified like this:

<propertysets>
    <propertyset name="jdbc"
    class="com.merrimacind.devcase.devCase.workflow.storage.JDBCStoragePropertySetWrapper">
        <arg name="datasource" value="jdbc/DefaultDS" />

        <arg name="table.name" value="OS_PROPERTYENTRY" />

        <arg name="col.globalKey" value="GLOBAL_KEY" />

        <arg name="col.itemKey" value="ITEM_KEY" />

        <arg name="col.itemType" value="ITEM_TYPE" />

        <arg name="col.string" value="STRING_VALUE" />

        <arg name="col.date" value="DATE_VALUE" />

        <arg name="col.data" value="DATA_VALUE" />

        <arg name="col.float" value="FLOAT_VALUE" />

        <arg name="col.number" value="NUMBER_VALUE" />
    </propertyset>

    <propertyset name="memory"
    class="com.opensymphony.module.propertyset.memory.MemoryPropertySet" />
</propertysets>

no comp/env or whatever, and OSWorkflow isn't tomcat-related application.

-- 
Eugene N Dzhurinsky

Re: JNDI resource configuration (Tomcat 5.0)

Posted by Cimballi <ci...@gmail.com>.
This a Tomcat specific prefix, not iBatis.

Cimballi


On 2/22/06, Eugeny N Dzhurinsky <eu...@jdevelop.com> wrote:
> On Wed, Feb 22, 2006 at 08:26:22AM -0600, Jeff Butler wrote:
> > Try this:
> >  <property name="DataSource" value="java:comp/env/jdbc/DBConn" />
>
> that seem to work... Strange, so I should add prefix /comp/env ? May be there
> are some other common prefixes for iBATIS not described in documentation? =)
>
> --
> Eugene N Dzhurinsky
>

Re: JNDI resource configuration (Tomcat 5.0)

Posted by Eugeny N Dzhurinsky <eu...@jdevelop.com>.
On Wed, Feb 22, 2006 at 08:26:22AM -0600, Jeff Butler wrote:
> Try this:
>  <property name="DataSource" value="java:comp/env/jdbc/DBConn" />

that seem to work... Strange, so I should add prefix /comp/env ? May be there
are some other common prefixes for iBATIS not described in documentation? =)

-- 
Eugene N Dzhurinsky

Re: JNDI resource configuration (Tomcat 5.0)

Posted by Jeff Butler <je...@gmail.com>.
Try this:

 <property name="DataSource" value="java:comp/env/jdbc/DBConn" />

Jeff Butler


On 2/22/06, Eugeny N Dzhurinsky <eu...@jdevelop.com> wrote:
>
> I seem to miss something - I configured JNDI resource in context like this
>
> <Context path="/myapp">
>    <Realm className="org.apache.catalina.realm.JAASRealm"
> appName="PortalRealm"
>    userClassNames="com.liferay.portal.jaas.PortalPrincipal"
>    roleClassNames="com.liferay.portal.jaas.PortalRole" debug="99"
>    useContextClassLoader="false" />
>    <Resource name="jdbc/DBConn" auth="Container" type="
> javax.sql.DataSource" />
>    <ResourceParams name="jdbc/DBConn">
>        <parameter>
>            <name>factory</name>
>            <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>        </parameter>
>
>        <parameter>
>            <name>username</name>
>            <value>root</value>
>        </parameter>
>
>        <parameter>
>            <name>password</name>
>            <value>
>            </value>
>        </parameter>
>
>        <parameter>
>            <name>driverClassName</name>
>            <value>org.gjt.mm.mysql.Driver</value>
>        </parameter>
>
>        <parameter>
>            <name>url</name>
>            <value>jdbc:mysql://localhost/database</value>
>        </parameter>
>    </ResourceParams>
> </Context>
>
> in iBATIS I configured mapping.xml to use it
>
> <transactionManager type="JDBC">
>    <dataSource type="JNDI">
>        <property name="DataSource" value="java:jdbc/DevCase" />
>    </dataSource>
> </transactionManager>
>
> but application complains about it can't find 'jdbc' resource. Any
> suggestions?
>
> --
> Eugene N Dzhurinsky
>

Exception trace

Posted by Eugeny N Dzhurinsky <eu...@jdevelop.com>.
exception is

ERROR 22/07/06 02:07:51 [http-8280-Processor24] (DevCasePortlet:75) - java.lang.RuntimeException: Error initializing class. Cause: com.ibatis.common.exception.NestedRuntimeException: Error occurred.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMapConfig/transactionManager/dataSource/end()'.  Cause: com.ibatis.sqlmap.client.SqlMapException: There was an error configuring JndiDataSourceDaoTransactionPool. Cause: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
Caused by: com.ibatis.sqlmap.client.SqlMapException: There was an error configuring JndiDataSourceDaoTransactionPool. Cause: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
Caused by: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMapConfig/transactionManager/dataSource/end()'.  Cause: com.ibatis.sqlmap.client.SqlMapException: There was an error configuring JndiDataSourceDaoTransactionPool. Cause: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
Caused by: com.ibatis.sqlmap.client.SqlMapException: There was an error configuring JndiDataSourceDaoTransactionPool. Cause: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMapConfig/transactionManager/dataSource/end()'.  Cause: com.ibatis.sqlmap.client.SqlMapException: There was an error configuring JndiDataSourceDaoTransactionPool. Cause: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
...
-- 
Eugene N Dzhurinsky