ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Could not instantiate DataSourceFactory. Cause: java.lang.ClassCastException
Date Wed, 15 Mar 2006 17:41:02 GMT
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 <chemagogia@gmail.com> 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
>
> <class-loader delegate='true'>
>
> into sun-web.xml
>
>
>
> 2006/3/15, Jeff Butler <jeffgbutler@gmail.com>:
>
> > I'm confused.  Are you saying:
> >
> > 1. It works if you package this into an EAR and the iBATIS jar files 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 iBATIS
> > problem - something else is seriously wrong with your WAR (likely) or
> > application server (unlikely).
> >
> > Jeff Butler
> >
> >
> >  On 3/15/06, Chema <chemagogia@gmail.com> 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 = (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 =
> > > (com.ibatis.sqlmap.engine.datasource.JndiDataSourceFactory )
> > > Resources.instantiate(type);
> > >
> > > the ClassCastException happens again.
> > >
> > > Only with
> > >
> > > JndiDataSourceFactory dsFactory = 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 <jeffgbutler@gmail.com >:
> > >
> > > > Try this:
> > > >
> > > > <transactionManager type="JDBC">
> > > >     <dataSource type="JNDI">
> > > >       <property name="DataSource"
> > > > value="java:comp/env/jdbc/datasource"/>
> > > >     </dataSource>
> > > >   </transactionManager>
> > > >
> > > > Jeff Butler
> > > >
> > > >
> > > >  On 3/14/06, Chema <chemagogia@gmail.com> 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/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
> > > > >
> > > > > <resource-ref>
> > > > >
> > > > > <res-ref-name>jdbc/datasource</res-ref-name>
> > > > >                 <res-type>javax.sql.DataSource </res-type>
> > > > >                 <res-auth>Container</res-auth>
> > > > >                 <res-sharing-scope>Shareable</res-sharing-scope>
> > > > > </resource-ref>
> > > > >
> > > > > - I defined this datasorce in sun-web.xml
> > > > >
> > > > > <resource-ref>
> > > > >                 <res-ref-name>jdbc/datasource</res-ref-name>
> > > > >                 <jndi-name>jdbc/datasource</jndi-name>
> > > > > </resource-ref>
> > > > >
> > > > >
> > > > > - I defined sqlMap client config file
> > > > >
> > > > >   <transactionManager type="JDBC">
> > > > >     <dataSource type="JNDI">
> > > > >       <property name="DataSource" value="jdbc/datasource"/>
> > > > >     </dataSource>
> > > > >   </transactionManager>
> > > > >
> > > > >
> > > > > 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
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>

Mime
View raw message