ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Meadors <larry.mead...@gmail.com>
Subject Re: Is this possible in iBatis?
Date Wed, 26 Jan 2005 12:53:17 GMT
Yes, the properties element will let you use either a resource or a
URL as the location of the properties file.

A resource is loaded from the class loader and as such, needs to be on
the class path. In a web application, you could put it in a jar in
your WEB-INF/lib directory, or in a directory in WEB-INF/classes, and
the class loader will find it. Resource examples include
"com/company/system/config/ibatis.propertes" or just simple
"ibatis.properties" instead.

A URL is loaded with the URLConnection class, so any URL that Java is
aware of will work in iBATIS. For example,
"jar:file:/somedir/config.jar!/ibatis-dev.properties". If you really
had a need, you could even use
"http://somehost/config/somefile.properties", and iBATIS would
dutifully load the properties from that URL.

You need to find the appropriate URL, and it will work.

Larry

On Tue, 25 Jan 2005 12:57:28 -0000, Adrian Harrison
<adrianharrison_uk@yahoo.co.uk> wrote:
> I have an EAR (PRDApp) containing several EJB's & a single WAR file.
> 
> I have a prd.system.properties file that currently contains the data source
> name iBatis use's to get a connection from a Weblogic connection pool.
> 
> i.e
> 
> datasourcename=PRDDataSource
> 
> So my sql-map-config.xml file looks something like this -
> 
>         <sqlMapConfig>
> 
>                 <properties resource = "prd.system.properties" />
> 
>                 .
>                 .
>                 <transactionManager type="EXTERNAL">
>                         <dataSource type="JNDI">
>                                 <property name="DBFullJndiContext"
> value="${datasourcename}"/>
>                         </dataSource>
>                 </transactionManager>
> 
> This works fine but I want to use this file to contain other settings used
> by other modules. So I've placed it in the App directory but changing the
> line to -
> 
>         <properties resource = "./applications/PRDApp/system.properties" />
> 
> but this produces -
> 
>         javax.ejb.EJBException: Error in ejbCreate::
> java.lang.ExceptionInInitializerError
>         .
>         Caused by: java.lang.RuntimeException: Could not initialize
> DaoConfig.  Cause:      com.ibatis.dao.client.DaoException: Error while
> configuring DaoManager.  Cause:
> com.ibatis.sqlmap.client.SqlMapException: There was an error while building
> the SqlMap instance.
>         --- The error occurred in
> ./applications/PRDApp/prd.system.properties.
>         --- The error occurred while loading global properties.
>         --- Cause: com.ibatis.sqlmap.client.SqlMapException: Error loading
> properties.  Cause:     java.io.IOException: Could not find resource
> ./applications/PRDApp/prd.system.properties
>         .
> 
> Is it possible to get iBatis to use this file? if so any ideas what the
> resource line should be?
> 
> Many thanks
> 
> harry
> 
>

Mime
View raw message