Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 13994 invoked from network); 15 Mar 2006 17:41:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Mar 2006 17:41:31 -0000 Received: (qmail 83273 invoked by uid 500); 15 Mar 2006 17:41:28 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 82910 invoked by uid 500); 15 Mar 2006 17:41:27 -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 82899 invoked by uid 99); 15 Mar 2006 17:41:26 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Mar 2006 09:41:26 -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.199 as permitted sender) Received: from [66.249.82.199] (HELO xproxy.gmail.com) (66.249.82.199) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Mar 2006 09:41:25 -0800 Received: by xproxy.gmail.com with SMTP id s19so123838wxc for ; Wed, 15 Mar 2006 09:41:04 -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=dG524hwBR/kqEqV2JT/KH2U27UlMEbsg/3XzcYqZevV02fzqhdkv84M398tSXfvSC4ImCbTITlz7QJTYnnnMc6RQ/ijUixkTYIoI5i7Mb/dtt4airOmdFH6dYjzfKCaSDtb2M0boS1MWeQvKEZ4JqoYRJLBD5N08sZsdjnlV+wk= Received: by 10.70.126.11 with SMTP id y11mr907348wxc; Wed, 15 Mar 2006 09:41:04 -0800 (PST) Received: by 10.70.70.13 with HTTP; Wed, 15 Mar 2006 09:41:02 -0800 (PST) Message-ID: Date: Wed, 15 Mar 2006 11:41:02 -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_25_22225323.1142444462700" References: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_25_22225323.1142444462700 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Interesting - that means that the iBATIS JARs are loaded by a parent classloader 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. Jeff Butler On 3/15/06, Chema wrote: > > > 1. Right > > 2. Right. This is very 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 > > > > 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 files ar= e > > 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 > > 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.JndiDataSourceFactory dsFactory = =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 parsin= g > > > > > XPath '/sqlMapConfig/transactionManager/dataSource/end()'. 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_25_22225323.1142444462700 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
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.
 
Jeff Butler

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

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_25_22225323.1142444462700--