[jboss-user] [Datasource Configuration] - can not be javax.naming.Reference cast to javax.sql.DataSource

Oscar Gutierrez do-not-reply at jboss.com
Tue Oct 4 21:23:06 EDT 2011


Oscar Gutierrez [http://community.jboss.org/people/gutiaes1024] created the discussion

"can not be javax.naming.Reference cast to javax.sql.DataSource"

To view the discussion, visit: http://community.jboss.org/message/630156#630156

--------------------------------------------------------------
Hello everyone,

I have trouble getting a JBoss JNDI datasorce of thing happens in particular in windows works correctly at the time of making the lookup of the datasource, but when I do the same exercise in linux I get an error "can not be javax.naming.Reference cast to javax.sql.DataSource " I have tried several ways to solve the problem but I could not,

has been added to the project all.jar  jbossclient, but the error continues.

the following test to verify that the lookup was not null, then perform a print of the object, trying to cast the datasource  object to get the following exception can not be cast to javax.naming.Reference  javax.sql.DataSource.

EXAMPLE

DataSource ds = null;
Connection conn = null;
Object obj = initContext.lookup("jdbc/gestdoc");
System.out.println(obj.toString());

print console:
--------------------
Reference Class Name: javax.sql.DataSource
Address Type: ProxyData
AddressContents: ffffffac ffffffed 0 5 73 7d 0 0 0 1 0 14 6a 61 76 61 78 2e 73 71 6c 2e 44 61 74 61 53 6f 75 72 63 65  ...
Address Type: VMID
AddressContents: ffffffac ffffffed 0 5 73 72 0 13 6a 61 76 61 2e 72 6d 69 2e 73 65 72 76 65 72 2e 55 49 44 f 12 70 d ffffffbf  ...
Type: JndiName
Content: jdbc/gestdoc
------------------

ds = (javax.sql.DataSource)obj;//Generate Exception -> javax.naming.Reference cannot be cast to javax.sql.DataSource

the definition xml of the datasource for oracle

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/gestdoc</jndi-name>
<use-java-context>false</use-java-context>
<connection-url>jdbc:oracle:thin:@localhost:1521:xe</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>gestdoc</user-name>
<password>gestdoc</password>
<check-valid-connection-sql>SELECT 1 FROM DUAL</check-valid-connection-sql>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>Oracle</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>


thank you very much for the collaboration.
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/630156#630156]

Start a new discussion in Datasource Configuration at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2077]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111004/e7cbbe6c/attachment.html 


More information about the jboss-user mailing list