-
1. Re: ClassCastException on DataSource access
adrian.brock Nov 5, 2003 11:06 AM (in response to leogsilv)What do you see if the ask
your copy and the WrapperDataSource's copy
for Class.getClassLoader() on class DataSource
My guess is you will find they are two different deployments.
Regards,
Adrian -
2. Re: ClassCastException on DataSource access
leogsilv Nov 5, 2003 2:07 PM (in response to leogsilv)Hi,
I added a statement showing the classloader of the interfaces that
the class WrapperDataSource implements and the result was :
interface : javax.resource.Referenceable
classloaders : org.jboss.mx.loading.UnifiedClassLoader3@b8deef{ url=file:/usr/local/jboss-3.2.2/server/default/tmp/deploy/tmp32909jboss-service.xml ,addedOrder=2}
interface : javax.sql.DataSource
classloaders : null
interface : java.io.Serializable
classloaders : null
The classloader of WrapperDataSource reference return by the jndi lookup is :
org.jboss.mx.loading.UnifiedClassLoader3@b8deef{ url=file:/usr/local/jboss-3.2.2/server/default/tmp/deploy/tmp32909jboss-service.xml ,addedOrder=2}
On JMX Agent View I found the correspondent Classloader:
UCL=b8deef
There is nothing special with the oracle-ds.xml and I reinstalled the jboss but the error persists. Any help is welcome
Thanx -
3. Re: ClassCastException on DataSource access
adrian.brock Nov 5, 2003 2:16 PM (in response to leogsilv)No.
I want to see DataSource.class.getClassLoader();
WrapperDataSource.class.getInterfaces()[indexOfDataSource].getClassLoader();
Looks like indexOfDataSource is 0 but probably best to print everything in a loop.
Regards,
Adrian -
4. Re: ClassCastException on DataSource access
adrian.brock Nov 5, 2003 2:17 PM (in response to leogsilv)Sorry, where I mention
WrapperDataSource.class above that should be
objectReturnedFromJndi.getClass()
Regards,
Adrian -
5. Re: ClassCastException on DataSource access
leogsilv Nov 6, 2003 4:51 AM (in response to leogsilv)Ok,
So, I did a little jsp page :
<%@ page language="java" %>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="org.jboss.resource.adapter.jdbc.*" %>
<%
InitialContext context = new InitialContext();
Object o = context.lookup("java:jdbc/OracleWLogData");
WrapperDataSource ds = (WrapperDataSource)o;
Class[] interfaces = ds.getClass().getInterfaces();
for(int i = 0 ; i < interfaces.length; i++) {
out.println("interface : " + interfaces.getName());
out.println("classloaders : " + interfaces.getClassLoader());
}
out.println("WrapperDataSource Classloader : " + ds.getClass().getClassLoader());
Connection con = ds.getConnection();
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select sysdate from dual");
while (rs.next()) {
out.println("Return : " + rs.getObject(1));
}
rs.close();
st.close();
con.close();
%>
And the output was :
interface : javax.resource.Referenceable
classloaders : org.jboss.mx.loading.UnifiedClassLoader3@b8deef{ url=file:/usr/local/jboss-3.2.2/server/default/tmp/deploy/tmp1893jboss-service.xml ,addedOrder=2}
interface : javax.sql.DataSource
classloaders : null
interface : java.io.Serializable
classloaders : null
WrapperDataSource Classloader : org.jboss.mx.loading.UnifiedClassLoader3@b8deef{ url=file:/usr/local/jboss-3.2.2/server/default/tmp/deploy/tmp1893jboss-service.xml ,addedOrder=2}
Return : 2003-11-06 08:33:11.0
PS: I'm using the last jdk version (1.4.2) running on a linux machine;
Regards
Leonardo -
6. Re: ClassCastException on DataSource access
leogsilv Nov 6, 2003 5:33 AM (in response to leogsilv)THE PROBLEM IS RESOLVED !
Finally I discovered the problem. The oracle driver jar had the package javax.sql so I pulled out this package , restarted jboss ('cause the driver is under lib) and voilla ! the application can use DataSource normally.Thank you for your help.
Regards
Leonardo