Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 29930 invoked from network); 16 Mar 2006 19:45:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Mar 2006 19:45:00 -0000 Received: (qmail 4582 invoked by uid 500); 16 Mar 2006 19:44:49 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 4568 invoked by uid 500); 16 Mar 2006 19:44:49 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 4557 invoked by uid 99); 16 Mar 2006 19:44:49 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Mar 2006 11:44:49 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of jeffgbutler@gmail.com designates 66.249.82.193 as permitted sender) Received: from [66.249.82.193] (HELO xproxy.gmail.com) (66.249.82.193) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Mar 2006 11:44:48 -0800 Received: by xproxy.gmail.com with SMTP id s19so339674wxc for ; Thu, 16 Mar 2006 11:44:27 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=I7N4pmfWVTkgfF8sWpdALmhhXxDMj5ZIAtGeTVFynlDogy7yIH/XpqAYTWxq3t86hB6oWFVgHnihI1dRJEGFhmnR91MTco+/tUf4+TtA7E2FMKpGlaI9RJtHQaz+CSqdZdn23YWffEkkZvTbpnTX9vtVT3wSxdPjpmfLeV0JRlo= Received: by 10.70.104.18 with SMTP id b18mr2486073wxc; Thu, 16 Mar 2006 11:44:27 -0800 (PST) Received: by 10.70.72.9 with HTTP; Thu, 16 Mar 2006 11:44:27 -0800 (PST) Message-ID: Date: Thu, 16 Mar 2006 13:44:27 -0600 From: "Jeff Butler" To: user-java@ibatis.apache.org Subject: Re: Could not instantiate DataSourceFactory. Cause: java.lang.ClassCastException In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_5182_4306226.1142538267153" References: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_5182_4306226.1142538267153 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Delegating to the parent means that the WAR is probably ignoring the iBATIS JARs in your web-inf/lib directory completely - you could remove them. Probably the issue you originally experienced happened because the two sets of JAR files are from different releases of iBATIS. If it were up to me, I would remove the iBATIS jars from the application server classpath - I really don't think its a good idea to put them there. Then the WAR would use the ones in web-inf/lib (whether delegating or not). Other than that, I'll just say that J2EE classloading is a very complex topic and you should do some more reading about it to make sure you understand what's going on. Jeff Butler On 3/16/06, Chema wrote: > > Yes. iBATIS jars were installed in /lib directory ( i'm > working into SUN Application Server 7 ) > > Jars included here are appended to classpath during WAR application init > > It seems to be that the classloader parent of 'WAR classloader' is 'EJB > classloader' and tag is recommended in > WebService. > But this WAR isn't it. Only it calls EJB components be in another server > instance, using IIOP ( WAR is a IIOP client ). > But the problem isn't during EJB components calls, but when iBatis load > dynamically instances > > Why I have to delegate to parent classloader ( EJB classloader ) to find > jars > stored into /lib from my WAR file ? > > > > > 2006/3/15, Jeff Butler : > > > > Interesting - that means that the iBATIS JARs are loaded by a parent > > classloader to the WAR classloader. So the iBATIS jars must be install= ed > > somewhere in the application server's classpath. That's probably not t= he > > best arrangement. > > > > Jeff Butler > > > > > > On 3/15/06, Chema wrote: > > > > > > > > > 1. Right > > > > > > 2. Right. This is very rare because doesn't find iBatis jars, but ye= s > > > another jars > > > > > > > > > I found a workaround but I don't know why works !! > > > > > > The solution is add > > > > > > > > > > > > into sun-web.xml > > > > > > > > > > > > 2006/3/15, Jeff Butler : > > > > > > > I'm confused. Are you saying: > > > > > > > > 1. It works if you package this into an EAR and the iBATIS jar file= s > > > > are in the EAR > > > > 2. It does not work if package this into a standalone WAR and put > > > > the iBATIS jar files in web-inf/lib > > > > > > > > ??? > > > > > > > > If the app cannot find jar files in web-inf/lib, it is not an iBATI= S > > > > problem - something else is seriously wrong with your WAR (likely) = or > > > > application server (unlikely). > > > > > > > > Jeff Butler > > > > > > > > > > > > On 3/15/06, Chema wrote: > > > > > > > > > > > > > > > Thanks for the answer, but that is not the problem. > > > > > > > > > > It's a problem about casting: > > > > > > > > > > Well, I have debugged the iBatis source and I have seen that the > > > > > problem is in > > > > > > > > > > com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.java > > > > > > > > > > when cast > > > > > > > > > > DataSourceFactory dsFactory =3D (DataSourceFactory) > > > > > Resources.instantiate(type); > > > > > > > > > > ( in addNodelet > > > > > "/sqlMapConfig/transactionManager/dataSource/end()" ) > > > > > > > > > > The 'type' value is ' com.ibatis.sqlmap.engine.datasource. > > > > > JndiDataSourceFactory' in my application > > > > > > > > > > Indeed, if I do > > > > > > > > > > com.ibatis.sqlmap.engine.datasource.JndiDataSourceFactorydsFactor= y =3D ( > > > > > com.ibatis.sqlmap.engine.datasource.JndiDataSourceFactory ) > > > > > Resources.instantiate(type); > > > > > > > > > > the ClassCastException happens again. > > > > > > > > > > Only with > > > > > > > > > > JndiDataSourceFactory dsFactory =3D new JndiDataSourceFactory() > > > > > > > > > > doesn't happen. > > > > > > > > > > > > > > > I guess that the source error is in the way that the objects are > > > > > instanciated by classloader in > > > > > com.ibatis.common.resources.Resources.java , but I dont know why. > > > > > > > > > > I tried to allocate ibatis JAR files into WEB-INF/lib, but WAR > > > > > doesn't find classes. > > > > > > > > > > Ummmm > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 2006/3/14, Jeff Butler : > > > > > > > > > > > Try this: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > value=3D"java:comp/env/jdbc/datasource"/> > > > > > > > > > > > > > > > > > > > > > > > > Jeff Butler > > > > > > > > > > > > > > > > > > On 3/14/06, Chema wrote: > > > > > > > > > > > > > > Hello: > > > > > > > > > > > > > > Sorry if I send this message twice > > > > > > > > > > > > > > I'm using iBatis 2. > > > > > > > I'm trying to deploy a WAR file into a SUNONE 7 AS instance > > > > > > > but retrieve this exception: > > > > > > > > > > > > > > com.ibatis.common.exception .NestedRuntimeException: Error > > > > > > > initializing iBatis SQLMap, Cause: > > > > > > > com.ibatis.common.exception.NestedRuntimeException: Error > > > > > > > occurred. Cause: com.ibatis.common.xml.NodeletException: > > > > > > > Error parsing XML. Cause: > > > > > > > com.ibatis.common.exception.NestedRuntimeException : Error > > > > > > > parsing XPath '/sqlMapConfig/transactionManager/dataSource/en= d()'. Cause: > > > > > > > com.ibatis.sqlmap.client.SqlMapException: Error initializing > > > > > > > DataSource. Could not instantiate DataSourceFactory. Cause: > > > > > > > java.lang.ClassCastException > > > > > > > Caused by: java.lang.ClassCastException > > > > > > > > > > > > > > > > > > > > > - I set up datasource configuration in the application server > > > > > > > as "jdbc/datasource" > > > > > > > > > > > > > > - I defined this datasorce in web.xml > > > > > > > > > > > > > > > > > > > > > > > > > > > > jdbc/datasource > > > > > > > javax.sql.DataSource > > > > > > > Container > > > > > > > > > > > > > > Shareable > > > > > > > > > > > > > > > > > > > > > - I defined this datasorce in sun-web.xml > > > > > > > > > > > > > > > > > > > > > jdbc/datasource > > > > > > > jdbc/datasource > > > > > > > > > > > > > > > > > > > > > > > > > > > > - I defined sqlMap client config file > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I dont understand why java.lang.ClassCastException happens. > > > > > > > Indeed, I get to initialize iBatis fine deploying a EAR file > > > > > > > within these config files > > > > > > > > > > > > > > Where can stay the problem ? > > > > > > > > > > > > > > Thanks in advance > > > > > > > > > > > > > > Best regards > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------=_Part_5182_4306226.1142538267153 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Delegating to the parent means that the WAR is probably ignoring the i= BATIS JARs in your web-inf/lib directory completely - you could remove them= .  Probably the issue you originally experienced happened because=  the two sets of JAR files are from different releases of iBATIS.
 
If it were up to me, I would remove the iBATIS jars from the applicati= on server classpath - I really don't think its a good idea to put them ther= e.  Then the WAR would use the ones in web-inf/lib (whether delegating= or not).
 
Other than that, I'll just say that J2EE classloading is a very comple= x topic and you should do some more reading about it to make sure you = understand what's going on.
 
Jeff Butler


 
On 3/16/06, = Chema <chemagogia@gmail.com<= /a>> wrote:
Yes. iBATIS jars were installed in <server= -instance>/lib directory ( i'm
working into SUN Application Server 7= )

Jars included here are appended to classpath during WAR applicati= on init

It seems to be that the classloader parent of 'WAR classloader' is = 'EJB
classloader' and <class-loader delegate=3D'true'> tag is rec= ommended in
WebService.
But this WAR isn't it. Only it calls EJB com= ponents be in another server=20
instance, using IIOP ( WAR is a IIOP client ).
But the problem isn'= t during EJB components calls, but when iBatis load
dynamically instanc= es

Why I have to delegate to parent classloader ( EJB classloader )= to find jars=20
stored into <server-instance>/lib from my WAR file ?




2006/3/15, Jeff Butler <jeffgbutler@gmail.com>:=20
Interesting - that means that the iBATIS JARs are loaded by a parent c= lassloader to the WAR classloader.  So the iBATIS jars must = be installed somewhere in the application server's classpath.  That's = probably not the best arrangement.=20
 
Jeff Butler

 
On 3/15/06, = Chema <chemagogia@gmail.com<= /a>> wrote:=20

1. Right

2. Right.  This is v= ery rare because doesn't find iBatis jars, but yes another jars

I found a workaround but I don't know why works !!

The solution is = add=20

<class-loader delegate=3D'true'>

into sun-web.xml


I'm confused.  Are you saying:
 
1. It works if you package this into an EAR and the iBATIS jar files a= re in the EAR
2. It does not work if package this into a standalone WAR and put the = iBATIS jar files in web-inf/lib
 
???
 
If the app cannot find jar files in web-inf/lib, it is not an iBATIS p= roblem - something else is seriously wrong with your WAR (likely) or applic= ation server (unlikely).
 
Jeff Butler

 
On 3/15/06, = Chema <chemagogia@gmail.com<= /a>> wrote:=20

Thanks for the answer, but that is not th= e problem.

It's a problem about casting:

Well, I have debugge= d the iBatis source and I have seen that the problem is in

com.ibat= is.sqlmap.engine.builder.xml.SqlMapConfigParser.java

when cast

DataSourceFactory dsFactory =3D (DataSourceFactor= y) Resources.instantiate(type);

(  in   addNodelet &q= uot;/sqlMapConfig/transactionManager/dataSource/end()" )

The 't= ype' value is '=20 com.ibatis.sqlmap.engine.datasource.
JndiDataSourceFactory' in my applic= ation

Indeed, if I do

com.ibatis.sqlmap.engine.datasource.Jn= diDataSourceFactory dsFactory =3D (com.ibatis.sqlmap.engine.datasource.Jndi= DataSourceFactory ) Resources.instantiate(type);

the ClassCastException happens again= .

Only with

JndiDataSourceFactory dsFactory =3D new JndiData= SourceFactory()

doesn't happen.


I guess that the source e= rror is in the way that the objects are instanciated by classloader in=20 com.ibatis.common.resources.Resources.java , but I dont know why.

I = tried to allocate ibatis JAR files into WEB-INF/lib, but WAR doesn't find c= lasses.

Ummmm




































Try this:
 
<transactionManager type=3D"JDBC">
 &nbs= p;  <dataSource type=3D"JNDI">
  &= nbsp;   <property name=3D"DataSource" value=3D"= java:comp/env/jdbc/datasource"/>   =20
    </dataSource>
  </transactionManag= er>

Jeff Butler

 
On 3/14/06, = Chema <chemagogia@gmail.com<= /a>> wrote:=20
Hello:

Sorry if I send this message tw= ice

I'm using iBatis 2.
I'm trying to deploy a WAR file into a SU= NONE 7 AS instance but retrieve this exception:

com.ibatis.common.ex= ception =20
.NestedRuntimeException: Error initializing iBatis SQLMap, Cause: com.= ibatis.common.exception.NestedRuntimeException: Error occurred.  Cause= : com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: c= om.ibatis.common.exception.NestedRuntimeException : Error parsing XPath '/sqlMapConfig/transactionManager/dataSource/end()'.=   Cause: com.ibatis.sqlmap.client.SqlMapException: Error initializing = DataSource.  Could not instantiate DataSourceFactory.  Cause: jav= a.lang.ClassCastException
Caused by: java.lang.ClassCastException


- I set up datasour= ce configuration in the application server as "jdbc/datasource" <= br>
- I defined this datasorce in web.xml

<resource-ref>&n= bsp;            = ; =20
            = ;    <res-ref-name>jdbc/datasource</res-ref-name>= ;            &n= bsp; 
          =       <res-type>javax.sql.DataSource </re= s-type>
          &= nbsp;     <res-auth>Container</res-auth>=20
            = ;    <res-sharing-scope>Shareable</res-sharing-scop= e>
</resource-ref>

- I defined this datasorce in sun-web= .xml

<resource-ref>       =    
        &nbs= p;       <res-ref-name>jdbc/datasource&= lt;/res-ref-name>=20
            = ;    <jndi-name>jdbc/datasource</jndi-name>
&= lt;/resource-ref>


- I defined sqlMap client config file
=
  <transactionManager type=3D"JDBC">
 &nbs= p;  <dataSource type=3D"JNDI">=20
      <property name=3D"DataSource&quo= t; value=3D"jdbc/datasource"/>   
 &nb= sp;  </dataSource>
  </transactionManager>

=
I dont understand why java.lang.ClassCastException happens.=20
Indeed, I get to initialize iBatis fine deploying a EAR file within the= se config files

Where can stay the problem ?

Thanks in advan= ce

Best regards


 

=

 

=


------=_Part_5182_4306226.1142538267153--