You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by Paul Benedict <pa...@yahoo.com> on 2006/06/11 03:06:28 UTC

Cannot find sqlmap in jar - new bug

I am using version 2.1.5.582

My web application has a sqlMapConfig.xml file which is the bootstrap config for ibatis. But the
actual configuration files which it refers (<sqlMap> elements) are in a jar. Has anyone had this
problem? 

I have verified that exploding the jar into my WEB-INF/classes directory makes the problem go
away, which means that IBATIS is making a wrong assumption here. Is it using a File object instead
of Class.getResourceAsStream() ?

-- Paul

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Cannot find sqlmap in jar - new bug

Posted by Brandon Goodin <br...@gmail.com>.
oops...sorry didn't see the version in your original email. Still post
your code however.

Brandon

On 6/10/06, Brandon Goodin <br...@gmail.com> wrote:
> I place sqlmapconfig.xml in my jars without issue. Please state the
> version of ibatis you are using and post the code you are using to
> load your sqlmap config.
>
> Brandon
>
> On 6/10/06, Paul Benedict <pa...@yahoo.com> wrote:
> > I am using version 2.1.5.582
> >
> > My web application has a sqlMapConfig.xml file which is the bootstrap config for ibatis. But the
> > actual configuration files which it refers (<sqlMap> elements) are in a jar. Has anyone had this
> > problem?
> >
> > I have verified that exploding the jar into my WEB-INF/classes directory makes the problem go
> > away, which means that IBATIS is making a wrong assumption here. Is it using a File object instead
> > of Class.getResourceAsStream() ?
> >
> > -- Paul
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
>

Re: Cannot find sqlmap in jar - new bug

Posted by Paul Benedict <pa...@yahoo.com>.
As for code, no code. It's all configuration (see previous email). I am using Spring to load this.

  <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    <property name="configLocation" value="/WEB-INF/sqlMapConfig.xml" />
    <property name="dataSource" ref="dataSource" />
  </bean>

--- Paul Benedict <pa...@yahoo.com> wrote:

> Brandon,
> 
> I may have missed getting my configuration across. Here's the problem:
> 
> 1. sqlmapconfig.xml is part of my webapp; it is in WEB-INF
> 2. The SQL maps exist in A SEPARATE LIBRARY in WEB-INF/lib
> 
> So there are two locations here; perhaps took classloaders? I took a look at the Resource.java,
> and I see it loads resources from a ClassLoader. My guess is that #2 is in a different class
> loader.
> 
> <sqlMapConfig>
>   <sqlMap resource="/com/company/people/impl/PeopleImpl-sqlmap.xml" />
> </sqlMapConfig>
> 
> I upgraded to 2.1.7.597 and I have the same issue. 
> As I said, if I copy out PeopleImpl-sqlmap.xml from the supporting library and put it directly
> into WEB-INF/classes, then it can be found.
> 
> --- Brandon Goodin <br...@gmail.com> wrote:
> 
> > I place sqlmapconfig.xml in my jars without issue. Please state the
> > version of ibatis you are using and post the code you are using to
> > load your sqlmap config.
> > 
> > Brandon
> > 
> > On 6/10/06, Paul Benedict <pa...@yahoo.com> wrote:
> > > I am using version 2.1.5.582
> > >
> > > My web application has a sqlMapConfig.xml file which is the bootstrap config for ibatis. But
> > the
> > > actual configuration files which it refers (<sqlMap> elements) are in a jar. Has anyone had
> > this
> > > problem?
> > >
> > > I have verified that exploding the jar into my WEB-INF/classes directory makes the problem
> go
> > > away, which means that IBATIS is making a wrong assumption here. Is it using a File object
> > instead
> > > of Class.getResourceAsStream() ?
> > >
> > > -- Paul
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam protection around
> > > http://mail.yahoo.com
> > >
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Cannot find sqlmap in jar - new bug

Posted by Paul Benedict <pa...@yahoo.com>.
Brandon,

I may have missed getting my configuration across. Here's the problem:

1. sqlmapconfig.xml is part of my webapp; it is in WEB-INF
2. The SQL maps exist in A SEPARATE LIBRARY in WEB-INF/lib

So there are two locations here; perhaps took classloaders? I took a look at the Resource.java,
and I see it loads resources from a ClassLoader. My guess is that #2 is in a different class
loader.

<sqlMapConfig>
  <sqlMap resource="/com/company/people/impl/PeopleImpl-sqlmap.xml" />
</sqlMapConfig>

I upgraded to 2.1.7.597 and I have the same issue. 
As I said, if I copy out PeopleImpl-sqlmap.xml from the supporting library and put it directly
into WEB-INF/classes, then it can be found.

--- Brandon Goodin <br...@gmail.com> wrote:

> I place sqlmapconfig.xml in my jars without issue. Please state the
> version of ibatis you are using and post the code you are using to
> load your sqlmap config.
> 
> Brandon
> 
> On 6/10/06, Paul Benedict <pa...@yahoo.com> wrote:
> > I am using version 2.1.5.582
> >
> > My web application has a sqlMapConfig.xml file which is the bootstrap config for ibatis. But
> the
> > actual configuration files which it refers (<sqlMap> elements) are in a jar. Has anyone had
> this
> > problem?
> >
> > I have verified that exploding the jar into my WEB-INF/classes directory makes the problem go
> > away, which means that IBATIS is making a wrong assumption here. Is it using a File object
> instead
> > of Class.getResourceAsStream() ?
> >
> > -- Paul
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Cannot find sqlmap in jar - new bug

Posted by Brandon Goodin <br...@gmail.com>.
I place sqlmapconfig.xml in my jars without issue. Please state the
version of ibatis you are using and post the code you are using to
load your sqlmap config.

Brandon

On 6/10/06, Paul Benedict <pa...@yahoo.com> wrote:
> I am using version 2.1.5.582
>
> My web application has a sqlMapConfig.xml file which is the bootstrap config for ibatis. But the
> actual configuration files which it refers (<sqlMap> elements) are in a jar. Has anyone had this
> problem?
>
> I have verified that exploding the jar into my WEB-INF/classes directory makes the problem go
> away, which means that IBATIS is making a wrong assumption here. Is it using a File object instead
> of Class.getResourceAsStream() ?
>
> -- Paul
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>

Re: Cannot find sqlmap in jar - new bug [RESOLVED]

Posted by Clinton Begin <cl...@gmail.com>.
Of course, that's all app server dependent.  It should work as you
describe.  Here's the silly thing about some classloaders:  if your resource
is loaded with the local classloader (thread or via known class), you can
start with a slash ("/"), but if it's loaded by the system classloader, you
can't start with a slash.  When you put your SQL Maps in a JAR, it's likely
they'll be loaded by the system classloader.  So putting the slash in front
of the SqlMapConfig.xml when in the web-inf, but not for each of the
resources in the JAR may work.

Classloaders are messed up.

Clinton

On 6/12/06, Paul Benedict <pa...@yahoo.com> wrote:
>
> Thanks everyone for your help. The problem is resolved.
>
> 1) You cannot put sqlmapconfig in WEB-INF but your sqlmap files in jars.
> This splits the classloader and so one will be found but not the other.
> Either put them all in your classpath or in WEB-INF
>
> 2) Do not start with a /
>
> Paul
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>

Re: Cannot find sqlmap in jar - new bug [RESOLVED]

Posted by Paul Benedict <pa...@yahoo.com>.
Thanks everyone for your help. The problem is resolved.

1) You cannot put sqlmapconfig in WEB-INF but your sqlmap files in jars. This splits the classloader and so one will be found but not the other. Either put them all in your classpath or in WEB-INF

2) Do not start with a /

Paul

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Cannot find sqlmap in jar - new bug

Posted by Clinton Begin <cl...@gmail.com>.
Did you try removing the "/" from the beginning of your resource path when
loading the xml files from the JAR file?

  <sqlMap resource="/com/company/people/impl/PeopleImpl-sqlmap.xml" />

Clinton


On 6/11/06, Brandon Goodin <br...@gmail.com> wrote:
>
> I'd recommend that you place your sqlMapConfig.xml in the classes
> directory and use the follwing spring config.
>
> <bean id="sqlMapClient"
> class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
>   <property name="configLocation" value="classpath:sqlMapConfig.xml"/>
>   <property name="dataSource" ref="dataSource"/>
> </bean>
>
> I would assume this issue is tied to the fact that the sqlMapConfig is
> not being loaded from the classpath.
>
> Brandon
>
> On 6/11/06, Paul Benedict <pa...@yahoo.com> wrote:
> > Brandon,
> >
> > >>All i can tell you is that i have recently created an application that
> > uses Spring, iBATIS and is jarred up.
> >
> > Forgive me, but based on the feedback I am getting, I am not convinced
> at all that my problem is
> > being understood. Can you give me some confidence it is? As I said, this
> is not a problem with the
> > application being jarred up --- my application is not jarred up.
> >
> > My problem arises when:
> > (1) the sqlmapconfig.xml exists in the webapp but
> > (2) the actual sqlmap files belong in a LIB jar.
> >
> > Do you see the difference?
> >
> > Paul
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
>

Re: Cannot find sqlmap in jar - new bug

Posted by Brandon Goodin <br...@gmail.com>.
I'd recommend that you place your sqlMapConfig.xml in the classes
directory and use the follwing spring config.

<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
  <property name="configLocation" value="classpath:sqlMapConfig.xml"/>
  <property name="dataSource" ref="dataSource"/>
</bean>

I would assume this issue is tied to the fact that the sqlMapConfig is
not being loaded from the classpath.

Brandon

On 6/11/06, Paul Benedict <pa...@yahoo.com> wrote:
> Brandon,
>
> >>All i can tell you is that i have recently created an application that
> uses Spring, iBATIS and is jarred up.
>
> Forgive me, but based on the feedback I am getting, I am not convinced at all that my problem is
> being understood. Can you give me some confidence it is? As I said, this is not a problem with the
> application being jarred up --- my application is not jarred up.
>
> My problem arises when:
> (1) the sqlmapconfig.xml exists in the webapp but
> (2) the actual sqlmap files belong in a LIB jar.
>
> Do you see the difference?
>
> Paul
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>

Re: Cannot find sqlmap in jar - new bug

Posted by Paul Benedict <pa...@yahoo.com>.
Brandon,

>>All i can tell you is that i have recently created an application that
uses Spring, iBATIS and is jarred up.

Forgive me, but based on the feedback I am getting, I am not convinced at all that my problem is
being understood. Can you give me some confidence it is? As I said, this is not a problem with the
application being jarred up --- my application is not jarred up.

My problem arises when:
(1) the sqlmapconfig.xml exists in the webapp but 
(2) the actual sqlmap files belong in a LIB jar. 

Do you see the difference? 

Paul

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Cannot find sqlmap in jar - new bug

Posted by Brandon Goodin <br...@gmail.com>.
Paul,

All i can tell you is that i have recently created an application that
uses Spring, iBATIS and is jarred up. I have not faced the problems
that you are facing. The only difference is that i used resin instead
of Tomcat. If you feel it is related to classloading strategies then
give resin a try and see if it has the same issue. If it does wind up
being a classloading issue then i'd have to say it is a tomcat issue
rather than an iBATIS issue.

Also, it is not the iBATIS team's responsibility to create the code
and reproduce the issue you are experiencing. It is the reporting
user's responsibility to create repeatable code that can be used to
diagnose the problem. Then you can provide it to us as an issue in
JIRA. At that time it is then our responsibility to assist in
discovering the problem. But, even then, you are encouraged to assist
in the discovery of the problem.

Thanks
Brandon

On 6/11/06, Paul Benedict <pa...@yahoo.com> wrote:
> Clinton, it was only a conjecture that it was using the File object, but my follow up emails show
> that I peeked into Resource.java to see what is going on.
>
> But, afaik, all signs at the moment point to a problem in ibatis. When I pull the XML files out of
> the jar and put them directly into WEB-INF/classes, the XML configs can be found. My best guess at
> the moment is that it deals with the Classloader that is being passed in.
>
> I'd like someone on the ibatis team to reproduce it. I am using tomcat 5.0.28, if it makes a
> difference on what platform is used.
>
> Paul
>
> --- Clinton Begin <cl...@gmail.com> wrote:
>
> > >> which means that IBATIS is making a wrong assumption here
> >
> > You're assuming iBATIS is making an assumption.  Which it is not. If you're
> > using the the iBATIS Resources util, you can confirm the behavior here:
> >
> >
> http://svn.apache.org/repos/asf/ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/resources/Resources.java
> >
> > Cheers,
> > Clinton
> >
> > On 6/10/06, Paul Benedict <pa...@yahoo.com> wrote:
> > >
> > > I am using version 2.1.5.582
> > >
> > > My web application has a sqlMapConfig.xml file which is the bootstrap
> > > config for ibatis. But the
> > > actual configuration files which it refers (<sqlMap> elements) are in a
> > > jar. Has anyone had this
> > > problem?
> > >
> > > I have verified that exploding the jar into my WEB-INF/classes directory
> > > makes the problem go
> > > away, which means that IBATIS is making a wrong assumption here. Is it
> > > using a File object instead
> > > of Class.getResourceAsStream() ?
> > >
> > > -- Paul
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam protection around
> > > http://mail.yahoo.com
> > >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>

Re: Cannot find sqlmap in jar - new bug

Posted by Paul Benedict <pa...@yahoo.com>.
Clinton, it was only a conjecture that it was using the File object, but my follow up emails show
that I peeked into Resource.java to see what is going on. 

But, afaik, all signs at the moment point to a problem in ibatis. When I pull the XML files out of
the jar and put them directly into WEB-INF/classes, the XML configs can be found. My best guess at
the moment is that it deals with the Classloader that is being passed in. 

I'd like someone on the ibatis team to reproduce it. I am using tomcat 5.0.28, if it makes a
difference on what platform is used.

Paul

--- Clinton Begin <cl...@gmail.com> wrote:

> >> which means that IBATIS is making a wrong assumption here
> 
> You're assuming iBATIS is making an assumption.  Which it is not. If you're
> using the the iBATIS Resources util, you can confirm the behavior here:
> 
>
http://svn.apache.org/repos/asf/ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/resources/Resources.java
> 
> Cheers,
> Clinton
> 
> On 6/10/06, Paul Benedict <pa...@yahoo.com> wrote:
> >
> > I am using version 2.1.5.582
> >
> > My web application has a sqlMapConfig.xml file which is the bootstrap
> > config for ibatis. But the
> > actual configuration files which it refers (<sqlMap> elements) are in a
> > jar. Has anyone had this
> > problem?
> >
> > I have verified that exploding the jar into my WEB-INF/classes directory
> > makes the problem go
> > away, which means that IBATIS is making a wrong assumption here. Is it
> > using a File object instead
> > of Class.getResourceAsStream() ?
> >
> > -- Paul
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Cannot find sqlmap in jar - new bug

Posted by Clinton Begin <cl...@gmail.com>.
>> which means that IBATIS is making a wrong assumption here

You're assuming iBATIS is making an assumption.  Which it is not. If you're
using the the iBATIS Resources util, you can confirm the behavior here:

http://svn.apache.org/repos/asf/ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/resources/Resources.java

Cheers,
Clinton

On 6/10/06, Paul Benedict <pa...@yahoo.com> wrote:
>
> I am using version 2.1.5.582
>
> My web application has a sqlMapConfig.xml file which is the bootstrap
> config for ibatis. But the
> actual configuration files which it refers (<sqlMap> elements) are in a
> jar. Has anyone had this
> problem?
>
> I have verified that exploding the jar into my WEB-INF/classes directory
> makes the problem go
> away, which means that IBATIS is making a wrong assumption here. Is it
> using a File object instead
> of Class.getResourceAsStream() ?
>
> -- Paul
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>