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 "Kram.V" <v....@yahoo.com> on 2008/08/19 15:09:14 UTC

iBatis confusion about sqlMap

Hi all,
 I am an iBATIS newbie and love the ease of using it over Hibernate, but am
having some issues here.
I have a BaseDAO that intializes a sqlMap in a static way. This DAO is
packaged in a jar and then bundled along with a war in a ear file and
deployed. This works perfectly fine.

Now, I have to use this same codebase for two different instances (2
different websites). Each instance has its own database, so at build time I
split out the sql-config-map.xml with respective datasources and bundled the
applications as two different ear files. So now we have two different jars
and two different wars bundled in their respective ear files. 

The problem that I am having is that the sqlMap keeps pointing to the same
database instance in both these application deployments. Is there something
that I am missing here, I thought each instance would get its own sql map
especially since I provided a separate sql-map-config.xml file for each. 

Shouldn't each ear have its own class loader that would prevent any class
loader issues? I am stumped.

Thanks for your help in advance.


-- 
View this message in context: http://www.nabble.com/iBatis-confusion-about-sqlMap-tp19048358p19048358.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: iBatis confusion about sqlMap

Posted by Larry Meadors <la...@gmail.com>.
Why not just use JNDI for the connections?

Larry


On Tue, Aug 19, 2008 at 7:09 AM, Kram.V <v....@yahoo.com> wrote:
>
> Hi all,
>  I am an iBATIS newbie and love the ease of using it over Hibernate, but am
> having some issues here.
> I have a BaseDAO that intializes a sqlMap in a static way. This DAO is
> packaged in a jar and then bundled along with a war in a ear file and
> deployed. This works perfectly fine.
>
> Now, I have to use this same codebase for two different instances (2
> different websites). Each instance has its own database, so at build time I
> split out the sql-config-map.xml with respective datasources and bundled the
> applications as two different ear files. So now we have two different jars
> and two different wars bundled in their respective ear files.
>
> The problem that I am having is that the sqlMap keeps pointing to the same
> database instance in both these application deployments. Is there something
> that I am missing here, I thought each instance would get its own sql map
> especially since I provided a separate sql-map-config.xml file for each.
>
> Shouldn't each ear have its own class loader that would prevent any class
> loader issues? I am stumped.
>
> Thanks for your help in advance.
>
>
> --
> View this message in context: http://www.nabble.com/iBatis-confusion-about-sqlMap-tp19048358p19048358.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Re: iBatis confusion about sqlMap

Posted by bala r <ba...@gmail.com>.
Hi,
Thanks for the quick reply.
This is standalone program not a web program.
Running thru JUnit Test cases and loaded the classpath in the specific
order.
If i remove storedProcedure and parameterMap and move insert statement onto
SQLMap file then i am able to insert or select XMLType content. Issue comes
only when i call stored procedure.

I will try to load the config  as you suggested.

Thanks
Bala.

On Tue, Aug 19, 2008 at 10:20 AM, Clinton Begin <cl...@gmail.com>wrote:

> It should.  The classloader is a hierarchy.  For example, a simple one:
>
> JVM
>     Application (EAR)
>         Web App (WAR)
>     Web App (WAR)
>
> The problem is that every one is different.  And JAR files totally mess
> everything up. If you look up the class loader docs for WebLogic, JBoss and
> WebSphere, you'll probably find more than you expect.
>
> The best solution that seems to work on all app servers is to keep the
> mapping files etc. in your /classes folder with your web app, rather than in
> a JAR.
>
> Also, you don't necessarily have to split out the sql-map-config.xml files,
> you can keep the same one and just split out the properties file specified
> in the <properties/> element of the sql-map-config.xml.
>
> As another solution, if all else fails... load the properties file yourself
> using the SqlMapClientBuilder.buildSqlMapClient(xmlResource,
> propertiesInstance) overloaded method.  You can load the properties file
> from the classpath using the Resources.getResourceAsProperties() method, and
> if necessary you can specify the classloader explicitly.
>
> Clinton
>
> On Tue, Aug 19, 2008 at 7:09 AM, Kram.V <v....@yahoo.com> wrote:
>
>>
>> Hi all,
>>  I am an iBATIS newbie and love the ease of using it over Hibernate, but
>> am
>> having some issues here.
>> I have a BaseDAO that intializes a sqlMap in a static way. This DAO is
>> packaged in a jar and then bundled along with a war in a ear file and
>> deployed. This works perfectly fine.
>>
>> Now, I have to use this same codebase for two different instances (2
>> different websites). Each instance has its own database, so at build time
>> I
>> split out the sql-config-map.xml with respective datasources and bundled
>> the
>> applications as two different ear files. So now we have two different jars
>> and two different wars bundled in their respective ear files.
>>
>> The problem that I am having is that the sqlMap keeps pointing to the same
>> database instance in both these application deployments. Is there
>> something
>> that I am missing here, I thought each instance would get its own sql map
>> especially since I provided a separate sql-map-config.xml file for each.
>>
>> Shouldn't each ear have its own class loader that would prevent any class
>> loader issues? I am stumped.
>>
>> Thanks for your help in advance.
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/iBatis-confusion-about-sqlMap-tp19048358p19048358.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
>

Re: iBatis confusion about sqlMap

Posted by "Kram.V" <v....@yahoo.com>.

Kram.v Begin wrote:
> 
> Hi Clinton
> 
>  Thank you for your response. After much head banging and cursing, found
> out that the problem was with JBoss's classloader, it was using a
> UnifiedClassLoader and this was preventing isolation. After some digging,
> figured out how to disable that to ensure unique class loaders for every
> ear (the right behavior according to what I have learnt). Sorry to have
> bothered you guys with a "non-IBATis" issue in this forum.
> 
> 
> Thanks
> 

Clinton Begin wrote:
> 
> It should.  The classloader is a hierarchy.  For example, a simple one:
> 
> JVM
>     Application (EAR)
>         Web App (WAR)
>     Web App (WAR)
> 
> The problem is that every one is different.  And JAR files totally mess
> everything up. If you look up the class loader docs for WebLogic, JBoss
> and
> WebSphere, you'll probably find more than you expect.
> 
> The best solution that seems to work on all app servers is to keep the
> mapping files etc. in your /classes folder with your web app, rather than
> in
> a JAR.
> 
> Also, you don't necessarily have to split out the sql-map-config.xml
> files,
> you can keep the same one and just split out the properties file specified
> in the <properties/> element of the sql-map-config.xml.
> 
> As another solution, if all else fails... load the properties file
> yourself
> using the SqlMapClientBuilder.buildSqlMapClient(xmlResource,
> propertiesInstance) overloaded method.  You can load the properties file
> from the classpath using the Resources.getResourceAsProperties() method,
> and
> if necessary you can specify the classloader explicitly.
> 
> Clinton
> 
> On Tue, Aug 19, 2008 at 7:09 AM, Kram.V <v....@yahoo.com> wrote:
> 
>>
>> Hi all,
>>  I am an iBATIS newbie and love the ease of using it over Hibernate, but
>> am
>> having some issues here.
>> I have a BaseDAO that intializes a sqlMap in a static way. This DAO is
>> packaged in a jar and then bundled along with a war in a ear file and
>> deployed. This works perfectly fine.
>>
>> Now, I have to use this same codebase for two different instances (2
>> different websites). Each instance has its own database, so at build time
>> I
>> split out the sql-config-map.xml with respective datasources and bundled
>> the
>> applications as two different ear files. So now we have two different
>> jars
>> and two different wars bundled in their respective ear files.
>>
>> The problem that I am having is that the sqlMap keeps pointing to the
>> same
>> database instance in both these application deployments. Is there
>> something
>> that I am missing here, I thought each instance would get its own sql map
>> especially since I provided a separate sql-map-config.xml file for each.
>>
>> Shouldn't each ear have its own class loader that would prevent any class
>> loader issues? I am stumped.
>>
>> Thanks for your help in advance.
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/iBatis-confusion-about-sqlMap-tp19048358p19048358.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/iBatis-confusion-about-sqlMap-tp19048358p19051785.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: iBatis confusion about sqlMap

Posted by Clinton Begin <cl...@gmail.com>.
It should.  The classloader is a hierarchy.  For example, a simple one:

JVM
    Application (EAR)
        Web App (WAR)
    Web App (WAR)

The problem is that every one is different.  And JAR files totally mess
everything up. If you look up the class loader docs for WebLogic, JBoss and
WebSphere, you'll probably find more than you expect.

The best solution that seems to work on all app servers is to keep the
mapping files etc. in your /classes folder with your web app, rather than in
a JAR.

Also, you don't necessarily have to split out the sql-map-config.xml files,
you can keep the same one and just split out the properties file specified
in the <properties/> element of the sql-map-config.xml.

As another solution, if all else fails... load the properties file yourself
using the SqlMapClientBuilder.buildSqlMapClient(xmlResource,
propertiesInstance) overloaded method.  You can load the properties file
from the classpath using the Resources.getResourceAsProperties() method, and
if necessary you can specify the classloader explicitly.

Clinton

On Tue, Aug 19, 2008 at 7:09 AM, Kram.V <v....@yahoo.com> wrote:

>
> Hi all,
>  I am an iBATIS newbie and love the ease of using it over Hibernate, but am
> having some issues here.
> I have a BaseDAO that intializes a sqlMap in a static way. This DAO is
> packaged in a jar and then bundled along with a war in a ear file and
> deployed. This works perfectly fine.
>
> Now, I have to use this same codebase for two different instances (2
> different websites). Each instance has its own database, so at build time I
> split out the sql-config-map.xml with respective datasources and bundled
> the
> applications as two different ear files. So now we have two different jars
> and two different wars bundled in their respective ear files.
>
> The problem that I am having is that the sqlMap keeps pointing to the same
> database instance in both these application deployments. Is there something
> that I am missing here, I thought each instance would get its own sql map
> especially since I provided a separate sql-map-config.xml file for each.
>
> Shouldn't each ear have its own class loader that would prevent any class
> loader issues? I am stumped.
>
> Thanks for your help in advance.
>
>
> --
> View this message in context:
> http://www.nabble.com/iBatis-confusion-about-sqlMap-tp19048358p19048358.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>