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 "Yee, Richard K, CTR,, DMDCWEST" <Ri...@osd.pentagon.mil> on 2005/09/28 01:19:21 UTC
iBatis in a standalone (JUnit) application - NoInitialContext err
or
Hi,
I'm trying to use iBatis DAO in a standalone Java class but am getting a
JNDI NoInitialContext error when I try to configure the DaoManager. I am
using a SIMPLE datasource and am specifying the username, driver, etc. This
is the error:
Exception in constructor: testGetPcmFacility
(com.ibatis.dao.client.DaoException: Error while configuring DaoManager.
Cause: com.ibatis.dao.client.DaoException: There was an error configuring
the DataSource from JNDI.
Cause: javax.naming.NoInitialContextException: Need to specify class name
in environment or system property, or as an applet parameter, or in an
application resource
file: java.naming.factory.initial
Caused by: javax.naming.NoInitialContextException: Need to specify class
name in environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
Caused by: com.ibatis.dao.client.DaoException: There was an error
configuring the DataSource from JNDI.
Cause: javax.naming.NoInitialContextException: Need to specify class name
in environment or system property, or as an applet parameter, or in an
application resource
file: java.naming.factory.initial
Caused by: javax.naming.NoInitialContextException: Need to specify class
name in environment
Any idea which class name I need to specify and what the property name is?
Thanks,
Richard
Problem Solved: Re: iBatis in a standalone (JUnit) application -
NoInitialContext err
Posted by Richard Yee <ry...@cruzio.com>.
Michael,
You are absolutely right. I did have an entry for JNDI. I added the
context for the standalone unit test application in my web application's
dao.xml. I'll try using a separate configuration file for my unit test
application.
Thanks,
Richard
Michael Campbell wrote:
> On 9/27/05, Richard Yee <ry...@cruzio.com> wrote:
>
>> Michael,
>> thanks for replying. However, no, we are not using Spring. Just a class
>> that extends JUnit TestCase.
>>
>
>
> Are you ABSOLUTELY sure you don't have another config file out there
> with JNDI listed? I don't know what it defaults to if it can't find
> ANY config, so also check that it's finding the file you think it is.
>
>
>
>
Re: iBatis in a standalone (JUnit) application - NoInitialContext
err or
Posted by Richard Yee <ry...@cruzio.com>.
Michael,
thanks for replying. However, no, we are not using Spring. Just a class
that extends JUnit TestCase.
-Richard
Michael Campbell wrote:
> On 9/27/05, Yee, Richard K, CTR,, DMDCWEST
> <Ri...@osd.pentagon.mil> wrote:
>
>> Hi,
>> I'm trying to use iBatis DAO in a standalone Java class but am getting a
>> JNDI NoInitialContext error when I try to configure the DaoManager. I am
>> using a SIMPLE datasource and am specifying the username, driver, etc. This
>> is the error:
>>
>
>
> Are you using spring integration?
>
> --
> I tend to view "truly flexible" by another term: "Make everything
> equally hard". -- DHH
>
>
>
>
\
Re: iBatis in a standalone (JUnit) application - NoInitialContext err or
Posted by Michael Campbell <mi...@gmail.com>.
On 9/27/05, Yee, Richard K, CTR,, DMDCWEST
<Ri...@osd.pentagon.mil> wrote:
> Hi,
> I'm trying to use iBatis DAO in a standalone Java class but am getting a
> JNDI NoInitialContext error when I try to configure the DaoManager. I am
> using a SIMPLE datasource and am specifying the username, driver, etc. This
> is the error:
Are you using spring integration?
--
I tend to view "truly flexible" by another term: "Make everything
equally hard". -- DHH
Re: iBatis in a standalone (JUnit) application - NoInitialContext
err or
Posted by Richard Yee <ry...@cruzio.com>.
Now that I read Michael Campbell's email I understand the problem, my
actual dao.xml file is this:
<!DOCTYPE daoConfig
PUBLIC "-//iBATIS.com//DTD DAO Configuration 2.0//EN"
"http://www.ibatis.com/dtd/dao-2.dtd">
<daoConfig>
<context>
<transactionManager type="JDBC">
<property name="DataSource" value="JNDI"/>
<property name="DBJndiContext" value="jdbc/xxxxxxxxPooledDS"/>
<property name="JDBC.DefaultAutoCommit" value="true" />
</transactionManager>
<dao interface="mil.osd.dmdc.deers.web.bwe.dao.IControlTableDao"
implementation="mil.osd.dmdc.deers.web.bwe.dao.jdbc.ControlTableDao"/>
</context>
<context>
<transactionManager type="JDBC">
<property name="DataSource" value="SIMPLE"/>
<property name="JDBC.Driver" value="oracle.jdbc.OracleDriver"/>
<property name="JDBC.ConnectionURL"
value="jdbc:oracle:thin:@xxx:1521:xxxt"/>
<property name="JDBC.Username" value="xxx"/>
<property name="JDBC.Password" value="xxxxx"/>
<property name="JDBC.DefaultAutoCommit" value="true" />
</transactionManager>
<dao interface="mil.osd.dmdc.deers.web.bwe.dao.IPlanManagerDao"
implementation="mil.osd.dmdc.deers.web.bwe.dao.jdbc.PlanManagerDao"/>
</context>
</daoConfig>
I had both a JNDI and non-JNDI datasource in the same file so that when
I ran standalone, the JNDI datasource caused the DaoException. By
separating the two into two separate files, I should be able to run
iBATIS in a standalone unit test for my web application.
Thanks Nathan and Michael.
-Richard
Richard Yee wrote:
> Nathan,
> Thanks for responding. Here is the file that I use to configure the
> DaoManager.
>
> <!DOCTYPE daoConfig
> PUBLIC "-//iBATIS.com//DTD DAO Configuration 2.0//EN"
> "http://www.ibatis.com/dtd/dao-2.dtd">
> <daoConfig>
> <context>
> <transactionManager type="JDBC">
> <property name="DataSource" value="SIMPLE"/>
> <property name="JDBC.Driver" value="oracle.jdbc.OracleDriver"/>
> <property name="JDBC.ConnectionURL"
> value="jdbc:oracle:thin:@myhost:1521:mysid"/>
> <property name="JDBC.Username" value="user"/>
> <property name="JDBC.Password" value="pass"/>
> <property name="JDBC.DefaultAutoCommit" value="true" />
> </transactionManager>
> <dao interface="mil.osd.dmdc.deers.web.bwe.dao.IPlanManagerDao"
>
> implementation="mil.osd.dmdc.deers.web.bwe.dao.jdbc.PlanManagerDao"/>
> </context>
> </daoConfig>
>
> Is an App Server needed to run iBATIS?
>
> -Richard
>
> Nathan Maves wrote:
>> Well I am just guessing here but it appears that you have set up your
>> datasource as a jndi lookup.
>>
>> We really need to see your config file to give a better solution.
>>
>> Nathan
>>
>> On Sep 27, 2005, at 5:19 PM, Yee, Richard K, CTR,, DMDCWEST wrote:
>>
>>> Hi,
>>> I'm trying to use iBatis DAO in a standalone Java class but am
>>> getting a
>>> JNDI NoInitialContext error when I try to configure the DaoManager.
>>> I am
>>> using a SIMPLE datasource and am specifying the username, driver,
>>> etc. This
>>> is the error:
>>>
>>> Exception in constructor: testGetPcmFacility
>>> (com.ibatis.dao.client.DaoException: Error while configuring
>>> DaoManager.
>>> Cause: com.ibatis.dao.client.DaoException: There was an error
>>> configuring
>>> the DataSource from JNDI.
>>> Cause: javax.naming.NoInitialContextException: Need to specify
>>> class name
>>> in environment or system property, or as an applet parameter, or in an
>>> application resource
>>> file: java.naming.factory.initial
>>> Caused by: javax.naming.NoInitialContextException: Need to specify
>>> class
>>> name in environment or system property, or as an applet parameter,
>>> or in an
>>> application resource file: java.naming.factory.initial
>>> Caused by: com.ibatis.dao.client.DaoException: There was an error
>>> configuring the DataSource from JNDI.
>>> Cause: javax.naming.NoInitialContextException: Need to specify
>>> class name
>>> in environment or system property, or as an applet parameter, or in an
>>> application resource
>>> file: java.naming.factory.initial
>>> Caused by: javax.naming.NoInitialContextException: Need to specify
>>> class
>>> name in environment
>>>
>>>
>>> Any idea which class name I need to specify and what the property
>>> name is?
>>>
>>> Thanks,
>>>
>>> Richard
>>>
>>>
>>
>>
>>
>
>
>
>
Re: iBatis in a standalone (JUnit) application - NoInitialContext
err or
Posted by Richard Yee <ry...@cruzio.com>.
Nathan,
Thanks for responding. Here is the file that I use to configure the
DaoManager.
<!DOCTYPE daoConfig
PUBLIC "-//iBATIS.com//DTD DAO Configuration 2.0//EN"
"http://www.ibatis.com/dtd/dao-2.dtd">
<daoConfig>
<context>
<transactionManager type="JDBC">
<property name="DataSource" value="SIMPLE"/>
<property name="JDBC.Driver" value="oracle.jdbc.OracleDriver"/>
<property name="JDBC.ConnectionURL"
value="jdbc:oracle:thin:@myhost:1521:mysid"/>
<property name="JDBC.Username" value="user"/>
<property name="JDBC.Password" value="pass"/>
<property name="JDBC.DefaultAutoCommit" value="true" />
</transactionManager>
<dao interface="mil.osd.dmdc.deers.web.bwe.dao.IPlanManagerDao"
implementation="mil.osd.dmdc.deers.web.bwe.dao.jdbc.PlanManagerDao"/>
</context>
</daoConfig>
Is an App Server needed to run iBATIS?
-Richard
Nathan Maves wrote:
> Well I am just guessing here but it appears that you have set up your
> datasource as a jndi lookup.
>
> We really need to see your config file to give a better solution.
>
> Nathan
>
> On Sep 27, 2005, at 5:19 PM, Yee, Richard K, CTR,, DMDCWEST wrote:
>
>> Hi,
>> I'm trying to use iBatis DAO in a standalone Java class but am getting a
>> JNDI NoInitialContext error when I try to configure the DaoManager. I am
>> using a SIMPLE datasource and am specifying the username, driver,
>> etc. This
>> is the error:
>>
>> Exception in constructor: testGetPcmFacility
>> (com.ibatis.dao.client.DaoException: Error while configuring DaoManager.
>> Cause: com.ibatis.dao.client.DaoException: There was an error
>> configuring
>> the DataSource from JNDI.
>> Cause: javax.naming.NoInitialContextException: Need to specify
>> class name
>> in environment or system property, or as an applet parameter, or in an
>> application resource
>> file: java.naming.factory.initial
>> Caused by: javax.naming.NoInitialContextException: Need to specify class
>> name in environment or system property, or as an applet parameter, or
>> in an
>> application resource file: java.naming.factory.initial
>> Caused by: com.ibatis.dao.client.DaoException: There was an error
>> configuring the DataSource from JNDI.
>> Cause: javax.naming.NoInitialContextException: Need to specify
>> class name
>> in environment or system property, or as an applet parameter, or in an
>> application resource
>> file: java.naming.factory.initial
>> Caused by: javax.naming.NoInitialContextException: Need to specify class
>> name in environment
>>
>>
>> Any idea which class name I need to specify and what the property
>> name is?
>>
>> Thanks,
>>
>> Richard
>>
>>
>
>
>
Re: iBatis in a standalone (JUnit) application - NoInitialContext err
or
Posted by Nathan Maves <Na...@Sun.COM>.
Well I am just guessing here but it appears that you have set up your
datasource as a jndi lookup.
We really need to see your config file to give a better solution.
Nathan
On Sep 27, 2005, at 5:19 PM, Yee, Richard K, CTR,, DMDCWEST wrote:
> Hi,
> I'm trying to use iBatis DAO in a standalone Java class but am
> getting a
> JNDI NoInitialContext error when I try to configure the DaoManager.
> I am
> using a SIMPLE datasource and am specifying the username, driver,
> etc. This
> is the error:
>
> Exception in constructor: testGetPcmFacility
> (com.ibatis.dao.client.DaoException: Error while configuring
> DaoManager.
> Cause: com.ibatis.dao.client.DaoException: There was an error
> configuring
> the DataSource from JNDI.
> Cause: javax.naming.NoInitialContextException: Need to specify
> class name
> in environment or system property, or as an applet parameter, or in an
> application resource
> file: java.naming.factory.initial
> Caused by: javax.naming.NoInitialContextException: Need to specify
> class
> name in environment or system property, or as an applet parameter,
> or in an
> application resource file: java.naming.factory.initial
> Caused by: com.ibatis.dao.client.DaoException: There was an error
> configuring the DataSource from JNDI.
> Cause: javax.naming.NoInitialContextException: Need to specify
> class name
> in environment or system property, or as an applet parameter, or in an
> application resource
> file: java.naming.factory.initial
> Caused by: javax.naming.NoInitialContextException: Need to specify
> class
> name in environment
>
>
> Any idea which class name I need to specify and what the property
> name is?
>
> Thanks,
>
> Richard
>
>