ArrayDescriptor + DataSource = ClassCastException
Hi all,
I have an issue with creating ArrayDescriptors in JRun 4 when using a DataSource. I've seen this issue in a few posts in different forums but no viable solutions. The problem is that JRun returns a JRunDataSource which then returns a JRunConnectionHandle-JRunConnection. The oracle.sql.ArrayDescriptor constructor requires a connection to be passed as a parameter. When I pass the connection I obtain from the JRunDataSource, I get a ClassCastException since it's trying to cast the JRunConnectionHandle-JRunConnection to an OracleConnection.
I've seen a few solutions which suggest using getPhysicalConnection( ) to obtain the inner connection from the JRun Wrapped Connection and then pass that connection to the ArrayDescriptor. However, this would require that I make my application only compatible with JRun since getPhysicalConnection( ) is a method of JRunConnectionHandle-JRunConnection.
I had the same issue when I placed this application in Tomcat 5.5 since the DataSource returned by Tomcat is a BasicDataSource which then returns a PoolableConnection. However, in Tomcat, I was able to configure the DataSource in the Server.xml by adding type= "oracle.jdbc.pool.OracleDataSource" and factory="oracle.jdbc.pool.OracleDataSourceFactory". After configuring the DataSource with these two Attributes, an OracleDataSource was returned instead of a BasicDataSource in Tomcat. I was hoping to have a similar solution for JRun since this solution does not require any server specific code in my application.
Below is my configuration for both Tomcast 5.5 and JRun 4. Tomcat returns an OracleDataSource which is what I need. JRun returns a JRunDataSource which causes a ClassCastException when I use its connections for an ArrayDescriptor. Any help is greatly appreciated:
Tomcat 5.5
name="jdbc/my_jndi_name" auth="Container" type="oracle.jdbc.pool.OracleDataSource" factory="oracle.jdbc.pool.OracleDataSourceFactory"
maxActive="20" maxIdle="10" maxWait="10000"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@my_db_url:1521:my_db" user="user" password="pw" connectionCachingEnabled="true"
JRun 4
<data-source>
<dbname>my_jndi_name</dbname>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>jdbc:oracle:thin:@my_db_url:1521:my_db</url>
<username>user</username>
<password>D46FCD1E3EC74BC58D68FB06AF961666</password>
<encrypted>true</encrypted>
<encryption-class>jrun.security.JRunCrypterForTwofish</encryption-class>
<native-results>true</native-results>
<remove-on-exceptions>true</remove-on-exceptions>
<pool-statements>true</pool-statements>
<initial-connections>1</initial-connections>
<connection-timeout>1200</connection-timeout>
<transaction-timeout>20</transaction-timeout>
<cache-enabled>false</cache-enabled>
<cache-size>5</cache-size>
<cache-refresh-interval>30</cache-refresh-interval>
<jndi-name>my_jndi_name</jndi-name>
<poolname>Pool</poolname>
<minimum-size>0</minimum-size>
<maximum-size>2147483647</maximum-size>
<user-timeout>20</user-timeout>
<skimmer-frequency>420</skimmer-frequency>
<shrink-by>5</shrink-by>
<maximum-soft>true</maximum-soft>
<debugging>false</debugging>
<disable-pooling>false</disable-pooling>
<description>Oracle connection</description>
</data-source>Thank you,
Dave
Hi all,
I have an issue with creating ArrayDescriptors in JRun 4 when using a DataSource. I've seen this issue in a few posts in different forums but no viable solutions. The problem is that JRun returns a JRunDataSource which then returns a JRunConnectionHandle-JRunConnection. The oracle.sql.ArrayDescriptor constructor requires a connection to be passed as a parameter. When I pass the connection I obtain from the JRunDataSource, I get a ClassCastException since it's trying to cast the JRunConnectionHandle-JRunConnection to an OracleConnection.
I've seen a few solutions which suggest using getPhysicalConnection( ) to obtain the inner connection from the JRun Wrapped Connection and then pass that connection to the ArrayDescriptor. However, this would require that I make my application only compatible with JRun since getPhysicalConnection( ) is a method of JRunConnectionHandle-JRunConnection.
I had the same issue when I placed this application in Tomcat 5.5 since the DataSource returned by Tomcat is a BasicDataSource which then returns a PoolableConnection. However, in Tomcat, I was able to configure the DataSource in the Server.xml by adding type= "oracle.jdbc.pool.OracleDataSource" and factory="oracle.jdbc.pool.OracleDataSourceFactory". After configuring the DataSource with these two Attributes, an OracleDataSource was returned instead of a BasicDataSource in Tomcat. I was hoping to have a similar solution for JRun since this solution does not require any server specific code in my application.
Below is my configuration for both Tomcast 5.5 and JRun 4. Tomcat returns an OracleDataSource which is what I need. JRun returns a JRunDataSource which causes a ClassCastException when I use its connections for an ArrayDescriptor. Any help is greatly appreciated:
Tomcat 5.5
name="jdbc/my_jndi_name" auth="Container" type="oracle.jdbc.pool.OracleDataSource" factory="oracle.jdbc.pool.OracleDataSourceFactory"
maxActive="20" maxIdle="10" maxWait="10000"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@my_db_url:1521:my_db" user="user" password="pw" connectionCachingEnabled="true"
JRun 4
<data-source>
<dbname>my_jndi_name</dbname>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>jdbc:oracle:thin:@my_db_url:1521:my_db</url>
<username>user</username>
<password>D46FCD1E3EC74BC58D68FB06AF961666</password>
<encrypted>true</encrypted>
<encryption-class>jrun.security.JRunCrypterForTwofish</encryption-class>
<native-results>true</native-results>
<remove-on-exceptions>true</remove-on-exceptions>
<pool-statements>true</pool-statements>
<initial-connections>1</initial-connections>
<connection-timeout>1200</connection-timeout>
<transaction-timeout>20</transaction-timeout>
<cache-enabled>false</cache-enabled>
<cache-size>5</cache-size>
<cache-refresh-interval>30</cache-refresh-interval>
<jndi-name>my_jndi_name</jndi-name>
<poolname>Pool</poolname>
<minimum-size>0</minimum-size>
<maximum-size>2147483647</maximum-size>
<user-timeout>20</user-timeout>
<skimmer-frequency>420</skimmer-frequency>
<shrink-by>5</shrink-by>
<maximum-soft>true</maximum-soft>
<debugging>false</debugging>
<disable-pooling>false</disable-pooling>
<description>Oracle connection</description>
</data-source>Thank you,
Dave
Similar Messages
-
Using XQSL w/Datasource : ClassCastException
I'm attempting to use XSQL in a Websphere 5.1 test server (WSAD) and I am getting this error:
Oracle XML Developers Kit 10.1.0.2.0 - Production
XML-25017: Unexpected Error Occurred
java.lang.ClassCastException: com.ibm.ejs.cm.proxy.OracleCallableStatementProxy
at oracle.xml.xsql.actions.XSQLRefCursorFunctionHandler.handleAction(XSQLRefCursorFunctionHandler.java:102)
The datasource in question is setup correctly since it works as implemented in the web app. XSQL appears setup correctly because it works with using XSQLConnectionManagerFactoryImpl and <connectiondefs>, and it also works using a AS400JDBCDriver Datasource with XSQLOracleDatasourceConnectionManager.
I'm using classes12.jar (and have tried it with the latest 3 versions). I'm using jdbc:oracle:thin with oracle.jdbc.pool.OracleConnectionPoolDataSource.
Finally, (not sure if this helps) when I decompile XSQLRefCursorFunctionHandler, line 102 appears to bomb here (see below), so I added a "date-format" attribute and value just for funzzies, without change in result:
if(s1 != null && !s1.equals(""))
oraclexmlquery.setDateFormat(s1);
boolean flag1 = s9 != null
&& (s9.equalsIgnoreCase("yes")
|| s9.equalsIgnoreCase("y"));
I'd would greatly appreciate some help.
Thanks in advance!
MonteOne possible reason is that i am using javax.sql.datasource in the source code but the DataSource has been defined with "com.evermind.sql.DriverManagerDataSource" throwing the classcast exception.
any idea in which jar the "com.evermind.sql.DriverManagerDataSource" class can be found ? -
ArrayDescriptor ClassCastException DataSource Tomcat5
Hi All,
I wanted to pass an array to pl/sql from Java using ArrayDescriptor, but i'm getting ClassCastException. Can any one suggest a solution for this.
Oracle version is 9.2.0.6
JDBC Drivers are ojdbc14.jar.
with regards
KarthikHi All
[Apologies.... Was out on meeting with client ]
Please Note:-
1)Thr PLSQL WORKS Pergectly Using a Ordinary Connection from
"DriverManager .get Connection()" in a Web container
2) When replaced with Datasource does not work where ever the Array
Discriptor is been declared as JDBC Releam in the Web container.
Tomcat Version is 5.5.12
Oracle is 9.2.0.6
JDBC DRI VER for ORACLE is ojdbc14.jar (from oracle website)
The Code fo which the
ArrayDescriptor adNames = ArrayDescriptor.createDescriptor("ARR_VARCHAR",myCon);
Here is the Stack Trace
==========================================================
java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:108)
at com.infinet.clc.VoucherProfileDB.insertProfile(VoucherProfileDB.java:587)
at org.apache.jsp.clc.clc_005fvoucher_005fprofile_005fnew_005fsubmit_jsp._jspService(org.apache.jsp.clc.clc_005fvoucher_005fprofile_005fnew_005fsubmit_jsp:413)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
nErrorCode : 0
==========================================================
Please some body suggest me a workaround
With regards
Karthik -
ClassCastException While using ArrayDescriptor
Hi,
Can anybody help me with this,I'm trying to insert some data in a nested table(Oracle
8i) , for which i need to create an ArrayDescriptor which needs to be passed to
the ARRAY on creation , if i directly get the Connection from the driver , it
works fine , but if i try to get it from the weblogic connection pool , it gives
a ClassCastException . I know internally oracle extension for JDBC uses OracleConnection
, but is there any other ways/workarounds ? Please reply asap .
ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("ARRAYOFDATA",connection);
ARRAY array = new ARRAY(descriptor, connection, elements);
ManishaHi Manisha,
I recently ran into the same problem you did. I came up with two workarounds for
this.
1. Given the WebLogic wrapped connection "conn" and the following types that I work
with:
CREATE TYPE dh_id_typ AS OBJECT (
id NUMBER(18)
CREATE TYPE dh_id_tab AS TABLE OF dh_id_typ;
I can do the following to make an Array of dh_id_typ objects for these id numbers
10100, 10101, 10102, 10200, 10201, 10300:
Dynamically build a string that looks like this:
String sql = "select dh_id_tab(dh_id_typ(10100), dh_id_typ(10101), dh_id_typ(10102),
dh_id_typ(10200), dh_id_typ(10201), dh_id_typ(10300)) from dual";
Next, do this:
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
rs.next();
java.sql.Array ids = rs.getArray(1);
"ids" is a DB server-side Array with the specified values. The Array object is good
for the duration of the transaction. No need for Oracle-specific classes and only
one extra round-trip to the DB. The only problem is that Oracle SQL statements have
a max length of 64K, so your Array length is limited by the generated SQL statement's
size.
2. The other workaround I thought of would involve batched inserts of array elements
to a temporary table. It doesn't suffer from any size limits. It means more round-trips
to the database, but it might scale better. It looks like this:
temp table & sequence schema:
CREATE SEQUENCE dh_temp_array_seq;
CREATE TABLE dh_temp_array (
seq_num NUMBER(18),
object_id NUMBER(18)
java code:
long[] ids = ... // Given id's in an array of longs.
PreparedStatement select = conn.prepareStatement("SELECT dh_temp_array_seq.NEXTVAL
FROM DUAL");
ResultSet rs = select.executeQuery(select);
rs.next();
long seqNum = rs.getLong(1);
rs.close();
PreparedStatement insert = conn.prepareStatement("INSERT INTO dh_temp_array (seq_num,
object_id) VALUES (?, ?)");
for (int index = 0; index < ids.length; index++) {
insert.setLong(1, seqNum);
insert.setLong(2, ids[index]);
insert.addBatch();
insert.executeBatch();
String sql = "SELECT CAST(MULTISET(select object_id from dh_temp_array where seq_num=?)
AS dh_id_tab) FROM dual";
PreparedStatement selectArray = conn.prepareStatment(sql);
selectArray.setLong(1, seqNum);
rs = selectArray.executeQuery();
rs.next();
Array idArray = rs.getArray(1);
. // Use Array
PreparedStatement delete = conn.prepareStatement("DELETE FROM dh_temp_array WHERE
seq_num=?");
delete.setLong(1, seqNum);
delete.executeUpdate();
Here, "idArray" is a DB server-side Array with the specified values. Again, no need
for an OracleConnection. This is all done on the wrapped connection.
Of course, you will have to adapt the examples to your schema/types.
BTW, if BEA would just follow the suggestions in Sun's JDBC 2.0 Standard Extension
API specification, located at:
http://java.sun.com/products/jdbc/jdbc20.stdext.pdf (See sections 6 & 7)
Then their Pooling/XA implementations could return us the logical connection wrapper
created by the Oracle driver (javax.sql.PooledConnection.getConnection() & javax.sql.XAConnection.getConnection()),
which DOES implement OracleConnection, but still hides the physical database connection
from the application code. Note, DON'T access PooledConnection or XAConnection from
your application code. Getting PooledConnection's/XAConnection's from their respective
data sources will create a physical database connection every time (slow). They are
meant for application server developers (like BEA), so they can create DataSource
implementation classes that provide connection pooling and distributed transaction
support, without having to create an entire JDBC wrapper driver (like BEA had to,
before JDBC 2.0 Std. Ext. API existed).
I hope that helps.
-Keith
Keith Caceres
Middleware Architect
Tririga Inc.
"Manisha Mehrotra" <[email protected]> wrote:
>
Hi,
Can anybody help me with this,I'm trying to insert some data in a nested
table(Oracle
8i) , for which i need to create an ArrayDescriptor which needs to be passed
to
the ARRAY on creation , if i directly get the Connection from the driver
, it
works fine , but if i try to get it from the weblogic connection pool ,
it gives
a ClassCastException . I know internally oracle extension for JDBC uses
OracleConnection
, but is there any other ways/workarounds ? Please reply asap .
ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("ARRAYOFDATA",connection);
ARRAY array = new ARRAY(descriptor, connection, elements);
Manisha -
WSAD 5, xerces, datasource and classcastexception issue
I am running into an issue trying to run my code once I upgraded from WDAD 5.0 to WSAD 5.01. I am getting the error below when I try and connect to my DataSource. This all was working fine before I upgraded. It looks like an issue with the xerces.jar file because if I take out the JAXP stuff in the xerces.jar file I work fine. But I need the JAXP stuff because I am doing messaging. Anyone have any ideas?
[5/22/03 7:02:59:848 CDT] 2ec4c80 SystemOut O 2003.05.22 07:02:59.848--ServerSession(426724481)--Thread[asyncDelivery0,5,main]--Connection(47762586)--TopLink, version:TopLink - 9.0.3 (Build 423)
2003.05.22 07:02:59.848--ServerSession(426724481)--Thread[asyncDelivery0,5,main]--Connection(47762586)--connecting(DatabaseLogin(
platform => DB2Platform
user name => "ou79ecm"
datasource name => "jdbc/DB239DataSource"
[5/22/03 7:03:00:118 CDT] 2ec4c80 ConnectionFac I J2CA0122I: Resource reference jdbc/DB239DataSource could not be located, so default values of the following are used: [Resource-ref settings]
res-auth: 1 (APPLICATION)
res-isolation-level: 0 (TRANSACTION_NONE)
res-sharing-scope: true (SHAREABLE)
res-resolution-control: 999 (undefined)
[Other attributes]
isCMP1_x: false (not CMP1.x)
isJMS: false (not JMS)
[5/22/03 7:03:01:160 CDT] 2ec4c80 ConnectionFac E J2CA0009E: An exception occurred while trying to instantiate the ManagedConnectionFactory class com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl used by resource jdbc/DB239DataSource : java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl
at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
at com.ibm.ejs.j2c.XMLReader.validate(XMLReader.java:673)
at com.ibm.ejs.j2c.XMLReader.init(XMLReader.java:241)
at com.ibm.ejs.j2c.XMLReader.<init>(XMLReader.java:165)
at com.ibm.ejs.j2c.ConnectorRuntime.getJ2C_Properties(ConnectorRuntime.java:341)
at com.ibm.ejs.j2c.poolmanager.PoolManager.<init>(PoolManager.java:541)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createCFD_Common(ConnectionFactoryBuilderImpl.java:699)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createConnectionFactoryDetails(ConnectionFactoryBuilderImpl.java:417)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance(ConnectionFactoryBuilderImpl.java:1400)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:313)
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:884)
at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:1675)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1538)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1458)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1130)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:122)
at javax.naming.InitialContext.lookup(InitialContext.java:363)
at oracle.toplink.jndi.JNDIConnector.connect(Unknown Source)
at oracle.toplink.sessions.DatabaseLogin.connect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
at oracle.toplink.threetier.ConnectionPool.buildConnection(Unknown Source)
at oracle.toplink.threetier.ConnectionPool.startUp(Unknown Source)
at oracle.toplink.threetier.ServerSession.connect(Unknown Source)
at oracle.toplink.publicinterface.DatabaseSession.login(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at com.deere.jdc.toplink.ToplinkServerSessionFactory.getSession(ToplinkServerSessionFactory.java:121)
at com.deere.jdc.toplink.ToplinkServerSessionFactory.getClientSession(ToplinkServerSessionFactory.java:56)
at com.deere.jdc.component.rcts.dao.RCTSGateway.findDealerASMByDealerNumber(RCTSGateway.java:194)
at com.deere.jdc.component.rcts.service.RCTSService.getRCTSDealerASM(RCTSService.java:159)
at com.deere.jdc.component.rcts.adapter.SoapRCTSService.getRCTSDealerASM(SoapRCTSService.java:107)
at java.lang.reflect.Method.invoke(Native Method)
at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.invokeServiceMethod(RCTSMessageHandler.java:103)
at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.processMessage(RCTSMessageHandler.java:62)
at com.deere.jdc.mqseries.MQJMSMessageHandler.onMessage(MQJMSMessageHandler.java:122)
at com.ibm.mq.jms.MQQueueReceiver.receiveAsync(MQQueueReceiver.java:861)
at com.ibm.mq.jms.SessionAsyncHelper.run(SessionAsyncHelper.java:401)
at java.lang.Thread.run(Thread.java:513)
[5/22/03 7:03:01:310 CDT] 2ec4c80 ConnectionFac A J2CA0013I: An exception occurred while trying to create ManagedConnectionFactory for DB239DataSource : java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl
at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
at com.ibm.ejs.j2c.XMLReader.validate(XMLReader.java:673)
at com.ibm.ejs.j2c.XMLReader.init(XMLReader.java:241)
at com.ibm.ejs.j2c.XMLReader.<init>(XMLReader.java:165)
at com.ibm.ejs.j2c.ConnectorRuntime.getJ2C_Properties(ConnectorRuntime.java:341)
at com.ibm.ejs.j2c.poolmanager.PoolManager.<init>(PoolManager.java:541)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createCFD_Common(ConnectionFactoryBuilderImpl.java:699)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createConnectionFactoryDetails(ConnectionFactoryBuilderImpl.java:417)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance(ConnectionFactoryBuilderImpl.java:1400)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:313)
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:884)
at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:1675)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1538)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1458)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1130)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:122)
at javax.naming.InitialContext.lookup(InitialContext.java:363)
at oracle.toplink.jndi.JNDIConnector.connect(Unknown Source)
at oracle.toplink.sessions.DatabaseLogin.connect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
at oracle.toplink.threetier.ConnectionPool.buildConnection(Unknown Source)
at oracle.toplink.threetier.ConnectionPool.startUp(Unknown Source)
at oracle.toplink.threetier.ServerSession.connect(Unknown Source)
at oracle.toplink.publicinterface.DatabaseSession.login(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at com.deere.jdc.toplink.ToplinkServerSessionFactory.getSession(ToplinkServerSessionFactory.java:121)
at com.deere.jdc.toplink.ToplinkServerSessionFactory.getClientSession(ToplinkServerSessionFactory.java:56)
at com.deere.jdc.component.rcts.dao.RCTSGateway.findDealerASMByDealerNumber(RCTSGateway.java:194)
at com.deere.jdc.component.rcts.service.RCTSService.getRCTSDealerASM(RCTSService.java:159)
at com.deere.jdc.component.rcts.adapter.SoapRCTSService.getRCTSDealerASM(SoapRCTSService.java:107)
at java.lang.reflect.Method.invoke(Native Method)
at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.invokeServiceMethod(RCTSMessageHandler.java:103)
at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.processMessage(RCTSMessageHandler.java:62)
at com.deere.jdc.mqseries.MQJMSMessageHandler.onMessage(MQJMSMessageHandler.java:122)
at com.ibm.mq.jms.MQQueueReceiver.receiveAsync(MQQueueReceiver.java:861)
at com.ibm.mq.jms.SessionAsyncHelper.run(SessionAsyncHelper.java:401)
at java.lang.Thread.run(Thread.java:513)
[5/22/03 7:03:01:340 CDT] 2ec4c80 Helpers W NMSV0605W: A Reference object looked up from the context "localhost/nodes/localhost/servers/server1" with the name "jdbc/DB239DataSource" was sent to the JNDI Naming Manager and an exception resulted. Reference data follows:
Reference Factory Class Name: com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl
Reference Factory Class Location URLs: <null>
Reference Class Name: DB239DataSource
Type: connectorName
Content: DB239DataSource
Type: classpath
Content: C:\Program Files\IBM\WebSphere Studio\runtimes\base_v5/lib/rsadapter.rar
Type: FactoryJndiName
Content: jdbc/DB239DataSource
Address Type: dd
AddressContents: ffffffac ffffffed 0 5 73 72 0 25 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 52 65 73 6f 75 72 63 65 ...
Address Type: poolProps
AddressContents: ffffffac ffffffed 0 5 73 72 0 27 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 43 6f 6e 6e 65 63 74 6f ...
Address Type: configProps
AddressContents: ffffffac ffffffed 0 5 73 72 0 23 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 43 6f 6e 6e 65 63 74 6f ...
Address Type: dsProps
AddressContents: ffffffac ffffffed 0 5 73 72 0 14 6a 61 76 61 2e 75 74 69 6c 2e 50 72 6f 70 65 72 74 69 65 73 39 12 ffffffd0 7a ...
Address Type: mcfProps
AddressContents: ffffffac ffffffed 0 5 73 72 0 2d 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 4d 61 6e 61 67 65 64 43 ...
Address Type: mbeanProps
AddressContents: ffffffac ffffffed 0 5 73 72 0 1a 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 4d 42 65 61 6e 50 72 6f ...
Exception data follows:
java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl
at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
at com.ibm.ejs.j2c.XMLReader.validate(XMLReader.java:673)
at com.ibm.ejs.j2c.XMLReader.init(XMLReader.java:241)
at com.ibm.ejs.j2c.XMLReader.<init>(XMLReader.java:165)
at com.ibm.ejs.j2c.ConnectorRuntime.getJ2C_Properties(ConnectorRuntime.java:341)
at com.ibm.ejs.j2c.poolmanager.PoolManager.<init>(PoolManager.java:541)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createCFD_Common(ConnectionFactoryBuilderImpl.java:699)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createConnectionFactoryDetails(ConnectionFactoryBuilderImpl.java:417)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance(ConnectionFactoryBuilderImpl.java:1400)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:313)
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:884)
at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:1675)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1538)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1458)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1130)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:122)
at javax.naming.InitialContext.lookup(InitialContext.java:363)
at oracle.toplink.jndi.JNDIConnector.connect(Unknown Source)
at oracle.toplink.sessions.DatabaseLogin.connect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
at oracle.toplink.threetier.ConnectionPool.buildConnection(Unknown Source)
at oracle.toplink.threetier.ConnectionPool.startUp(Unknown Source)
at oracle.toplink.threetier.ServerSession.connect(Unknown Source)
at oracle.toplink.publicinterface.DatabaseSession.login(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at com.deere.jdc.toplink.ToplinkServerSessionFactory.getSession(ToplinkServerSessionFactory.java:121)
at com.deere.jdc.toplink.ToplinkServerSessionFactory.getClientSession(ToplinkServerSessionFactory.java:56)
at com.deere.jdc.component.rcts.dao.RCTSGateway.findDealerASMByDealerNumber(RCTSGateway.java:194)
at com.deere.jdc.component.rcts.service.RCTSService.getRCTSDealerASM(RCTSService.java:159)
at com.deere.jdc.component.rcts.adapter.SoapRCTSService.getRCTSDealerASM(SoapRCTSService.java:107)
at java.lang.reflect.Method.invoke(Native Method)
at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.invokeServiceMethod(RCTSMessageHandler.java:103)
at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.processMessage(RCTSMessageHandler.java:62)
at com.deere.jdc.mqseries.MQJMSMessageHandler.onMessage(MQJMSMessageHandler.java:122)
at com.ibm.mq.jms.MQQueueReceiver.receiveAsync(MQQueueReceiver.java:861)
at com.ibm.mq.jms.SessionAsyncHelper.run(SessionAsyncHelper.java:401)
at java.lang.Thread.run(Thread.java:513)
[5/22/03 7:03:01:891 CDT] 2ec4c80 Helpers W NMSV0610I: A NamingException is being thrown from a javax.naming.Context implementation. Details follow:
Context implementation: com.ibm.ws.naming.jndicos.CNContextImpl
Context method: lookup
Context name: localhost/nodes/localhost/servers/server1
Target name: jdbc/DB239DataSource
Other data:
Exception stack trace: com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. Root exception is java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl
at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
at com.ibm.ejs.j2c.XMLReader.validate(XMLReader.java:673)
at com.ibm.ejs.j2c.XMLReader.init(XMLReader.java:241)
at com.ibm.ejs.j2c.XMLReader.<init>(XMLReader.java:165)
at com.ibm.ejs.j2c.ConnectorRuntime.getJ2C_Properties(ConnectorRuntime.java:341)
at com.ibm.ejs.j2c.poolmanager.PoolManager.<init>(PoolManager.java:541)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createCFD_Common(ConnectionFactoryBuilderImpl.java:699)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createConnectionFactoryDetails(ConnectionFactoryBuilderImpl.java:417)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance(ConnectionFactoryBuilderImpl.java:1400)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:313)
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:884)
at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:1675)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1538)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1458)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1130)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:122)
at javax.naming.InitialContext.lookup(InitialContext.java:363)
at oracle.toplink.jndi.JNDIConnector.connect(Unknown Source)
at oracle.toplink.sessions.DatabaseLogin.connect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
at oracle.toplink.threetier.ConnectionPool.buildConnection(Unknown Source)
at oracle.toplink.threetier.ConnectionPool.startUp(Unknown Source)
at oracle.toplink.threetier.ServerSession.connect(Unknown Source)
at oracle.toplink.publicinterface.DatabaseSession.login(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at com.deere.jdc.toplink.ToplinkServerSessionFactory.getSession(ToplinkServerSessionFactory.java:121)
at com.deere.jdc.toplink.ToplinkServerSessionFactory.getClientSession(ToplinkServerSessionFactory.java:56)
at com.deere.jdc.component.rcts.dao.RCTSGateway.findDealerASMByDealerNumber(RCTSGateway.java:194)
at com.deere.jdc.component.rcts.service.RCTSService.getRCTSDealerASM(RCTSService.java:159)
at com.deere.jdc.component.rcts.adapter.SoapRCTSService.getRCTSDealerASM(SoapRCTSService.java:107)
at java.lang.reflect.Method.invoke(Native Method)
at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.invokeServiceMethod(RCTSMessageHandler.java:103)
at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.processMessage(RCTSMessageHandler.java:62)
at com.deere.jdc.mqseries.MQJMSMessageHandler.onMessage(MQJMSMessageHandler.java:122)
at com.ibm.mq.jms.MQQueueReceiver.receiveAsync(MQQueueReceiver.java:861)
at com.ibm.mq.jms.SessionAsyncHelper.run(SessionAsyncHelper.java:401)
at java.lang.Thread.run(Thread.java:513)
2003.05.22 07:03:02.111--ServerSession(426724481)--Thread[asyncDelivery0,5,main]--EXCEPTION [TOPLINK-7060] (TopLink - 9.0.3 (Build 423)): oracle.toplink.exceptions.ValidationException
EXCEPTION DESCRIPTION: Cannot acquire data source [jdbc/DB239DataSource].
INTERNAL EXCEPTION: com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl]LOCAL EXCEPTION STACK:
EXCEPTION [TOPLINK-7060] (TopLink - 9.0.3 (Build 423)): oracle.toplink.exceptions.ValidationException
EXCEPTION DESCRIPTION: Cannot acquire data source [jdbc/DB239DataSource].
INTERNAL EXCEPTION: com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl]
at oracle.toplink.exceptions.ValidationException.cannotAcquireDataSource(Unknown Source)
at oracle.toplink.jndi.JNDIConnector.connect(Unknown Source)
at oracle.toplink.sessions.DatabaseLogin.connect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
at oracle.toplink.threetier.ConnectionPool.buildConnection(Unknown Source)
at oracle.toplink.threetier.ConnectionPool.startUp(Unknown Source)
at oracle.toplink.threetier.ServerSession.connect(Unknown Source)
at oracle.toplink.publicinterface.DatabaseSession.login(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at com.deere.jdc.toplink.ToplinkServerSessionFactory.getSession(ToplinkServerSessionFactory.java:121)
at com.deere.jdc.toplink.ToplinkServerSessionFactory.getClientSession(ToplinkServerSessionFactory.java:56)
at com.deere.jdc.component.rcts.dao.RCTSGateway.findDealerASMByDealerNumber(RCTSGateway.java:194)
at com.deere.jdc.component.rcts.service.RCTSService.getRCTSDealerASM(RCTSService.java:159)
at com.deere.jdc.component.rcts.adapter.SoapRCTSService.getRCTSDealerASM(SoapRCTSService.java:107)
at java.lang.reflect.Method.invoke(Native Method)
at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.invokeServiceMethod(RCTSMessageHandler.java:103)
at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.processMessage(RCTSMessageHandler.java:62)
at com.deere.jdc.mqseries.MQJMSMessageHandler.onMessage(MQJMSMessageHandler.java:122)
at com.ibm.mq.jms.MQQueueReceiver.receiveAsync(MQQueueReceiver.java:861)
at com.ibm.mq.jms.SessionAsyncHelper.run(SessionAsyncHelper.java:401)
at java.lang.Thread.run(Thread.java:513)
INTERNAL EXCEPTION STACK:
com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. Root exception is java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl
at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
at com.ibm.ejs.j2c.XMLReader.validate(XMLReader.java:673)
at com.ibm.ejs.j2c.XMLReader.init(XMLReader.java:241)
at com.ibm.ejs.j2c.XMLReader.<init>(XMLReader.java:165)
at com.ibm.ejs.j2c.ConnectorRuntime.getJ2C_Properties(ConnectorRuntime.java:341)
at com.ibm.ejs.j2c.poolmanager.PoolManager.<init>(PoolManager.java:541)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createCFD_Common(ConnectionFactoryBuilderImpl.java:699)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.createConnectionFactoryDetails(ConnectionFactoryBuilderImpl.java:417)
at com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl.getObjectInstance(ConnectionFactoryBuilderImpl.java:1400)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:313)
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:884)
at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:1675)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1538)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1458)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1130)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:122)
at javax.naming.InitialContext.lookup(InitialContext.java:363)
at oracle.toplink.jndi.JNDIConnector.connect(Unknown Source)
at oracle.toplink.sessions.DatabaseLogin.connect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.connect(Unknown Source)
at oracle.toplink.threetier.ConnectionPool.buildConnection(Unknown Source)
at oracle.toplink.threetier.ConnectionPool.startUp(Unknown Source)
at oracle.toplink.threetier.ServerSession.connect(Unknown Source)
at oracle.toplink.publicinterface.DatabaseSession.login(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at oracle.toplink.tools.sessionmanagement.SessionManager.getSession(Unknown Source)
at com.deere.jdc.toplink.ToplinkServerSessionFactory.getSession(ToplinkServerSessionFactory.java:121)
at com.deere.jdc.toplink.ToplinkServerSessionFactory.getClientSession(ToplinkServerSessionFactory.java:56)
at com.deere.jdc.component.rcts.dao.RCTSGateway.findDealerASMByDealerNumber(RCTSGateway.java:194)
at com.deere.jdc.component.rcts.service.RCTSService.getRCTSDealerASM(RCTSService.java:159)
at com.deere.jdc.component.rcts.adapter.SoapRCTSService.getRCTSDealerASM(SoapRCTSService.java:107)
at java.lang.reflect.Method.invoke(Native Method)
at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.invokeServiceMethod(RCTSMessageHandler.java:103)
at com.deere.jdc.component.rcts.messaging.RCTSMessageHandler.processMessage(RCTSMessageHandler.java:62)
at com.deere.jdc.mqseries.MQJMSMessageHandler.onMessage(MQJMSMessageHandler.java:122)
at com.ibm.mq.jms.MQQueueReceiver.receiveAsync(MQQueueReceiver.java:861)
at com.ibm.mq.jms.SessionAsyncHelper.run(SessionAsyncHelper.java:401)
at java.lang.Thread.run(Thread.java:513)This looks like a classPath issue.check ur runtime
class path and make sure xerces is before any other
parser(xml4j /oracleParser)
vasanth -
ClassCastException ArrayDescriptor SructDescriptor
Hi,
I have problem with calling stored procedure in oracle.
One of the IN parameters of the procedure is Array, and when I try to call this procedure I get error:
java.lang.ClassCastException: oracle.sql.StructDescriptor cannot be cast to oracle.sql.ArrayDescriptor
Code in PL/SQL:
CREATE OR REPLACE
type A_TYPE as OBJECT (
firstName varchar2(100),
surname varchar2(100)
CREATE OR REPLACE
type A_TYPE_ARRAY is table of A_TYPE;
Code in java:
String function ="xxxxxxxxxx";
OracleCallableStatement cstmt = (OracleCallableStatement)conn.prepareCall(funkcion);
OracleConnection conn = (OracleConnection)DriverManager.getConnection
("jdbc:oracle:thin:@xxxx:1521:xxxxx", "xxx", "xxx");
Object[] atr = new Object[];
StructDescriptor structdesc = StructDescriptor.createDescriptor("A_TYPE", conn);
STRUCT struct = new STRUCT(structdesc, conn, atr);
ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor("A_TYPE_ARRAY", conn);
ARRAY array = new ARRAY(arrayDesc, conn, struct);
cstmt.setArray(1, array);
cstmt.execute();
In line where I trying to make arrayDesc I get error:
Exception occurred during event dispatching:
java.lang.ClassCastException: oracle.sql.StructDescriptor cannot be cast to oracle.sql.ArrayDescriptor
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:112)
Can some tell me what causes this problem?
Thanks.Hi,
I have problem with calling stored procedure in oracle.
One of the IN parameters of the procedure is Array, and when I try to call this procedure I get error:
java.lang.ClassCastException: oracle.sql.StructDescriptor cannot be cast to oracle.sql.ArrayDescriptor
Code in PL/SQL:
CREATE OR REPLACE
type A_TYPE as OBJECT (
firstName varchar2(100),
surname varchar2(100)
CREATE OR REPLACE
type A_TYPE_ARRAY is table of A_TYPE;
Code in java:
String function ="xxxxxxxxxx";
OracleCallableStatement cstmt = (OracleCallableStatement)conn.prepareCall(funkcion);
OracleConnection conn = (OracleConnection)DriverManager.getConnection
("jdbc:oracle:thin:@xxxx:1521:xxxxx", "xxx", "xxx");
Object[] atr = new Object[];
StructDescriptor structdesc = StructDescriptor.createDescriptor("A_TYPE", conn);
STRUCT struct = new STRUCT(structdesc, conn, atr);
ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor("A_TYPE_ARRAY", conn);
ARRAY array = new ARRAY(arrayDesc, conn, struct);
cstmt.setArray(1, array);
cstmt.execute();
In line where I trying to make arrayDesc I get error:
Exception occurred during event dispatching:
java.lang.ClassCastException: oracle.sql.StructDescriptor cannot be cast to oracle.sql.ArrayDescriptor
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:112)
Can some tell me what causes this problem?
Thanks. -
Java ArrayDescriptor Classcastexception
I'm using Weblogic 8.1 SP2, Oracle Database 9.2.0.1.0 and Oracle JDBC thin driver supplied with Weblogic(major ver. 1, minor ver. 0).
I wanted to pass an array to pl/sql from Java using ArrayDescriptor, but i'm getting ClassCastException. I also tried to pass Clob but same exception occurred.
What to do? Is there any driver patch that needs to be applied?Hi,
This particular forum is for S1AS7. :)
You might want to repost this in the App Server 6.x forum:
http://softwareforum.sun.com/NASApp/jive/forum.jsp?forum=18 -
ClassCastException trying to create ArrayDescriptor
There is one way I found to accomplish something like this. It basically involves
using the customdatum interface that oracle provides. Essentially you can pass
an object through all of the jdbc layers into the oracle driver and then let the
driver call your object back with an oracleconnection - thereby avoiding the classcastexception.
It does require a bit more work, but may be worth it in certain circumstances.
I have attached an example dervied from some working code(though the example probably
will not compile). It shows how to accomplish this for a struct containing an
array of structs (pretty much a one to many model). It can be simplified of course
if such a containment model does not exist. Also one should be able to adjust
this strategy for clobs as well to basically avoid having to do two jdbc calls
to create a new clob.
Rupen
"David" <[email protected]> wrote:
>
Joseph Weinstein <[email protected]> wrote:
Jay Fuller wrote:
I am trying to save information to a Nested Table with type "HISTORY_NT"within "ejbStore", but
I'm getting a ClassCastException when I make this call.
ArrayDescriptor.createDescriptor("HISTORY_NT",conn); // orace.sql.ArrayDescriptor
The exact error statement is:
java.lang.ClassCastException: weblogic.jdbc20.jts.Connection
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:80)...
Hi. We currently don't have any way of offering Oracle non-standardJDBC
extensions through
our pool and jts drivers. For example, that createDescriptor call requires
a naked Oracle JDBC
connection for an argument, not a WebLogic jts or pool connection. There's
nothing we can do to
make our jts or pool connections cast directly to an Oracle class. Unless/until
we provide
you access to the underlying DBMS connection for these purposes, you
will not be able to make
these Oracle calls with a pooled connection. We need to maintain a wrapper
around any pooled
connection to be able to guarantee that when the connection is returned
to the pool, no one retains
a reference to it that is out of our control. Otherwise the next user
of the pooled connection may
have his work corrupted by a former user that mis-uses a reference to
the DBMS connection they
obtained long before. A simple example is that if we gave you access
to the Oracle connection
class to make that call, and when you were done, you closed both pool
connection (returning it
to the pool), and the DBMS connection, you would kill the pooled connection
and the next user
would get a dead pool connection. A more serious example would be if
after closing the pool
connection, you did a commit() or rollback on the DBMS connection, if
some other thread got
the pool connection before the commit/rollback you'd be trampling their
tx.
Joe
My connection statement within my EJB is:
static
new weblogic.jdbc20.jts.Driver();
private Connection getConnection()
throws SQLException
return DriverManager.getConnection("jdbc20:weblogic:jts:OraclePool",null);
I am using a database pool set up as follows.
weblogic.jdbc.connectionPool.OraclePool=\
url=jdbc:oracle:oci8:@dbname,\
driver=oracle.jdbc.driver.OracleDriver,\
loginDelaySecs=1,\
initialCapacity=4,\
maxCapacity=10,\
capacityIncrement=2,\
allowShrinking=true,\
shrinkPeriodMins=15,\
refreshMinutes=10,\
testTable=dual,\
props=user=xxxxxxxx;password=xxxxxx
I'm using WLS 5.1 sp1 and Oracle 8.1.6 and I can make the code workif I access the database
directly, but going through the jts driver there seems to be a bugin the weblogic code. I might
be wrong about this, so if someone can please point out my error Iwould appreciate it.
Jay--
PS: Folks: BEA WebLogic is in S.F., and now has some entry-level positions
for
people who want to work with Java and E-Commerce infrastructure products.
Send
resumes to [email protected]
The Weblogic Application Server from BEA
JavaWorld Editor's Choice Award: Best Web Application Server
Java Developer's Journal Editor's Choice Award: Best Web Application
Server
Crossroads A-List Award: Rapid Application Development Tools for
Java
Intelligent Enterprise RealWare: Best Application Using a ComponentArchitecture
http://weblogic.beasys.com/press/awards/index.htm
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<p>Jay Fuller wrote:
<blockquote TYPE=CITE>I am trying to save information to a Nested Table
with type "HISTORY_NT" within "ejbStore", but I'm getting a ClassCastException
when I make this call.
<p> <b>ArrayDescriptor.createDescriptor("HISTORY_NT",conn);
// </b>orace.sql.ArrayDescriptor
<p>The exact error statement is:
<br> <b>java.lang.ClassCastException:
weblogic.jdbc20.jts.Connection</b>
<br><b>
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:80)
....</b></blockquote>
<p><br>Hi. We currently don't have any way of offering Oracle non-standard
JDBC extensions through
<br>our pool and jts drivers. For example, that createDescriptor call
requires
a naked Oracle JDBC
<br>connection for an argument, not a WebLogic jts or pool connection.
There's nothing we can do to
<br>make our jts or pool connections cast directly to an Oracle class.
Unless/until we provide
<br>you access to the underlying DBMS connection for these purposes,
you
will not be able to make
<br>these Oracle calls with a pooled connection. We need to maintain
a
wrapper around any pooled
<br>connection to be able to guarantee that when the connection is returned
to the pool, no one retains
<br>a reference to it that is out of our control. Otherwise the next
user
of the pooled connection may
<br>have his work corrupted by a former user that mis-uses a reference
to the DBMS connection they
<br>obtained long before. A simple example is that if we gave you access
to the Oracle connection
<br>class to make that call, and when you were done, you closed both
pool
connection (returning it
<br>to the pool), and the DBMS connection, you would kill the pooled
connection and the next user
<br>would get a dead pool connection. A more serious example would be
if
after closing the pool
<br>connection, you did a commit() or rollback on the DBMS connection,
if some other thread got
<br>the pool connection before the commit/rollback you'd be trampling
their
tx.
<br>Joe
<blockquote TYPE=CITE><b></b>
<br>
<p>My connection statement within my EJB is:
<br> <b>static</b>
<br><b> {</b>
<br><b> new weblogic.jdbc20.jts.Driver();</b>
<br><b> }</b>
<p><b> private Connection getConnection()</b>
<br><b> throws SQLException</b>
<br><b> {</b>
<br><b> return
DriverManager.getConnection("jdbc20:weblogic:jts:OraclePool",null);</b>
<br><b> }</b>
<p>I am using a database pool set up as follows.
<br> <b> weblogic.jdbc.connectionPool.OraclePool=\</b>
<br><b> url=jdbc:oracle:oci8:@dbname,\</b>
<br><b> driver=oracle.jdbc.driver.OracleDriver,\</b>
<br><b> loginDelaySecs=1,\</b>
<br><b> initialCapacity=4,\</b>
<br><b> maxCapacity=10,\</b>
<br><b> capacityIncrement=2,\</b>
<br><b> allowShrinking=true,\</b>
<br><b> shrinkPeriodMins=15,\</b>
<br><b> refreshMinutes=10,\</b>
<br><b> testTable=dual,\</b>
<br><b> props=user=xxxxxxxx;password=xxxxxx</b>
<br>
<p>I'm using WLS 5.1 sp1 and Oracle 8.1.6 and I can make the code work
if I access the database directly, but going through the jts driverthere
seems to be a bug in the weblogic code. I might be wrong about
this,
so if someone can please point out my error I would appreciate it.
<p>Jay</blockquote>
<p>--
<p>PS: Folks: BEA WebLogic is in S.F., and now has some entry-levelpositions
for
<br>people who want to work with Java and E-Commerce infrastructureproducts.
Send
<br>resumes to [email protected]
<br>--------------------------------------------------------------------------------
<br>
The Weblogic Application Server from BEA
<br> JavaWorld Editor's
Choice Award: Best Web Application Server
<br> Java Developer's Journal Editor's Choice Award: Best Web Application
Server
<br> Crossroads A-List Award: Rapid Application
Development Tools for Java
<br>Intelligent Enterprise RealWare: Best Application Using a Component
Architecture
<br>
http://weblogic.beasys.com/press/awards/index.htm
<br> </html>
Weblogic connection pool users weblogic.jdbc.rmi.SerialConnection connection
class,
not java.sql.Connection.
Oracle oracle.sql.ArrayDescriptor.createDescriptor method tries to cast
it to
oracle.jdbc.OracleConnection which fails.
One workaround is to use Oracle connection pool.
Oracle8i JDBC Developer's Guide and Reference:
http://download-west.oracle.com/docs/cd/A81042_01/DOC/index.htm
Another workaround is to stop passing Oracle Array to the stored procedure,
pass delimited string and conver it into pl/sql Array internaly.
Here is the code we use (original sample by Tom Kyte):
CREATE OR REPLACE TYPE INT_TABLE AS TABLE OF NUMBER;
CREATE OR REPLACE
FUNCTION str2array( p_string in VARCHAR2 ) RETURN INT_TABLE
AS
l_string long default p_string || ',';
l_data INT_TABLE := INT_TABLE();
n number;
BEGIN
LOOP
EXIT WHEN l_string is null;
n := INSTR( l_string, ',' );
l_data.EXTEND;
l_data(l_data.COUNT) :=
LTRIM( RTRIM( SUBSTR( l_string, 1, n-1 ) ) );
l_string := SUBSTR( l_string, n+1 );
END LOOP;
RETURN l_data;
END;
--Unit test
SELECT * from THE ( select cast( str2array('787, 234, 12, 1024, 1,45,1231243,324235435,3436426767,0,-1,-345235')
AS INT_TABLE ) from dual ) a
--Performance test
DECLARE
it_groups INT_TABLE := INT_TABLE();
BEGIN
FOR i IN 1..1000 LOOP
it_groups:=str2array('787,234,312,787,234,312,345,235,787,235,787,234,312,335,434,235');
END LOOP;
END;
Overhead is about 1 ms to parse 16 tokens.
Hope it helps,
David
[CustomDatumExample.java] -
Connection ClassCastException trying to create ArrayDescriptor
Create a class that implements oracle.sql.CustomDatum and the toDatum() method. The OracleDriver will call this method to create your oracle.sql.ARRAY object.The just use setObject() to set the value.import oracle.sql.Datum;import oracle.jdbc.driver.OracleConnection;import oracle.sql.CustomDatum;import oracle.sql.ARRAY;import oracle.sql.ArrayDescriptor;public class OracleArray implements CustomDatum { private List data; private String sqlType; // pass in the sql name of the array public OracleArray(String sqlType, List data) { this.data = data; } public Datum toDatum(OracleConnection conn) throws SQLException { ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor(sqlType, conn); ARRAY array = new ARRAY(arrayDesc, conn, data.toArray()); return array; }
-
Java.lang.ClassCastException while creating array descriptor
( This post was moved from SQL / PLSQL forum to here )
Hi everyone, i used to pass string array from java to plsql. I wrote a java source, then i load db with loadjava. And i wrote java spec. Then i run the function but i am getting this error :
java.lang.ClassCastException
at oracle.jdbc.driver.PhysicalConnection.putDescriptor(PhysicalConnection.java:4921)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:208)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:175)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:158)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:125)
at SplitterOracle3.tokens2(SplitterOracle3.java:29)
My Java Source is :
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import oracle.sql.*;
import oracle.jdbc.driver.OracleConnection;
import oracle.jdbc.driver.OracleDriver;
public class SplitterOracle3 {
public static oracle.sql.ARRAY tokens2(String str,String delim)
try
//Class.forName("oracle.jdbc.driver.OracleDriver");
//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//Connection conn = new OracleDriver().defaultConnection( );
OracleDriver ora = new OracleDriver();
OracleConnection conn = (OracleConnection) ora.defaultConnection();
//ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor("MY_ARRAY", ((conn).getRealConnection());
//Connection conn = DriverManager.getConnection("jdbc:default:connection:");
//Connection conn = ((DelegatingConnection) getDataSource().getConnection()).getInnermostDelegate();
// get an initial context
//OracleConnection oracleConnection = (OracleConnection)WSJdbcUtil.getNativeConnection((WSJdbcConnection) wsConn);
ArrayDescriptor arraydesc =
ArrayDescriptor.createDescriptor ("ARR_VARCHAR_100", conn);
String strarr[] = new String[47];
strarr[0]="ahmet";
strarr[1]="mehmet";
int curIndex = 0;
int nextIndex = 0;
boolean nextIsLastToken = false;
int i=0;
while (true)
nextIndex = str.indexOf(delim, curIndex);
if (nextIsLastToken)
//return false;
break;
if (nextIndex == -1)
nextIsLastToken=true;
nextIndex = str.length();
strarr[i] = str.substring(curIndex, nextIndex);
curIndex = nextIndex + 1;
i++;
ARRAY dirArray = new ARRAY(arraydesc, conn, strarr);
return dirArray;*/
catch(Exception ex)
System.err.println(ex.getMessage());
ex.printStackTrace();
return null;
public static void main(String[] args)
String str="2000,2,123553168,1,10,64895,65535,27662,64860,64895,65535,27662,64860,0,,,,,,0,0,2491039806,,,,,,,,,0,0,1,,2491039106,,,,,,,,,,,,";
String strarr[] = new String[47];
long l1,l2;
int j=0;
l1 = System.currentTimeMillis();
for ( int i=0; i<20000000; i++)
strarr = tokens2(str,",");
l2 = System.currentTimeMillis();
System.out.println("Fark :"+ (l2-l1));
The line has "ArrayDescriptor.createDescriptor ("ARR_VARCHAR_100", conn);" causes this error.
java.lang.ClassCastException
at oracle.jdbc.driver.PhysicalConnection.putDescriptor(PhysicalConnection.java:4921)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:208)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:175)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:158)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:125)
at SplitterOracle3.tokens2(SplitterOracle3.java:29)
But i could not find the solution. Can you help me?
Thanks for responses.Hi,
Did you try my suggestion from Re: java.lang.ClassCastException while create array descriptor
Try replacing
oracle.jdbc.driver.OracleConnectionwith
oracle.jdbc.OracleConnectionRegards
Peter -
VArray,TypeDescriptor, Connection, TransactionManager - ClasscastException
Hi,
I have a problem with unit testing an object with a collection which is stored as a VArray in the database.
I have a datasource with a JNDIConnector. When I use an externalTransactionController I am not able to save my object. The problem is that the connection (T4CConnection) is proxied ($Proxy0). This results in a ClassCastException in the following Oracle code:
TypeDescriptor:
public void setPhysicalConnectionOf(Connection connection) {
m_conn = ((OracleConnection)connection).physicalConnectionWithin();
Is there a workaround for this?
With kind regards.This is the stacktrace:
java.lang.ClassCastException: $Proxy0
at oracle.sql.TypeDescriptor.setPhysicalConnectionOf(TypeDescriptor.java:264)
at oracle.sql.TypeDescriptor.<init>(TypeDescriptor.java:79)
at oracle.sql.ArrayDescriptor.<init>(ArrayDescriptor.java:133)
at oracle.toplink.objectrelational.ObjectRelationalDescriptor.buildFieldValueFromDirectValues(ObjectRelationalDescriptor.java:77)
at oracle.toplink.mappings.foundation.AbstractCompositeDirectCollectionMapping.writeFromObjectIntoRow(AbstractCompositeDirectCollectionMapping.java:709)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildRow(ObjectBuilder.java:753)
at oracle.toplink.internal.descriptors.ObjectBuilder.buildRow(ObjectBuilder.java:742)
at oracle.toplink.internal.queryframework.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:401)
at oracle.toplink.queryframework.InsertObjectQuery.executeCommit(InsertObjectQuery.java:60)
at oracle.toplink.internal.queryframework.DatabaseQueryMechanism.performUserDefinedWrite(DatabaseQueryMechanism.java:622)
at oracle.toplink.internal.queryframework.DatabaseQueryMechanism.performUserDefinedInsert(DatabaseQueryMechanism.java:586)
at oracle.toplink.internal.queryframework.DatabaseQueryMechanism.insertObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:479)
at oracle.toplink.queryframework.WriteObjectQuery.executeCommitWithChangeSet(WriteObjectQuery.java:110)
at oracle.toplink.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:259)
at oracle.toplink.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:47)
at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:603)
at oracle.toplink.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:519)
at oracle.toplink.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:100)
at oracle.toplink.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:72)
at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2532)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:981)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:938)
at oracle.toplink.internal.sessions.CommitManager.commitNewObjectsForClassWithChangeSet(CommitManager.java:240)
at oracle.toplink.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:161)
at oracle.toplink.publicinterface.Session.writeAllObjectsWithChangeSet(Session.java:3123)
at oracle.toplink.publicinterface.UnitOfWork.commitToDatabase(UnitOfWork.java:1242)
at oracle.toplink.publicinterface.UnitOfWork.commitToDatabaseWithChangeSet(UnitOfWork.java:1330)
at oracle.toplink.publicinterface.UnitOfWork.issueSQLbeforeCompletion(UnitOfWork.java:2799)
at oracle.toplink.publicinterface.UnitOfWork.issueSQLbeforeCompletion(UnitOfWork.java:2779)
at oracle.toplink.transaction.AbstractSynchronizationListener.beforeCompletion(AbstractSynchronizationListener.java:96)
at oracle.toplink.transaction.JTASynchronizationListener.beforeCompletion(JTASynchronizationListener.java:55)
at oracle.toplink.internal.ejb.cmp3.transaction.base.TransactionImpl.commit(TransactionImpl.java:195)
at oracle.toplink.internal.ejb.cmp3.transaction.base.TransactionManagerImpl.commit(TransactionManagerImpl.java:68)
at nl.politie.isc.nlsis.domain.dao.varray.BootMotorVArrayTest.testSave(BootMotorVArrayTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) -
JGeometry / oracle.jdbc.OracleDriver ClassCastException
Hi-
I can't seem to store my JGeometry (from the SDO API) back to the database. The code that causes the problem is this:
===== Sample Code ========
import oracle.jdbc.OracleConnection;
OracleConnection oc = (OracleConnection) st.getConnection();
STRUCT struct = JGeometry.store((JGeometry)value,oc);
==========================
That last line of code throws this error:
===== Exception ============
05/01/04 16:50:26 [ERROR] ResultForm - Could not save the ResultBean <java.lang.ClassCastException>java.lang.ClassCastException
at oracle.jdbc.driver.OracleConnection.unwrapCompletely(OracleConnection.java:5075)
at oracle.jdbc.driver.OracleConnection.physicalConnectionWithin(OracleConnection.java:5126)
at oracle.sql.TypeDescriptor.setPhysicalConnectionOf(TypeDescriptor.java:494)
at oracle.sql.TypeDescriptor.<init>(TypeDescriptor.java:147)
at oracle.sql.ArrayDescriptor.<init>(ArrayDescriptor.java:186)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:118)
at oracle.spatial.geometry.JGeometry.createDBDescriptors(JGeometry.java:1323)
at oracle.spatial.geometry.JGeometry.store(JGeometry.java:1257)
at gov.usgswim.wdnr.fishform.GeometryType.nullSafeSet(GeometryType.java:54)
=========================
It looks like the oracle.jdbc.driver.OracleConnection.unwrapCompletely method is assuming the connection to be something that it is not - but I'm stumped without the source code.
I've seen someone speculate that this is a classloader issue, but I'd have no idea how to resolve that within OC4J.
Here is my setup:
Running from JDev 9.0.5.2 using OC4J 9.0.5.
JDBC connections are provided via JNDI by specifying the datasource thru JDev. I've tried replacing the JDBC drivers that come with OC4J with the newer versions (that is, classes12.jar --> classes14.jar)
Database version is 10.1.0.3.0
I'm pretty much stuck until I can work this out, so any help would be appreciated.
Thanks in advance,
Eric EvermanHi LJ - Thanks for the reply.
I'm leaving out detail about the framework I'm working within. For instance, the full method that saves the JGeometry back to the db is part of a Hibernate UserType for which I can't change the method signiture - thus the PreparedStatement.getConnection(). The full method looks like this:
=========== Java Method =================
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
STRUCT struct = null;
if (value != null) {
if (value instanceof JGeometry) {
JGeometry jg = (JGeometry)value;
System.out.println("Storing a Geom object to the db. Info:");
System.out.println(" Type: " + jg.getType());
System.out.println(" # of points: " + jg.getNumPoints());
System.out.println(" isPoint: " + jg.isPoint());
System.out.println(" X, Y: " + jg.getFirstPoint()[0] + ", " + jg.getFirstPoint()[1]);
//System.out.println(" elemInfo length: " + jg.getElemInfo().length); (throws error)
OracleConnection oc = (OracleConnection) st.getConnection();
struct = JGeometry.store(jg,oc);
} else {
throw new HibernateException("Cannot set GeometryType value to " + value.getClass().getName());
} //keep null value
st.setObject(index, struct);
==================================
==== Typical Output ==============
05/01/04 20:53:08 Storing a Geom object to the db. Info:
05/01/04 20:53:08 Type: 1
05/01/04 20:53:08 # of points: 1
05/01/04 20:53:08 isPoint: true
05/01/04 20:53:08 X, Y: 385343.3057, 562597.748
==================================
I've no reason to think that the connection I'd get from the prepared statement would be anything other then the connection returned from JNDI, but I'll try a simplified test to make sure.
My Geom is point data - would I expect JGeometry.getElemInfo() to return null in that case? Currently it does return null immediately after I load the JGeom from the database. -
ClassCastException in method declaration in JSP page??
i keep getting this ClassCastException in my jsp page. The line that
is apparently the problem is the <%! where the method declaration
starts. I can't seem to figure out why this is happening, can someone
please help? Here is the full code:
java.lang.ClassCastException
at quickfix0itm_0submit__jsp.addUpdate(/epsc/quickfix_itm_submit.jsp:25)
at quickfix0itm_0submit__jsp._jspService(/epsc/quickfix_itm_submit.jsp:165)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:506)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:344)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:534)
<%
if ( (session.getAttribute("setID") == null ) || ( !session.getAttribute("setID").equals(session.getId()) ))
out.write("You are either not logged in or your session has timed out due to inactivity.<BR>"
+ "Please <a href=\"index.jsp\">return to the login screen</a> and login again<BR><BR>");
else
%>
<%@ page language=java %>
<%@ page import='java.sql.*' %>
<%@ page import='javax.sql.*' %>
<%@ page import='javax.naming.*' %>
<%@ page import='java.io.*' %>
<%@ page import='java.util.Hashtable' %>
<%@ page import='java.util.Vector' %>
<%@ page import='java.util.Enumeration' %>
<%@ page import='java.util.Calendar' %>
<%@ page import='java.util.GregorianCalendar' %>
<%!
private void addUpdate(String[] tmpP, String[] UIDs, String curName, String colName, String lastIdx, Hashtable uid_updates)
if (curName.equals(colName))
for (int c = 0; c < UIDs.length; c++)
Object[] tmp = (Object[])uid_updates.get(UIDs[c]);
Vector colNames = new Vector();
Vector colValues = new Vector();
if (tmp == null)
tmp = new Object[2];
else
colNames = (Vector)tmp[0];
colValues = (Vector)tmp[1];
String updateVal = tmpP[0];
colNames.add(curName);
colValues.add(updateVal);
tmp[0] = colNames;
tmp[1] = colValues;
uid_updates.remove(UIDs[c]);
uid_updates.put(UIDs[c], tmp);
else
int uidIdx = curName.lastIndexOf(lastIdx);
String uidcode = curName.substring(uidIdx + 1);
Object[] tmp = (Object[])uid_updates.get(uidcode);
Vector colNames = new Vector();
Vector colValues = new Vector();
if (tmp == null)
tmp = new Object[2];
else
colNames = (Vector)tmp[0];
colValues = (Vector)tmp[1];
//String[] tmpP = request.getParameterValues(curName);
String updateVal = tmpP[0];
colNames.add(colName);
colValues.add(updateVal);
tmp[0] = colNames;
tmp[1] = colValues;
uid_updates.remove(uidcode);
uid_updates.put(uidcode, tmp);
%>
<%
String ss = "0";
String force_noon = "0";
String qfix_duration = "2";
int qfixd = 2;
String mod_keys = "";
String[] mktmp = request.getParameterValues("mod_keys");
if (mktmp == null)
out.print("Error! Please go back and try again.");
else
mod_keys = mktmp[0];
Hashtable uid_updates = new Hashtable();
String[] UIDs = new String[1];
if (mod_keys.equals("1"))
UIDs = request.getParameterValues("UID");
for (int storeUIDs = 0; storeUIDs < UIDs.length; storeUIDs++)
Vector tmp = new Vector();
uid_updates.put(UIDs[storeUIDs], tmp);
Enumeration cols = request.getParameterNames();
while (cols.hasMoreElements())
String curName = (String)cols.nextElement();
if (curName.indexOf("BusName") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "BusName", "e", uid_updates);
else if (curName.equals("ss"))
String[] asdfadf = request.getParameterValues(curName);
if (asdfadf != null)
ss = "1";
else
ss = "0";
else if (curName.equals("force_noon"))
String[] asdfadf = request.getParameterValues(curName);
force_noon = asdfadf[0];
else if (curName.equals("qfix_duration"))
String[] asdfadf = request.getParameterValues(curName);
qfix_duration = asdfadf[0];
qfixd = Integer.parseInt(qfix_duration);
else if (curName.indexOf("DisplayLine") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "DisplayLine", "e", uid_updates);
else if (curName.indexOf("CityName") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "CityName", "e", uid_updates);
else if (curName.indexOf("PAC") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "PAC", "C", uid_updates);
else if (curName.indexOf("ProvDisp") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "ProvDisp", "p", uid_updates);
else if (curName.indexOf("TeleNum") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "TeleNum", "m", uid_updates);
else if (curName.indexOf("ProvCode") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "ProvCode", "e", uid_updates);
else if (curName.indexOf("Dircode") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "Dircode", "e", uid_updates);
else if (curName.indexOf("Hdgcode") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "Hdgcode", "e", uid_updates);
else if (curName.indexOf("EMail") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "EMail", "l", uid_updates);
else if (curName.indexOf("URL") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "URL", "L", uid_updates);
else if (curName.indexOf("DispAd") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "DispAd", "d", uid_updates);
else if (curName.indexOf("TOPlus") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "TOPlus", "s", uid_updates);
else if (curName.indexOf("EStore") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "EStore", "e", uid_updates);
else if (curName.indexOf("HSLINE_EN") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "HSLINE_EN", "N", uid_updates);
else if (curName.indexOf("HSLINE_FR") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "HSLINE_FR", "R", uid_updates);
else if (curName.indexOf("MtlPlus") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "MtlPlus", "s", uid_updates);
else if (curName.indexOf("CalPlus") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "CalPlus", "s", uid_updates);
else if (curName.indexOf("EdmPlus") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "EdmPlus", "s", uid_updates);
else if (curName.indexOf("VanPlus") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "VanPlus", "s", uid_updates);
else if (curName.indexOf("DEALER_LOCATOR") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "DEALER_LOCATOR", "R", uid_updates);
long curTime = System.currentTimeMillis();
long monthMS = 2629743832L;
long expLength = monthMS * qfixd;
long expTime = curTime + expLength;
java.sql.Date d1 = new java.sql.Date(System.currentTimeMillis());
String Start_Date = d1.toString();
d1 = new java.sql.Date(expTime);
String Expiry_Date = d1.toString();
Context env1 = (Context) new InitialContext().lookup("java:comp/env");
DataSource source1 = (DataSource) env1.lookup("jdbc/epsc");
Connection conn1 = source1.getConnection();
String Pub_ID = "";
try {
Enumeration uidKeys = uid_updates.keys();
while (uidKeys.hasMoreElements())
String Unique_ID = (String)uidKeys.nextElement();
Object[] updateData = (Object[])uid_updates.get(Unique_ID);
Vector colNames = (Vector)updateData[0];
Vector colValues = (Vector)updateData[1];
String selectRecord = "SELECT * from epsc_ypca WHERE Unique_ID='" + Unique_ID + "';";
Statement getRecord = conn1.createStatement();
ResultSet returned = getRecord.executeQuery(selectRecord);
Pub_ID = returned.getString("Pub_ID");
boolean createDelete = false;
String updateString = "";
for (int b = 0; b < colNames.size(); b++)
if (b != 0)
updateString = updateString + ", ";
String colName = (String)colNames.get(b);
String colVals = (String)colValues.get(b);
if (colName.equals("BusName") || colName.equals("DisplayLine") || colName.equals("ProvDisp") || colName.equals("CityName") || colName.equals("PAC") || colName.equals("TeleNum"))
if (!((returned.getString(colName)).equals(colVals)))
createDelete = true;
updateString = updateString + colName + "='" + colVals + "'";
if (createDelete)
//create delete
String delFromQuickfixes = "DELETE FROM epsc_quickfixes WHERE Start_Date='" + Start_Date + "' AND Pub_ID='" + Pub_ID + "' AND QFix_Type='2';";
Statement delItm = conn1.createStatement();
delItm.execute(delFromQuickfixes);
String insertQfixDel = "INSERT INTO epsc_quickfixes SELECT *, '0' as UID, '" + Start_Date + "' as Start_Date, '" + Expiry_Date + "' as Expiry_Date, '2' as QFix_Type, '0' as ss, '" + force_noon + "' as force_noon FROM epsc_ypca WHERE Pub_ID='" + Pub_ID + "' AND (Record_Ind='2' OR Record_Ind='4' OR Record_Ind='6');";
Statement insertQFDEL = conn1.createStatement();
insertQFDEL.execute(insertQfixDel);
String updateRecords = "UPDATE epsc_ypca SET " + updateString + " WHERE Unique_ID='" + Unique_ID + "';";
String selectAndInsert = "INSERT INTO epsc_quickfixes SELECT *, '0' as UID, '" + Start_Date + "' as Start_Date, '" + Expiry_Date + "' as Expiry_Date, '3' as QFix_Type, '" + ss + "' as ss, '" + force_noon + "' as force_noon FROM epsc_ypca WHERE Pub_ID='" + Pub_ID + "';";
Statement insertIntoQfix = conn1.createStatement();
insertIntoQfix.execute(selectAndInsert);
out.write("Quickfix Successfully submitted.<BR><BR>\r\n");
catch (SQLException e)
out.write("<h1>SQL ERROR: " + e.getMessage() + "<BR><BR>Please report to administrator</h1>");
finally{
conn1.close();
%>
<BR><BR>[ <a href="menu.jsp">Return To Main</a> ]
</center>
</BODY>
</HTML>
<%
%>it is the exact same as the one i originally posted:
500 Servlet Exception
java.lang.ClassCastException
at quickfix0itm_0submit__jsp.addUpdate(/epsc/quickfix_itm_submit.jsp:24)
at quickfix0itm_0submit__jsp._jspService(/epsc/quickfix_itm_submit.jsp:169)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:506)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:344)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:534) -
ClassCastException while inserting in oracle.sql.BLOB
Hi,
I have to insert a blob data in to database . I wrote the code . I'm having a ClassCastException problem in the line oracle.sql.BLOB blob = oracle.sql.BLOB.createTemporary(st.getConnection(), false,
oracle.sql.BLOB.DURATION_CALL); while trying to store a BLOB value I'm using Oracle 9i. (JDBC classes12.jar).
if I use the method with a dedicated database connection that specifies the driver as oracle.jdbc.driver.OracleDriver there is no problem .
But when I use JBoss to run , I will get ClassCastException
I imagine that somewhere in the code of this method there is a cast of the underlying connection leading to the ClassCastException when used in conjunction with the jboss datasource. The code to save the BLOB is as follows:
String sql = " update test set code = ? where id = ? ";
BLOB newBlob = BLOB.createTemporary(dbcon, false, BLOB.DURATION_CALL);
newBlob.putBytes(1,data.getBytes());
stmt = dbcon.prepareStatement(newsql);
stmt.setBlob(1, newBlob);
stmt.setInt(2, Studid );
stmt.executeUpdate();
stmt.close();Can any one tell me how can I get this code to work with the datasource implementation.
ThanksI think this could be a problem with the class loader . Take a look at this thread It should solve your problem.
http://forum.java.sun.com/thread.jspa?forumID=48&threadID=788715 -
I encountered a bug while using the deploytool to deploy
an EAR file to the Sun J2EE 1.3_01 server.
I submitted a bug report to Sun via the Sun Java Developer Connection.
(Sorry, it has not been assigned a BugID yet)
Question:
Does anybody know if the web container in Sun's
J2EE 1.3_01 server supports access to local enterprise beans?
Screenshots of the bug are available at
http://sync4j.sourceforge.net/deploymentbug/
Full details below....
-Sean
category: j2ee
subcategory: deployment
release: 1.3_01
hardware: x86
OSversion: windows_2000
synopsis: java.lang.ClassCastException thrown during deployment of Session bean
java -version
java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)
C:\j2sdkee1.3\bin>j2ee -version
Java 2 Enterprise Edition version 1.3_01, build 1.3_01-b01
I built a EJB 2.0 compliant stateful session bean.
The session bean has a remote interface (ISyncRemote),
a remote home interface (ISyncHomeRemote),
a local interface (ISyncLocal),
and a local home interface (ISyncHomeLocal).
I built an HTTP Servlet that is supposed to access
the Stateful Session Bean using ISyncHomeLocal and
ISyncLocal
I run "deploytool.bat" in GUI mode to perform the deployment.
During deployment, the deploytool GUI displays a message
box which states:
"There was a deployment error.
java.rmi.ServerException: RemoteException occurred in server thread;
nested exception is:
java.rmi.RemoteException: An error was encountered while loading
a web component.
Please refer to
<J2EE_HOME>/logs/<machine-name>/j2ee//j2ee/error.log
for more information. Please verify your Application with the
Verifier tool."
The "error.log" file did not contain any useful information.
I ran the J2EE "verifier.bat" tool to verify that my EAR archive is OK.
The Sun J2EE server output this error string:
"java.lang.ClassCastException:
com.sun.enterprise.deployment.EjbExternalDescriptor"
Here is the full output from the Sun J2EE server:
C:\j2sdkee1.3\bin>j2ee -verbose
J2EE server listen port: 1050
Naming service started:1050
Binding DataSource, name = jdbc/EstoreDB, url =
jdbc:cloudscape:rmi:CloudscapeDB;create=true
Binding DataSource, name = jdbc/Cloudscape, url =
jdbc:cloudscape:rmi:CloudscapeDB;create=true
Binding DataSource, name = jdbc/DB1, url =
jdbc:cloudscape:rmi:CloudscapeDB;create=true
Binding DataSource, name = jdbc/DB2, url =
jdbc:cloudscape:rmi:CloudscapeDB;create=true
Binding DataSource, name = jdbc/InventoryDB, url =
jdbc:cloudscape:rmi:CloudscapeDB;create=true
Binding DataSource, name = jdbc/XACloudscape, url = jdbc/XACloudscape__xa
Binding DataSource, name = jdbc/XACloudscape__xa, dataSource =
COM.cloudscape.core.RemoteXaDataSourc
e@245536
Starting JMS service...
Initialization complete - waiting for client requests
Binding: < JMS Destination : jms/Queue , javax.jms.Queue >
Binding: < JMS Destination : jms/Topic , javax.jms.Topic >
Binding: < JMS Cnx Factory : TopicConnectionFactory , Topic , No properties >
Binding: < JMS Cnx Factory : jms/TopicConnectionFactory , Topic , No properties
>
Binding: < JMS Cnx Factory : QueueConnectionFactory , Queue , No properties >
Binding: < JMS Cnx Factory : jms/QueueConnectionFactory , Queue , No properties
>
Starting web service at port: 8000
Starting secure web service at port: 7000
J2EE SDK/1.3
Starting web service at port: 9191
J2EE SDK/1.3
J2EE server startup complete.
Compiling c:\j2sdkee1.3\repository\rbi\gnrtrTMP\Sync4j Server enterprise
application\sync4j\server\s
yncbean\SyncBean_LocalHomeImpl.java ....
Compiling c:\j2sdkee1.3\repository\rbi\gnrtrTMP\Sync4j Server enterprise
application\sync4j\server\s
yncbean\SyncBean_EJBLocalObjectImpl.java ....
Compiling c:\j2sdkee1.3\repository\rbi\gnrtrTMP\Sync4j Server enterprise
application\sync4j\server\s
yncbean\SyncBean_RemoteHomeImpl.java ....
Compiling c:\j2sdkee1.3\repository\rbi\gnrtrTMP\Sync4j Server enterprise
application\sync4j\server\s
yncbean\SyncBean_EJBObjectImpl.java ....
rmic sync4j.server.syncbean.SyncBean_RemoteHomeImpl...
rmic sync4j.server.syncbean.SyncBean_EJBObjectImpl...
c:\j2sdkee1.3\repository\rbi\applications\Sync4j Server enterprise
application1004172068449Server.ja
r
Binding name:`java:comp/env/ejb/ISyncHomeRemote`
Binding name:`java:comp/env/ejb/ISyncHomeLocal`
java.lang.ClassCastException:
com.sun.enterprise.deployment.EjbExternalDescriptor
at com.sun.enterprise.deployment.EjbReferenceDescriptor.getValue
(EjbReferenceDescriptor.java
:202)
at com.sun.enterprise.naming.NamingManagerImpl.bindObjects
(NamingManagerImpl.java:394)
at com.sun.web.server.WebService.addContext(WebService.java:148)
at com.sun.web.server.ServletDeployerImpl.loadWebComponents
(ServletDeployerImpl.java:214)
at
com.sun.enterprise.tools.deployment.backend.JarInstallerImpl.deployWebComponent
s
(JarInsta
llerImpl.java:791)
at
com.sun.enterprise.tools.deployment.backend.JarInstallerImpl.deployApplication
(JarInstall
erImpl.java:219)
at
org.omg.stub.com.sun.enterprise.tools.deployment.backend._JarInstallerImpl_Tie.
invoke(Un
known Source)
at com.sun.corba.ee.internal.corba.ServerDelegate.dispatch
(ServerDelegate.java:355)
at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:273)
at com.sun.corba.ee.internal.iiop.RequestProcessor.process
(RequestProcessor.java:84)
at com.sun.corba.ee.internal.orbutil.ThreadPool$PooledThread.run
(ThreadPool.java:99)
Does the Sun J2EE server implementation support the invocation
of Session EJB's via a Local interface?
Does the Sun J2EE server implementation allow a Servlet to invoke
Session EJB's via the bean's Local interface?
While researching this issue, I read the J2EE 1.3 final specification.
The spec says:
"The EJB container is required to access to local enterprise beans.
We recommend that the web container also support access to local
enterprise beans."
Does the web container in Sun's J2EE server support access to local enterprise beans?I'm pretty much sure that you cannot access a
local Session bean from outside the EJB container.Please read the J2EE 1.3 specification before posting messages about EJB and J2EE.
According to the J2EE 1.3 specification:
"The EJB container is required to support access to local enterprise beans. We recommend that the web container also support access to local enterprise beans.
No support is provided for access to local enterprise beans from the application client container or the applet container."
If you use local interfaces for your session bean,
than your client must be local too. A local client is
a client that is collocated in the same JVM with the
session/entity that provides the local view and which
can be tightly coupled to the bean.My client is running in the same JVM as my EJB. The client is a servlet. The servlet is running in the same JVM as the EJB.
For what its worth, the error that I observed occurs during deployment. I haven't figured out why deployment is failing.
Maybe you are looking for
-
How to restrict user to enter duplicate items in Purchase Order Lines?
I have to do form personalization so that user cannot enter duplicate items in the PO. At when-new-item-instance in PO-Approve field, I have created a database function that is taking the count of items and returning the count value. In the condition
-
Need Affordable Capture Card CS4 Win 7 i5
I work for the government, so some things here are out of my control. In 2003, I was able to build a machine to capture TV news clips for an archive and to turn some material into web video. We also Firewire in our own material, edit and burn to DVD
-
Cannot view or download PDF's from Safari
Hi. I got a new MacBook Pro with retina display this summer... love it. A few weeks ago I joined Creative Cloud and upgraded my Adobe software; all software worked fine up to the CC upgrade. So details are: Mac OS 10.8.5, Safari 6.1, Acrobat X1 Pro.
-
Personnel number 51099402 locked by user-CAT4
HI, I am getting the message in cat4 is Personnel number 51099402 locked by user Message no. LR093 I am unable to solve the problem. Please help me. Rgds, RSV
-
How to link two text boxes so that text flows from one to the other.
In Adobe Acrobat XI Pro, I have managed to link two text boxes with JavaScript. I have deselected the "scroll long text" and selected auto text size. I have entered the script into the "custom keystroke script" if ( event.fieldFull || event.willComm