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 <[EMAIL PROTECTED]> 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 application init

It seems to be that the classloader parent of 'WAR classloader' is 'EJB
classloader' and <class-loader delegate='true'> 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 <server-instance>/lib from my WAR file ?




2006/3/15, Jeff Butler <[EMAIL PROTECTED]>:
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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>:
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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED] >:
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 <[EMAIL PROTECTED]> 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


 


 



Reply via email to