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 Scott Zhu <sc...@gmail.com> on 2005/10/21 17:06:28 UTC
handle international characters
Hi, I tried to look this up in the user guide. I have to insert something
into the database (SQL Server) with international characters. I tried to
debug the code and I could see just before the ibatis query, the characters
are preserved correctly. But those characters ended in the database as "?"s.
The only related configuration I can see in the xml file is <?xml version="
1.0" encoding="UTF-8" ..> part. What am I missing here? Thanks.
Re: classLoaders
Posted by Ravi Krishnamurthy <ra...@savvion.com>.
Thanks Larry. Actually I ahve tried
Resources.setDefaultClassLoaders(customClassLoader) and it worked fine.
But it forces the clients to call this everytime which I wish to handle
without forcing the clients to do anything. It is little bit tricky to
do it without asking the clients to do it.
Bacially users can develop thier own application and write java classes
which they can change dynamically. The custom clasloader basically
provides the dynamic loading of the classes - if there is a change in
the classes, you dont need to restart the jvm again. Also ibatis is one
of the libraries ( there are many) and these are always loaded using the
custom classloaders and so it gives flexibility for them to load it
anytime with their java classes.
In your suggestion, you mentioned about
setClassLoader(yourEjbClasslOader).. guess you mean the arguement to be
customClasslOader because ejbClassloader will not work.
Is is a good enhancement for ibatis to look for the classloader that
loads its classes(Resources.java in this case) for getResources ?
Regards,
Ravi
Larry Meadors wrote:
>That is an interesting problem. I wonder why the custom class loader
>is not set as the thread class loader. Hm..oh well. :-)
>
>If we use the Resources.java class loader, everything breaks when
>people share the iBATIS jar files (i.e., in common/lib or shared/lib
>with tomcat..which IMO, is a bad idea anyway).
>
>You may want to try using Resources.setClassLoader(yourEjbClassLoader)
>to see if it makes things work. You will need to do that before the
>rest of iBATIS loads, so it may take some digging on your part to
>figure out WHERE to do that, but it is worth a try.
>
>Just curious, what environment is this in?
>
>Larry
>
>On 10/24/05, Ravi Krishnamurthy <ra...@savvion.com> wrote:
>
>
>>Hello:
>>I have a custom classloader that has the ejbclassloader as the parent.
>>The custom classloader loads all the ibatis classes but the thread
>>context classloader is the ejbclassloader. So when the ibatis is trying
>>to load the resource, I get resource not found for the sql...dtd files.
>>On lookig at the source code looks like in the Resources.java of ibatis,
>>the getClassLoader first check the default Classloader and then the
>>Thread.contextClassloader. Looks like in my case, the defaultClassLoader
>>is null and so the context classloader (ejbclassloader) is used to
>>search for the resources and so things file.
>>
>>Could someone give me some pointers on how to resolve this problem.
>>
>>But wondering why the getClassLoader does not use the classloader that
>>loaded the Resources.java to search for the resources.
>>
>>Please note that the ibatis classes are only visible to the
>>cutomclassloader and not to the ejbclassloader.
>>
>>Thanks for your time,
>>
>>Regards,
>>Ravi
>>
>>
>>
>>
Re: classLoaders
Posted by Larry Meadors <lm...@apache.org>.
That is an interesting problem. I wonder why the custom class loader
is not set as the thread class loader. Hm..oh well. :-)
If we use the Resources.java class loader, everything breaks when
people share the iBATIS jar files (i.e., in common/lib or shared/lib
with tomcat..which IMO, is a bad idea anyway).
You may want to try using Resources.setClassLoader(yourEjbClassLoader)
to see if it makes things work. You will need to do that before the
rest of iBATIS loads, so it may take some digging on your part to
figure out WHERE to do that, but it is worth a try.
Just curious, what environment is this in?
Larry
On 10/24/05, Ravi Krishnamurthy <ra...@savvion.com> wrote:
> Hello:
> I have a custom classloader that has the ejbclassloader as the parent.
> The custom classloader loads all the ibatis classes but the thread
> context classloader is the ejbclassloader. So when the ibatis is trying
> to load the resource, I get resource not found for the sql...dtd files.
> On lookig at the source code looks like in the Resources.java of ibatis,
> the getClassLoader first check the default Classloader and then the
> Thread.contextClassloader. Looks like in my case, the defaultClassLoader
> is null and so the context classloader (ejbclassloader) is used to
> search for the resources and so things file.
>
> Could someone give me some pointers on how to resolve this problem.
>
> But wondering why the getClassLoader does not use the classloader that
> loaded the Resources.java to search for the resources.
>
> Please note that the ibatis classes are only visible to the
> cutomclassloader and not to the ejbclassloader.
>
> Thanks for your time,
>
> Regards,
> Ravi
>
>
Re: classLoaders
Posted by Jeff Butler <je...@gmail.com>.
Simple solution - get rid of the custom classloader. The custom classloader
is likely to end up introducing hidden application server dependencies into
your code - because it is not safe to assume that all application servers
structure their classloaders the same way.
If there is some compelling reason to have a custom classloader (do tell),
then maybe this would help:
Resources.setDefaultClassLoader(yourCustomClassloader)
Jeff Butler
On 10/24/05, Ravi Krishnamurthy <ra...@savvion.com> wrote:
>
> Hello:
> I have a custom classloader that has the ejbclassloader as the parent.
> The custom classloader loads all the ibatis classes but the thread
> context classloader is the ejbclassloader. So when the ibatis is trying
> to load the resource, I get resource not found for the sql...dtd files.
> On lookig at the source code looks like in the Resources.java of ibatis,
> the getClassLoader first check the default Classloader and then the
> Thread.contextClassloader. Looks like in my case, the defaultClassLoader
> is null and so the context classloader (ejbclassloader) is used to
> search for the resources and so things file.
>
> Could someone give me some pointers on how to resolve this problem.
>
> But wondering why the getClassLoader does not use the classloader that
> loaded the Resources.java to search for the resources.
>
> Please note that the ibatis classes are only visible to the
> cutomclassloader and not to the ejbclassloader.
>
> Thanks for your time,
>
> Regards,
> Ravi
>
>
classLoaders
Posted by Ravi Krishnamurthy <ra...@savvion.com>.
Hello:
I have a custom classloader that has the ejbclassloader as the parent.
The custom classloader loads all the ibatis classes but the thread
context classloader is the ejbclassloader. So when the ibatis is trying
to load the resource, I get resource not found for the sql...dtd files.
On lookig at the source code looks like in the Resources.java of ibatis,
the getClassLoader first check the default Classloader and then the
Thread.contextClassloader. Looks like in my case, the defaultClassLoader
is null and so the context classloader (ejbclassloader) is used to
search for the resources and so things file.
Could someone give me some pointers on how to resolve this problem.
But wondering why the getClassLoader does not use the classloader that
loaded the Resources.java to search for the resources.
Please note that the ibatis classes are only visible to the
cutomclassloader and not to the ejbclassloader.
Thanks for your time,
Regards,
Ravi
Re: handle international characters
Posted by Daniel Henrique Ferreira e Silva <dh...@gmail.com>.
Hi Scott,
Well, as far as i know, all jdbc drivers take the database encoding
as the default one and that makes sense to me.
What is your database encoding? It's likely to not be UTF8 based on
what you've just said.
Cheers,
Daniel Silva.
On 10/21/05, Scott Zhu <sc...@gmail.com> wrote:
> Thanks, Daniel. I actually didn't think the problem would be in ibatis, but
> I wanted to be sure I didn't miss any obvious settings. I was using
> Weblogic's (bea) sql server type 4 driver. I found later that I have to set
> "CodePageOverride=UTF8" in the driver to get this to work. I don't quite
> understand however, why do I have to set this, shouldn't this be the default
> option in JDBC drivers? I'd be interested if you know more of this. But
> thanks for your help regardless.
>
>
>
> On 10/21/05, Daniel Henrique Ferreira e Silva <dh...@gmail.com> wrote:
> > Scott,
> >
> > That UTF-8 thing just states the xml file character encoding. It's not
> > related to what get inserted into your database. You should look for
> > info on configuring your JDBC driver encoding or ways to work around
> > this within your database.
> >
> > Which database engine are you using?
> >
> > Cheers,
> > Daniel Silva.
> >
> > On 10/21/05, Scott Zhu < scottzhu@gmail.com> wrote:
> > > Hi, I tried to look this up in the user guide. I have to insert
> something
> > > into the database (SQL Server) with international characters. I tried to
> > > debug the code and I could see just before the ibatis query, the
> characters
> > > are preserved correctly. But those characters ended in the database as
> "?"s.
> > > The only related configuration I can see in the xml file is <?xml
> version="
> > > 1.0" encoding="UTF-8" ..> part. What am I missing here? Thanks.
> >
>
>
Re: handle international characters
Posted by Scott Zhu <sc...@gmail.com>.
Thanks, Daniel. I actually didn't think the problem would be in ibatis, but
I wanted to be sure I didn't miss any obvious settings. I was using
Weblogic's (bea) sql server type 4 driver. I found later that I have to set
"CodePageOverride=UTF8" in the driver to get this to work. I don't quite
understand however, why do I have to set this, shouldn't this be the default
option in JDBC drivers? I'd be interested if you know more of this. But
thanks for your help regardless.
On 10/21/05, Daniel Henrique Ferreira e Silva <dh...@gmail.com> wrote:
>
> Scott,
>
> That UTF-8 thing just states the xml file character encoding. It's not
> related to what get inserted into your database. You should look for
> info on configuring your JDBC driver encoding or ways to work around
> this within your database.
>
> Which database engine are you using?
>
> Cheers,
> Daniel Silva.
>
> On 10/21/05, Scott Zhu <sc...@gmail.com> wrote:
> > Hi, I tried to look this up in the user guide. I have to insert
> something
> > into the database (SQL Server) with international characters. I tried to
> > debug the code and I could see just before the ibatis query, the
> characters
> > are preserved correctly. But those characters ended in the database as
> "?"s.
> > The only related configuration I can see in the xml file is <?xml
> version="
> > 1.0" encoding="UTF-8" ..> part. What am I missing here? Thanks.
>
Re: handle international characters
Posted by Daniel Henrique Ferreira e Silva <dh...@gmail.com>.
Scott,
That UTF-8 thing just states the xml file character encoding. It's not
related to what get inserted into your database. You should look for
info on configuring your JDBC driver encoding or ways to work around
this within your database.
Which database engine are you using?
Cheers,
Daniel Silva.
On 10/21/05, Scott Zhu <sc...@gmail.com> wrote:
> Hi, I tried to look this up in the user guide. I have to insert something
> into the database (SQL Server) with international characters. I tried to
> debug the code and I could see just before the ibatis query, the characters
> are preserved correctly. But those characters ended in the database as "?"s.
> The only related configuration I can see in the xml file is <?xml version="
> 1.0" encoding="UTF-8" ..> part. What am I missing here? Thanks.