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 Adrian Harrison <ad...@yahoo.co.uk> on 2005/01/25 13:57:28 UTC

Is this possible in iBatis?

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


Re: Is this possible in iBatis?

Posted by Brice Ruth <bd...@gmail.com>.
It really isn't the property name that you need to worry about. Its
the properties resource:

<properties resource = "./applications/PRDApp/system.properties" />

that is causing you problems. As Larry explained, iBATIS has
essentially two ways of loading properties, one uses the ClassLoader -
this means that it needs to be in the CLASSPATH of the module using
iBATIS (whether its an EJB or a WAR doesn't particularly matter at
that point).

I'm not sure what kind of URL you can use, as I've never come across
this particular situation, but I imagine there is a way to reference a
file in an EAR using a URL ... this is what you need to figure out.

The value you use for DBFullJndiContext will remain the same, once
you've told iBATIS how to successfully load your .properties file.

Cheers!
Brice


On Wed, 26 Jan 2005 13:17:26 -0000, harryajh <ha...@yahoo.co.uk> wrote:
> Larry, thanks for your reply, I'm still struggling with this, could you have
> a another quick look & hopefully give me some ideas?
> 
> My directory structure (exploded) is as follows -
> 
> I:\
> +--domains
> |  +--dev
> |     +--applications
> |     |  +--PRDApp                           (prd.system.properties in here)
> |     |     +--META-INF
> |     |     +--PRDCommonEJB
> |     |     +--PRDControllersEJB
> |     |     +--PRDDataEngineEJB
> |     |     |  +--META-INF
> |     |     |  +--uk
> |     |     |     +--gov
> |     |     |        +--ea
> |     |     |           +--prd
> |     |     |              +--ejb
> |     |     |              +--interfaces
> |     |     |              +--persistence
> |     |     |                 +--config      (sql-map-config.xml in here)
> 
> Any ideas what the <property name="DBFullJndiContext" value="?????"/> should
> be?
> 
> Thanks once again!
> 
> Harry
> 
> -----Original Message-----
> From: Larry Meadors [mailto:larry.meadors@gmail.com]
> Sent: 26 January 2005 12:53
> To: ibatis-user-java@incubator.apache.org
> Subject: Re: Is this possible in iBatis?
> 
> 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
> <ad...@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
> >
> >
> 
>

RE: Is this possible in iBatis?

Posted by harryajh <ha...@yahoo.co.uk>.
Larry, thanks for your reply, I'm still struggling with this, could you have
a another quick look & hopefully give me some ideas?

My directory structure (exploded) is as follows -

I:\
+--domains
|  +--dev
|     +--applications
|     |  +--PRDApp                           (prd.system.properties in here)
|     |     +--META-INF
|     |     +--PRDCommonEJB
|     |     +--PRDControllersEJB
|     |     +--PRDDataEngineEJB
|     |     |  +--META-INF
|     |     |  +--uk
|     |     |     +--gov
|     |     |        +--ea
|     |     |           +--prd
|     |     |              +--ejb
|     |     |              +--interfaces
|     |     |              +--persistence
|     |     |                 +--config      (sql-map-config.xml in here)


Any ideas what the <property name="DBFullJndiContext" value="?????"/> should
be?

Thanks once again!

Harry

-----Original Message-----
From: Larry Meadors [mailto:larry.meadors@gmail.com] 
Sent: 26 January 2005 12:53
To: ibatis-user-java@incubator.apache.org
Subject: Re: Is this possible in iBatis?


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
<ad...@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
> 
>


Re: Is this possible in iBatis?

Posted by Larry Meadors <la...@gmail.com>.
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
<ad...@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
> 
>