ClassCastException casting CallableStatement to OracleCallableStatement
Im trying to create a ViewObject based on a REF_CURSOR returned by PL/SQL stored procedure OUT parameter.
I casted the normal CallableStatement to OracleCallableStatement so I can call the OracleCallableStatement.getCursor(index);
CallableStatement statement = getDbTransaction.createCallableStatement(statementString, DbTransaction.DEFAULT);
ResultSet rs = ((OracleCallableStatement)statement).getCursor(1);I get a "java.lang.ClassCastException: oracle_jdbc_driver_T4CCallableStatement_Proxy" when I run this piece of code.
Jdeveloper version is Jdev10.1.3.1 Preview.
regards,
Anton
I got a resolution for this. The reason for this exception is that I got the wrong import for the OracleCallableStatement. The correct import is "import oracle.jdbc.OracleCallableStatement" instead of "import oracle.jdbc.driver.OracleCallableStatement"
See the related thread:
Re: Dive into BC4J related --REF CURSOR (executeQueryForCollection)
regards,
Anton
Similar Messages
-
ClassCastException casting CallableStatement into OracleCallableStatement
Well, i have configured Jakarta DBCP 1.1 with Jakarta Tomcat 4.1.29, JDK 1.4.2, with a database Oracle 9i over Win32 Platform.
Everything works fine if i use Statements and make SQL sentences. But when i try to execute a stored procedure with a callable statement, i need to pass it a CLOB parameter, so i need to cast a CallableStatement into a OracleCallableStatement, to use the Oracle Extensions. This process makes a ClassCastException.
This process works fine without DBCP, using just a connection, but fails when use DBCP connection pool.
I have tried to cast the Connection into OracleConnection that i get from the pool, but i get the same error. Also I have checked Connection is not null and connection works.
Could anyone gimme a solution? Thanx for your help!Can't you use method getClob from CallableStatement, and then pass the data to the clob using setCharacterStream(...)?
BTW, I think DBCP wraps the genuine Oracle classes, which is the reason that your objects are not instances of Oracles classes. -
ClassCastException casting to a OracleConnection in Jdeveloper
Hi all,
Figured somebody on the list may know the answer to this one. Sounds to me like configuration step that I am missing.
I am running jdev 9031
I get a
java.lang.ClassCastException: com.evermind.sql.OrclCMTConnection
at tv.thirdspace.ova.debug.QueryTag.doEndTag(QueryTag.java:132)
at jsps.debug._debug._jspService(debug.jsp:24)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:139)
at run time when I execute a jsp tag lib.
I am doing the following in the tag lib
try {
Context env = (Context) new InitialContext().lookup("java:comp/env");
ds = (DataSource) env.lookup("jdbc/TestConnectionPool");
}catch (NamingException e) {System.out.println(e.getMessage());}
conn = (OracleConnection)ds.getConnection();
It is failing when I attempt to cast the connection as a OracleConnection.
The data-sources.xml has the following datasource definition
<data-source
class="com.evermind.sql.DriverManagerDataSource"
name="TestConnectionPool"
location="jdbc/TestConnectionPool"
xa-location="jdbc/xa/OracleXADS"
ejb-location="jdbc/TestConnectionPool"
connection-driver="oracle.jdbc.driver.OracleDriver"
username="scott"
password="tiger"
url="jdbc:oracle:thin:@infinity:1521:test"
inactivity-timeout="30"
/>
What am I missing??
- ManishIn the current version there is a restriction that you can only really have one (diagrammed) Struts configuration per project, as such we disable the option to create a new pageflow in the New gallery. What may be happening is that we're not recognising the fact that the existing xml file is a struts config (maybe the <!DOCTYPE > is wrong / missing? ) so we allow you to add a second and that messes things up.
See:
http://www.oracle.com/technology/products/jdev/howtos/10g/StrutsMultiConfigs/struts_multiconfig_howto.html -
I am trying to send an array to a pl/sql module but for some reason i am unable to get the connection object.
Here is the line of code that fails
Connection conn = null;
ArrayDescriptor rectabDescriptor = ArrayDescriptor.createDescriptor("CCS21_CONSIGNMENTLIST_TYPE",conn); <<FAILS HERE<<
ARRAY awbNoHwbs = new ARRAY(rectabDescriptor,conn,childLessAwbs);
ARRAY hwbs = new ARRAY(rectabDescriptor,conn,hwbList);
OracleCallableStatement cst = (OracleCallableStatement)conn.prepareCall(stp.SUBMIT_CONSIGNMENT_STORED_PROC);
Here is the stack trace
java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.DelegatingCallableStatement
at com.acbt.ccstt.data.accessors.ConsignmentDAO.submitDeclaration(ConsignmentDAO.java:301)
at com.acbt.ccstt.presentation.events.consignments.select.SubmitDeclaration.midAction(SubmitDeclaration.java:68)
at com.acbt.ccstt.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:36)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)And here is my connection config
Struts Web.xml file
<resource-ref>
<description>Oracle Datasource</description>
<res-ref-name>jdbc/ccs21db</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>Metainf/context.xml
<Resource name="jdbc/thedb" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:dbsid"
username="xxx" password="xxx" maxActive="20" maxIdle="10"
maxWait="-1"/> Edited by: ziggy on Sep 26, 2008 4:02 PMziggy wrote:
OracleCallableStatement cst = (OracleCallableStatement)conn.prepareCall(stp.SUBMIT_CONSIGNMENT_STORED_PROC);
java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.DelegatingCallableStatement
Why are you casting CallableStatement to OracleCallableStatement? The JDBC API is intented to be completely implementation independent. Never cast interfaces to implementation specific classes, it will break your app sooner or later. -
ClassCastException with OracleCallableStatement
Hi,
I am porting our application from WLS6.0 sp2 to WLS6.1 and have encountered the
above error. As far as I can see, nothing in our code has changed (I just rebuilt
against the WLS6.1 libraries and deployed to the new server)
Thanks for any help.
Gino
Stack trace below :
java.sql.SQLException: java.lang.ClassCastException: oracle.jdbc.driver.OracleCallableStatement
at weblogic.jdbc.jts.CallableStatement.clearParameters(CallableStatement.java:220)
at weblogic.jdbc.rmi.internal.CallableStatementImpl.clearParameters(CallableStatementImpl.java:368)
at weblogic.jdbc.rmi.SerialCallableStatement.clearParameters(SerialCallableStatement.java:444)
at com.banctec.caseware.server.dbaccess.dao.helper.DaoParameterHelper.bindToStatement(DaoParameterHelper.java:977)
at com.banctec.caseware.server.dbaccess.dao.helper.DaoParameterHelper.bindToStatement(DaoParameterHelper.java:1170)
at com.banctec.caseware.server.dbaccess.dao.CaseDAOOracle.insertRow(CaseDAOOracle.java:126)
at com.banctec.caseware.server.dbaccess.dao.CaseDAO.insert(CaseDAO.java:190)
at com.banctec.caseware.server.dbaccess.DBAccessBean.insert(DBAccessBean.java:243)
at com.banctec.caseware.server.dbaccess.DBAccessBean_m9wwam_EOImpl.insert(DBAccessBean_m9wwam_EOImpl.java:389)
at com.banctec.caseware.server.casehandler.CaseHandlerBean.createResource(CaseHandlerBean.java:1286)
at com.banctec.caseware.server.casehandler.CaseHandlerBean_nn9cfa_EOImpl.createResource(CaseHandlerBean_nn9cfa_EOImpl.java:475)
at com.banctec.caseware.server.cpc.CPCBean.createResource(CPCBean.java:682)
at com.banctec.caseware.server.cpc.CPCBean_1fna_EOImpl.createResource(CPCBean_1fna_EOImpl.java:387)
at com.banctec.caseware.server.cpc.CPCBean_1fna_EOImpl_WLSkel.invoke(Unknown
Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:288)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:257)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)http://e-docs.bea.com/wls/docs60/notes/issues.html#1024261
Oracle offers several non-standard (not approved by Sun) extensions to JDBC:
OracleConnection
OracleStatement
OracleResultSet
OraclePreparedStatement
OracleCallableStatement
If a user attempts to use these classes within an application that gets its
connection using WebLogic Server JDBC, they will not work.
"Gino Coccia" <[email protected]> wrote in message
news:[email protected]...
>
Hi,
I am porting our application from WLS6.0 sp2 to WLS6.1 and haveencountered the
above error. As far as I can see, nothing in our code has changed (I justrebuilt
against the WLS6.1 libraries and deployed to the new server)
Thanks for any help.
Gino
Stack trace below :
java.sql.SQLException: java.lang.ClassCastException:oracle.jdbc.driver.OracleCallableStatement
atweblogic.jdbc.jts.CallableStatement.clearParameters(CallableStatement.java:2
20)
atweblogic.jdbc.rmi.internal.CallableStatementImpl.clearParameters(CallableSta
tementImpl.java:368)
atweblogic.jdbc.rmi.SerialCallableStatement.clearParameters(SerialCallableStat
ement.java:444)
atcom.banctec.caseware.server.dbaccess.dao.helper.DaoParameterHelper.bindToSta
tement(DaoParameterHelper.java:977)
atcom.banctec.caseware.server.dbaccess.dao.helper.DaoParameterHelper.bindToSta
tement(DaoParameterHelper.java:1170)
atcom.banctec.caseware.server.dbaccess.dao.CaseDAOOracle.insertRow(CaseDAOOrac
le.java:126)
atcom.banctec.caseware.server.dbaccess.dao.CaseDAO.insert(CaseDAO.java:190)
atcom.banctec.caseware.server.dbaccess.DBAccessBean.insert(DBAccessBean.java:2
43)
atcom.banctec.caseware.server.dbaccess.DBAccessBean_m9wwam_EOImpl.insert(DBAcc
essBean_m9wwam_EOImpl.java:389)
atcom.banctec.caseware.server.casehandler.CaseHandlerBean.createResource(CaseH
andlerBean.java:1286)
atcom.banctec.caseware.server.casehandler.CaseHandlerBean_nn9cfa_EOImpl.create
Resource(CaseHandlerBean_nn9cfa_EOImpl.java:475)
atcom.banctec.caseware.server.cpc.CPCBean.createResource(CPCBean.java:682)
atcom.banctec.caseware.server.cpc.CPCBean_1fna_EOImpl.createResource(CPCBean_1
fna_EOImpl.java:387)
atcom.banctec.caseware.server.cpc.CPCBean_1fna_EOImpl_WLSkel.invoke(Unknown
Source)
atweblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:288)
atweblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
:93)
atweblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:257)
atweblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:2
2)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120) -
CastCastException with OracleCallableStatement
I'm trying to use Oracle JDBC extensions with the Oracle thin Driver (to
read a cursor returned by a PL/SQL function). When I attempt to cast a
CallableStatement to an weblogic.jdbc.vendor.oracle.OracleCallableStatement,
the weblogic wrapper class, I still get the same ClassCastException as if I
try to cast to a vanilla OracleCallableStatement. I thought the weblogic
class was the fix to this problem.
Code is:
ResultSet rs =
((weblogic.jdbc.vendor.oracle.OracleCallableStatement)cs).getCursor(1);
Exception is:
java.sql.SQLException: java.lang.ClassCastException:
oracle.jdbc.driver.OracleCallableStatement
It's interesting that the exception is for
oracle.jdbc.driver.CallableStatement, even though I'm casting to the
Weblogic wrapper class.
Weblogic version is 6.1 sp2
Oracle is 8.1.6
Does anyone know what's happeneng here, and how to fix it.
Any help much appreciated
JohnUnfortunatly, this doesn't work either - it doesn't understand the new type:
java.sql.SQLException: Invalid column type
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:285)
at
oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:53
40)
at
oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallab
leStatement.java:245)
at
oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallab
leStatement.java:370)
at
weblogic.jdbc.jts.Statement.registerOutParameter(Statement.java:973)
at
weblogic.jdbc.rmi.internal.CallableStatementImpl.registerOutParameter(Callab
leStatementImpl.java:53)
at
weblogic.jdbc.rmi.SerialCallableStatement.registerOutParameter(SerialCallabl
eStatement.java:48)
at com.bluedot.beans.support.ProcedureBuffer.executeFunction(Unknown
Source)
at
com.bluedot.beans.support.ProcedureBuffer.executeTagSetFunction(Unknown
Source)
at
com.bluedot.beans.entityManagement.EntityManagementServerBean.getExhibitorSt
ats(Unknown Source)
at
com.bluedot.beans.entityManagement.EntityManagementServerBean_7yjcm7_EOImpl.
getExhibitorStats(EntityManagemen
tServerBean_7yjcm7_EOImpl.java:37)
etc
"Slava Imeshev" <[email protected]> wrote in message
news:[email protected]...
OK. Now it's clear. You can not use OracleTypes.CURSOR.
In order to get a result set from cursor, the right sequence
should be following:
cs.registerOutParameter(1, java.sql.Types.OTHER);
cs.execute();
ResultSet rs = cstmt.getResultSet(1);
Regards,
Slava Imeshev
"John Prout" <[email protected]> wrote in message
news:[email protected]...
Slava
Here's part of the stack trace - the whole thing is probably 100 lines:
java.sql.SQLException: java.lang.ClassCastException:
oracle.jdbc.driver.OracleCallableStatement
at
weblogic.jdbc.jts.CallableStatement.getCursor(CallableStatement.java:277)
at
weblogic.jdbc.rmi.internal.CallableStatementImpl.getCursor(CallableStatement
Impl.java:420)
at
weblogic.jdbc.rmi.SerialCallableStatement.getCursor(SerialCallableStatement.
java:496)
at
com.bluedot.beans.support.ProcedureBuffer.executeTagSetFunction(Unknown
Source)
at
com.bluedot.beans.entityManagement.EntityManagementServerBean.getExhibitorSt
ats(Unknown Source)
at
com.bluedot.beans.entityManagement.EntityManagementServerBean_7yjcm7_EOImpl.
getExhibitorStats(EntityManagemen
tServerBean_7yjcm7_EOImpl.java:421)
at
com.bluedot.beans.entityManagement.EntityManagementServerBean_7yjcm7_EOImpl_
WLSkel.invoke(Unknown Source)
at
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:296)
As you can see, the PL/SQL code is being called from an EJB.
The connection is obtained through JNDI:
java.sql.Connection conn = null;
Hashtable ht = new Hashtable() ;
ht.put( Context.INITIAL_CONTEXT_FACTORY ,
"weblogic.jndi.WLInitialContextFactory" );
InitialContext ctx = new InitialContext( ht ) ;
if ( ctx == null ) return null ;
String dataSource = getUserSession().getDatabase() ;
javax.sql.DataSource source = (javax.sql.DataSource) ctx.lookup(
dataSource ) ;
if ( source != null )
conn = source.getConnection() ;
Then the CallableStatement is obtained and used:
OracleConnection con = null ;
OracleCallableStatement cs = null ;
Object returnValue = null;
ResultSet rs = null ;
// String in the form: { ? = call <procedure-name>[<arg1>,<arg2>,...]}
StringBuffer buff = new StringBuffer();
buff.append("{ ? = call ").append(functionName).append("()") ;
// setup mStringBuffer and mStringLength so the rest of the class will
work right
buff.getChars(0, buff.length(),mStringBuffer,0);
mStringLength = buff.length();
con = (OracleConnection)psc.getDatabaseConnection() ;
cs = (OracleCallableStatement)con.prepareCall( buff.toString() ) ;
cs.registerOutParameter(1, OracleTypes.CURSOR);
// printQuery( psc ) ;
boolean result = cs.execute() ; // It's not in the API what "result"
is...
rs =
((weblogic.jdbc.vendor.oracle.OracleCallableStatement)cs).getCursor(1);
The exception happens when I call getCursor(1)
This code works outside weblogic, using a connection I obtain usingstandard
JDBC and the Oracle thin driver.
The sample is extracted from several pieces of the real code, so therecould
be compile errors, etc
John
"Slava Imeshev" <[email protected]> wrote in message
news:[email protected]...
Hi John,
Could you post the questionable code and the full exception?
From information provided it's not clear whether this exception
is thown from the server or from the app.
Regards,
Slava Imeshev
"John Prout" <[email protected]> wrote in message
news:[email protected]...
I am getting a connection from a standard weblogic connection pool,
using
a
JNDI lookup. I can see no way to directly obtain a
weblogic.jdbc.vendor.oracle.OracleConnection. If I cast everything to
the
weblogic OracleConnection and OracleCallableStatement, I still get thesame
ClassCastException
Can you post an example of how to get the
weblogic.jdbc.vendor.oracle.OracleConnection
Thanks
John
"Slava Imeshev" <[email protected]> wrote in message
news:[email protected]...
Hi John,
This exception is thrown because plain oracle connection was used.
To use weblogic oracle extensions, connection should be obtained
from the connection pool, either via DataSource or directly.
Regards,
Slava Imeshev
"John Prout" <[email protected]> wrote in message
news:[email protected]...
I'm trying to use Oracle JDBC extensions with the Oracle thin Driver
(to
read a cursor returned by a PL/SQL function). When I attempt to cast a
CallableStatement to anweblogic.jdbc.vendor.oracle.OracleCallableStatement,
the weblogic wrapper class, I still get the same ClassCastException as
if
I
try to cast to a vanilla OracleCallableStatement. I thought the
weblogic
class was the fix to this problem.
Code is:
ResultSet rs =
((weblogic.jdbc.vendor.oracle.OracleCallableStatement)cs).getCursor(1);
>>>
Exception is:
java.sql.SQLException: java.lang.ClassCastException:
oracle.jdbc.driver.OracleCallableStatement
It's interesting that the exception is for
oracle.jdbc.driver.CallableStatement, even though I'm casting to the
Weblogic wrapper class.
Weblogic version is 6.1 sp2
Oracle is 8.1.6
Does anyone know what's happeneng here, and how to fix it.
Any help much appreciated
John -
Oracle callable statement problems in weblogic 5.1
Hi Benzi,
Using Oracle arrays directly will not work because most of
oracle object are not serializable. Not to mention, it's not standard.
So the onlyt way to create arrays is using strored procedures.
There are also array accessor methods supporting some oracle array
extensions, though they are not supported officially and I think they could
be avaialble in the next version of weblogic.
Regards,
Slava Imeshev
"Benzi Galili" <[email protected]> wrote in message
news:[email protected]...
>
Hi Ravi,
Did you ever find a solution? We are running into the same problem withWLS 6.x,
and it seems like we can't get it to use Oracle's thin JDBC properly froma pool
configuration.
Thanx,
Benzi
"Ravi Sundar" <[email protected]> wrote:
e are using the TxDataSource obtained from weblogic connection pool.
Details are shown below:
weblogic.jdbc.connectionPool.oraclePool=\
url=jdbc:oracle:thin:@sirius:1521:sirora,\
driver=oracle.jdbc.driver.OracleDriver,\
loginDelaySecs=0,\
initialCapacity=2,\
maxCapacity=50,\
capacityIncrement=5,\
allowShrinking=true,\
shrinkPeriodMins=10,\
refreshMinutes=5,\
testTable=dual,\
props=user=mrt3c;password=mrt3c
weblogic.allow.reserve.weblogic.jdbc.connectionPool.oraclePool=\
everyone
weblogic.allow.reset.weblogic.jdbc.connectionPool.oraclePool=\
everyone
weblogic.allow.shrink.weblogic.jdbc.connectionPool.oraclePool=\
everyone
weblogic.jdbc.TXDataSource.oracleDataSource=oraclePool
Next we use the following to obtain a connection:
private Connection getConnection() throws Exception{
InitialContext lvObjCtx = new InitialContext();
DataSource lvObjDs = (DataSource)lvObjCtx.lookup("oracleDataSource");
return lvObjDs.getConnection();
We need to pass an array as IN parameter to oracle stored
procedure. We use the following code in a stateless session ejb:
public Vector insertBranchDetails(int lvIntMapId, int lvIntBranchId,
int
lvIntHierarchyLevel, int lvIntRoleId, String[] lvStrArrBranchId, String[]
lvStrArrBranchName, String[] lvStrArrBranchOrder, String[]
lvStrArrStudentsWeight, String[] lvStrArrDescription, String[]
lvStrArrTimeValue, String[] lvStrArrTimeUnits, String[]
lvStrArrEditorsWeight, String[] lvStrArrExpertsWeight, String[]
lvStrArrExpertsName, String lvStrUserId) throws RemoteException{
OracleCallableStatement lvObjCs = null;
Connection lvObjConn = null;
try{
lvObjConn = ConnectionPool.getConnection();
lvObjCs = (OracleCallableStatement)lvObjConn.prepareCall("{call
PROC_INS_UPD_BRANCHES_01(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
ArrayDescriptor lvObjAs = new ArrayDescriptor("ARRAY_VARCHAR2_4000",
lvObjConn);
/* ARRAY_VARCHAR2_4000 is a SQLTABLE */
ARRAY lvObjBranchId = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrBranchId);
ARRAY lvObjBranchName = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrBranchName);
ARRAY lvObjBranchOrder = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrBranchOrder);
ARRAY lvObjStudentsWeight = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrStudentsWeight);
ARRAY lvObjDescription = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrDescription);
ARRAY lvObjTimeValue = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrTimeValue);
ARRAY lvObjTimeUnits = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrTimeUnits);
ARRAY lvObjEditorsWeight = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrEditorsWeight);
ARRAY lvObjExpertsWeight = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrExpertsWeight);
ARRAY lvObjExpertsName = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrExpertsName);
lvObjCs.setInt(1, lvIntMapId);
lvObjCs.setInt(2, lvIntBranchId);
lvObjCs.setInt(3, lvIntHierarchyLevel);
lvObjCs.setInt(4, lvIntRoleId);
lvObjCs.setString(5, lvStrUserId);
lvObjCs.setARRAY(6, lvObjBranchId);
lvObjCs.setARRAY(7, lvObjBranchName);
lvObjCs.setARRAY(8, lvObjBranchOrder);
lvObjCs.setARRAY(9, lvObjStudentsWeight);
lvObjCs.setARRAY(10, lvObjTimeValue);
lvObjCs.setARRAY(11, lvObjTimeUnits);
lvObjCs.setARRAY(12, lvObjDescription);
lvObjCs.setARRAY(13, lvObjEditorsWeight);
lvObjCs.setARRAY(14, lvObjExpertsWeight);
lvObjCs.setARRAY(15, lvObjExpertsName);
lvObjCs.registerOutParameter(16, Types.INTEGER);
lvObjCs.registerOutParameter(17, Types.VARCHAR);
lvObjCs.execute();
int lvIntErrorNumber = lvObjCs.getInt(16);
String lvStrErrorDescription = lvObjCs.getString(17);
if((lvIntErrorNumber % 10) == 1){
throw new AppServerException("Error Number: " + lvIntErrorNumber +
Error Description: " + lvStrErrorDescription);
Vector lvVecData = new Vector();
lvVecData.addElement(new Integer(lvIntErrorNumber));
lvVecData.addElement(lvStrErrorDescription);
return lvVecData;
}catch(Exception lvObjEx){
throw new AppServerException(lvObjEx);
}finally{
try{
if(lvObjCs != null){
lvObjCs.close();
if(lvObjConn != null){
ConnectionPool.returnConnection(lvObjConn);
}catch(Exception lvObjEx){
When this method is called from the client we get the following error:
java.lang.ClassCastException: weblogic.jdbc20.rmi.SerialCallableStatement
This occurs when we try to cast the CallableStatement to
OracleCallableStatement. Without casting to OracleCallableStatement
we cannot pass arrays as IN parameters to oracle stored procedures.
The method works well if we use the following code to obtain the
connection:
>>
private Connection getConnection() throws Exception{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
DriverManager.getConnection("jdbc:oracle:thin:@sirius:1521:sirora",
"mrt3c", "mrt3c");
But the problem is, this connection does not support transactions
Please help -
I am trying to set up a client server RMI connection, but i get the following error when running the server. I am new to using RMI so any help would be great, thanks so much,
Fred
Exception in thread "main" java.lang.ClassCastExcepti
cast to IMServer
at OutwardFacing.main(OutwardFacing.java:14)
here is my code:
import java.rmi.*;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class OutwardFacing {
public static void main(String[] args)
//get the remote object from the registry
try
String url = "//localhost/server1";
**14** IMServer server1 = (IMServer)Naming.lookup(url);
System.out.println("Got remote object");
server1.Register("fred", "password");
server1.ListRegistered();
catch (RemoteException exc)
System.out.println("Error in lookup: " + exc.toString());
catch (java.net.MalformedURLException exc)
System.out.println("Malformed URL: " + exc.toString());
catch (java.rmi.NotBoundException exc)
System.out.println("NotBound: " + exc.toString());
}Cast the object you're looking up to the remote interface it implements, not to the type of the implementation class.
-
CLassCastException with oracle.jdbc.driver.OracleCallableStatement
Hello,
I get a ClassCastException when I try to execute a Stored Procedure with WL6.1
and the JDriver.
I have a servlet who intanciate a Bean and call to his execute() method in this
way:
Context ctx = null;
Hashtable ht = new Hashtable();
Connection conn = null;
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
try {
ctx = new InitialContext(ht);
javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup(connPool);
conn = ds.getConnection();
conn.setAutoCommit(true);
SvcEmpEstObt empEstObt = new SvcEmpEstObt();
empEstObt.setMaxRows(100);
empEstObt.setConnection(conn);
//Get parameters from Http Get and set the JB
empEstObt.setEmpRut(request.getParameter("rut"));
empEstObt.setEmpTimeStamp(request.getParameter("timestamp"));
//Execute Service
empEstObt.execute();
/* ********* the execute() method of the jb is listed here */
public int execute() throws ClassNotFoundException, SQLException{
intreturnedRows = 0;
try {if (connection == null){
try {Class.forName(driver);
} catch (ClassNotFoundException e) {
System.err.println("ClassNotFoundException: " + e);
throw e;
connection = DriverManager.getConnection(url, user, password);
row = -1;
srv_message = String.valueOf(maxRows);
String sp = "{call SvcEmpEstObt_Pkg.SvcEmpEstObt(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}";
oracle.jdbc.driver.OracleCallableStatement procout = (oracle.jdbc.driver.OracleCallableStatement)
connection.prepareCall(sp); // The exception is here
procout.registerOutParameter(1, Types.VARCHAR);
procout.setString(1, srv_message);
procout.setString(2, empRut);
procout.setString(3, empTimeStamp);
procout.registerOutParameter(4, Types.VARCHAR);
procout.registerOutParameter(5, Types.VARCHAR);
procout.registerOutParameter(6, Types.INTEGER);
int elemSqlType = OracleTypes.INTEGER;
int elemMaxLen = 0;
procout.registerIndexTableOutParameter(7, maxRows, elemSqlType, elemMaxLen);
elemSqlType = OracleTypes.VARCHAR;
elemMaxLen = 30;
// register the OUT parameter
procout.registerIndexTableOutParameter(8, maxRows, elemSqlType, elemMaxLen);
elemSqlType = OracleTypes.VARCHAR;
elemMaxLen = 21;
// register the OUT parameter
procout.registerIndexTableOutParameter(9, maxRows, elemSqlType, elemMaxLen);
elemSqlType = OracleTypes.INTEGER;
elemMaxLen = 0;
// register the OUT parameter
procout.registerIndexTableOutParameter(10, maxRows, elemSqlType, elemMaxLen);
// execute the call
procout.execute();
sqlWarning = procout.getWarnings();
srv_message = procout.getString(1);
returnStatus = new Integer(srv_message.substring(0,1)).intValue();
dagMessage = new DagMessage();
dagMessage.oracleMessage(srv_message);
// access the value using JDBC default mapping
empEstTitulo = procout.getString(4);
empEstUniv = procout.getString(5);
empEstNivel = procout.getInt(6);
curCodigo = (BigDecimal[]) procout.getPlsqlIndexTable(7);
curNombre = (String[]) procout.getPlsqlIndexTable(8);
curFecha = (String[]) procout.getPlsqlIndexTable(9);
curDuracion = (BigDecimal[]) procout.getPlsqlIndexTable(10);
// close the statement
procout.close();
if (curCodigo == null) {
return 0;
} else {
return curCodigo.length;
} catch (SQLException e) {
SQLException ex = e;
System.err.println("\n--- SQLException caught ---\n");
while (ex != null) {
System.err.println("Message: " + ex.getMessage ());
System.err.println("SQLState: " + ex.getSQLState ());
System.err.println("ErrorCode: " + ex.getErrorCode ());
ex = ex.getNextException();
System.out.println("");
throw e;
Does Someone has an idea why it happens ?Hans,
Could you give us the whole text of exception?
Regards,
Slava Imeshev
"Hans" <[email protected]> wrote in message
news:[email protected]...
>
It Works! Thanx a lot ....
I was working with a previous version of my App ... I fixed the problemand now
i can Cast to weblogic.jdbc.vendor.oracle.OracleCallableStatement,
But ...
I get the following Exception:
SQL Exception:
registerIndexTableOutParameter is not supported by the
underlying JDBC driver weblogic.jdbc.pool.Connection
What I need to do ?
/* this is what i`m trying to make */
weblogic.jdbc.vendor.oracle.OracleCallableStatement procout =(weblogic.jdbc.vendor.oracle.OracleCallableStatement)
connection.prepareCall(sp);
procout.registerOutParameter(1, Types.VARCHAR);
procout.setString(1, srv_message);
procout.setString(2, empRut);
procout.setString(3, empTimeStamp);
procout.registerOutParameter(4, Types.VARCHAR);
procout.registerOutParameter(5, Types.VARCHAR);
procout.registerOutParameter(6, Types.INTEGER);
int elemSqlType = OracleTypes.INTEGER;
int elemMaxLen = 0;
procout.registerIndexTableOutParameter(7, maxRows, elemSqlType,elemMaxLen);
>
elemSqlType = OracleTypes.VARCHAR;
elemMaxLen = 30;
// register the OUT parameter
procout.registerIndexTableOutParameter(8, maxRows, elemSqlType,elemMaxLen);
>
elemSqlType = OracleTypes.VARCHAR;
elemMaxLen = 21;
// register the OUT parameter
procout.registerIndexTableOutParameter(9, maxRows, elemSqlType,elemMaxLen);
>
elemSqlType = OracleTypes.INTEGER;
elemMaxLen = 0;
// register the OUT parameter
procout.registerIndexTableOutParameter(10, maxRows, elemSqlType,elemMaxLen);
>
>
"Hans" <[email protected]> wrote:
Thanx Slava,
But I have the same problem again...
I replace oracle.jdbc.driver.OracleCallableStatement with
weblogic.jdbc.vendor.oracle.OracleCallableStatement
and I get the same ClassClastException in
weblogic.jdbc.vendor.oracle.OracleCallableStatement procout =
(weblogic.jdbc.vendor.oracle.OracleCallableStatement)
connection.prepareCall(sp);
Any ideas ??
"Slava Imeshev" <[email protected]> wrote:
Hi Hans,
You can not cast returned object to
oracle.jdbc.driver.OracleCallableStatement
when accessing oracle db via connection pool.
It can be casted to weblogic.jdbc.vendor.oracle.OracleCallableStatement.
Here is a list of methods supported by this interface:
void clearParameters() throws java.sql.SQLException;
void registerIndexTableOutParameter(int i, int j, int k, int l) throws
java.sql.SQLException;
void registerOutParameter(int i, int j, int k, int l) throws
java.sql.SQLException;
java.sql.ResultSet getCursor(int i) throws java.sql.SQLException;
java.io.InputStream getAsciiStream(int i) throws
java.sql.SQLException;
java.io.InputStream getBinaryStream(int i) throwsjava.sql.SQLException;
java.io.InputStream getUnicodeStream(int i) throwsjava.sql.SQLException;
>>>
Regards,
Slava Imeshev
"Hans" <[email protected]> wrote in message
news:[email protected]...
Hello,
I get a ClassCastException when I try to execute a Stored Procedurewith
WL6.1
and the JDriver.
I have a servlet who intanciate a Bean and call to his execute()
method
in
this
way:
Context ctx = null;
Hashtable ht = new Hashtable();
Connection conn = null;
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFact
or
y");
try {
ctx = new InitialContext(ht);
javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup(connPool);
conn = ds.getConnection();
conn.setAutoCommit(true);
SvcEmpEstObt empEstObt = new SvcEmpEstObt();
empEstObt.setMaxRows(100);
empEstObt.setConnection(conn);
file://Get parameters from Http Get and set the JB
empEstObt.setEmpRut(request.getParameter("rut"));
empEstObt.setEmpTimeStamp(request.getParameter("timestamp"));
file://Execute Service
empEstObt.execute();
/* ********* the execute() method of the jb is listed here */
public int execute() throws ClassNotFoundException, SQLException{
intreturnedRows = 0;
try {if (connection == null){
try {Class.forName(driver);
} catch (ClassNotFoundException e) {
System.err.println("ClassNotFoundException: " + e);
throw e;
connection = DriverManager.getConnection(url, user, password);
row = -1;
srv_message = String.valueOf(maxRows);
String sp = "{call SvcEmpEstObt_Pkg.SvcEmpEstObt(?, ?, ?, ?, ?, ?,?, ?,
oracle.jdbc.driver.OracleCallableStatement procout =(oracle.jdbc.driver.OracleCallableStatement)
connection.prepareCall(sp); // The exception is here
procout.registerOutParameter(1, Types.VARCHAR);
procout.setString(1, srv_message);
procout.setString(2, empRut);
procout.setString(3, empTimeStamp);
procout.registerOutParameter(4, Types.VARCHAR);
procout.registerOutParameter(5, Types.VARCHAR);
procout.registerOutParameter(6, Types.INTEGER);
int elemSqlType = OracleTypes.INTEGER;
int elemMaxLen = 0;
procout.registerIndexTableOutParameter(7, maxRows, elemSqlType,elemMaxLen);
elemSqlType = OracleTypes.VARCHAR;
elemMaxLen = 30;
// register the OUT parameter
procout.registerIndexTableOutParameter(8, maxRows, elemSqlType,elemMaxLen);
elemSqlType = OracleTypes.VARCHAR;
elemMaxLen = 21;
// register the OUT parameter
procout.registerIndexTableOutParameter(9, maxRows, elemSqlType,elemMaxLen);
elemSqlType = OracleTypes.INTEGER;
elemMaxLen = 0;
// register the OUT parameter
procout.registerIndexTableOutParameter(10, maxRows, elemSqlType,elemMaxLen);
// execute the call
procout.execute();
sqlWarning = procout.getWarnings();
srv_message = procout.getString(1);
returnStatus = new Integer(srv_message.substring(0,1)).intValue();
dagMessage = new DagMessage();
dagMessage.oracleMessage(srv_message);
// access the value using JDBC default mapping
empEstTitulo = procout.getString(4);
empEstUniv = procout.getString(5);
empEstNivel = procout.getInt(6);
curCodigo = (BigDecimal[]) procout.getPlsqlIndexTable(7);
curNombre = (String[]) procout.getPlsqlIndexTable(8);
curFecha = (String[]) procout.getPlsqlIndexTable(9);
curDuracion = (BigDecimal[]) procout.getPlsqlIndexTable(10);
// close the statement
procout.close();
if (curCodigo == null) {
return 0;
} else {
return curCodigo.length;
} catch (SQLException e) {
SQLException ex = e;
System.err.println("\n--- SQLException caught ---\n");
while (ex != null) {
System.err.println("Message: " + ex.getMessage ());
System.err.println("SQLState: " + ex.getSQLState ());
System.err.println("ErrorCode: " + ex.getErrorCode ());
ex = ex.getNextException();
System.out.println("");
throw e;
Does Someone has an idea why it happens ? -
Hello
I am getting java.lang.ClassCastException: oracle.xml.parser.v2.XMLText cannot be cast to org.w3c.dom.Element error. This code is in java which is present in java embedding.
The SOA is parsing the xml in java code using oracle.xml.parser.v2 . This wont be a problem if the SOA uses default w3c DOM parser. How do i force SOA to use w3c DOM parser.
Is there any thing i can do with class loading?
Kindly help.
Regards
SharatCan you paste your java code here ? I assume, you must have tried type-casting.
-
Bom Dia
Nesta solução NF-e do B2B Outbound Attachment +Body eu tive um problema ao testar o Module Gui gerei o pacote .ear fiz o deploy do mesmo no J2ee e
acontece um erro quando testo o envio do e-mail
Message processing failed. Cause: java.lang.ClassCastException: class com.sap.sdn.nfe.SetAttachmentNameLocalHomeImpl0_0 can not be casted to ModuleLocalHome or SModuleLocalHome
1 - já tirei os .jar de referencia do ".ear"(Extrai usando o WinZip) mais não funcionou...
.jar extraido do .EAR antes do deploy..!
aii_af_cci.jar
aii_af_ms_api.jar
aii_af_trace.jar
aii_af_cpa.jar
aii_af_ms_spi.jar
aii_af_mp.jar
aii_af_svc.jar
Alguém teria alguma dica doque poderia estar ocorrendo..?
Agradeço desde já
RONALDO DE MORAESRoberti ...,
Eliminando as classes geradas e ajustando para as classes standard...!!
Existiam alguns erros.....com.sap.sdn.nfe.SetAttachmentNameLocalhome quando na verdade deveria ser isso com.sap.aii.af.mp.module.ModuleLocalHome
esse erro só notei quando olhei a doc postada pelo Roberti ...
http://wiki.sdn.sap.com/wiki/pages/editpage.action?pageId=233474286
Obrigado ...pela força Robert e Henrique -
Hi friends,
We are in to new development in Oracle ADF and newbie to this technology.
Created .jsf page and in corresponding pagedef, has "ControllerClass" with refering "DummyPagePhaseListener" and we have master-detail relationship using Viewlink(created using a SQL Query and entity based view).
Below exception raised when navigating from one to another record in Master af:table. Any help will be appreciated. Thanks in Advance......
java.lang.ClassCastException: DummyPagePhaseListener cannot be cast to oracle.adf.model.RegionController
at oracle.adf.model.binding.DCBindingContainer.getRegionController(DCBindingContainer.java:5197)
at oracle.adf.model.binding.DCBindingContainer.validate(DCBindingContainer.java:4247)
at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.validateModelUpdates(PageLifecycleImpl.java:300)
at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.validateModelUpdates(FacesPageLifecycle.java:70)
at oracle.adf.controller.v2.lifecycle.Lifecycle$6.execute(Lifecycle.java:202)
at oracle.adfinternal.controller.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:197)
at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.access$600(ADFPhaseListener.java:23)
at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$3.after(ADFPhaseListener.java:323)
at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.afterPhase(ADFPhaseListener.java:75)
at oracle.adfinternal.controller.faces.lifecycle.ADFLifecyclePhaseListener.afterPhase(ADFLifecyclePhaseListener.java:53)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:447)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:202)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:508)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:173)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:125)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:293)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:199)
at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:180)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)Hi timo,
Thanks for ur reply...
we are using unbounded taskflow.
In Controller class(page def file), we refered the class that implements PagePhaseListener
The following override methods has created
public void afterPhase(PagePhaseEvent pagePhaseEvent) {
//In this area we used to read the session object file which is written and sent by another application(application to application navigate).
If session object file exists,will allow the user to navigate into the requested page else will navigate in to login(security aspect).
public void beforePhase(PagePhaseEvent pagePhaseEvent) {
Is we used Controller class wrongly ???
Is there any relationship with region controller???
Mani
[email protected] -
EJB3 Stateful:ClassCastException when casting the object returned in lookup
Hi,
I'm developing a web application that make use of EJB3 stateless and stateful beans. The application server is the Websphere Application Server 6.1.0.15 with the EJB3 Feature Pack installed and the web server is the IBM HTTP Server running in another machine.
The problem I'm facing is that for every stateful bean after the lookup, it throws a ClassCastExcption when casting the object returned. See part of the log below.
[7/13/08 3:15:48:869 CDT] 0000001c SystemErr R java.lang.ClassCastException: cannot cast class com.spcs.dsa.ejb.authenticationmanager._AuthenticationManager_Stub to class com.spcs.dsa.ejb.authenticationmanager._AuthenticationManager_Stub
at com.ibm.rmi.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:396)
at com.spcs.dsa.ejb.client.DsaEjbClient.getAuthenticationRemote(DsaEjbClient.java:37)
at com.spcs.dsa.action.NewCardAction.execute(NewCardAction.java:85)
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)
Please notice in the log above that the cast was done for the correct class.
Here is the java code:
AuthenticationManager auth =
(AuthenticationManager) javax.rmi.PortableRemoteObject.narrow(
context.lookup("com.spcs.dsa.ejb.authenticationmanager.AuthenticationManager"),
AuthenticationManagerStub.class);
This problem doesn't happen for statless beans. If you simply change the class to be stateless, this problem stop to happen.
If you run this code in a stand alone program, this problem doesn't happen. It only happen when running in the web server.
Does anybody know what should be done to solve this problem ??
Thanks,
Marcos.I'm not familiar with any specifics of IBM's implementation but from an EJB 3 spec perspective there is no need to use PortableRemoteObject.narrow() if you're retrieving an EJB 3.0 Remote Business interface, regardless of the component type( stateful vs. stateless). In addition, the "_Stub" class should never have to be part of your client programming model. That should be hidden within the vendor's implementation, if present at all.
If AuthenticationManager is the Remote 3.0 Business Interface
@Remote
public interface AuthenticationManager {
your client lookup should be :
AuthenticationManager am = (AuthenticationManager) context.lookup("..."); -
ClassCastexception when casting a Class that extends HttpServletRequestWrap
I have inherited some code that runs OK in JDK 1.4.2 in a JSP, but give s an exception when the JSP runs unfer 1.5.0. My Class is a as follows:
public class WrappedRequest extends HttpServletRequestWrapper {
public WrappedRequest(HttpServletRequest req) {
super(req);
/** Return value string of requested parameter.
* <ul>
* <li> If htmlEncode == NO_HTML_ENCODE, return the native request param, un-html encoded
* <li> If htmlEncode == HTML_ENCODE, return an html encoded copy of the requested parameter
* <li> If htmlEncode is neither, return the html encoded copy of the requested parameter
* </ul>
* @param name name of the request parameter
* @param htmlEncode whether html encoded/un-encoded parameter value should be returned.
* @return String of the requested parameter value. If parameter name is null, return null
public String getParameter(String name, int htmlEncode) {
if(name != null && (htmlEncode == NO_HTML_ENCODE)) {
String str = super.getParameter(name);
return str;
else
return getParameter(name);
public String getParameter(String name) {
String str = super.getParameter(name);
if(str != null)
str = Utils.htmlEncode(str); //Another package class
return str;
This class in normally invoked as follows:
String changeApproval = ((WrappedRequest)request).getParameter("CrApp" , WrappedRequest.NO_HTML_ENCODE);
I get a ClassCastException exception on this line. Any suggestions?
Regards,Stuart_Millington wrote:
Further to my original post I have another question. Please bear in mind that I am fairly new to Java and this is code that I have inherited. In the following line of code (which is the line that causes the exception:
String changeApproval = ((WrappedRequest)request).getParameter("CrApp" , WrappedRequest.NO_HTML_ENCODE);
Why is the request being cast? The following code SEEMS to run OK:
WrappedRequest wr = new WrappedRequest(request);
String CrApproval = wr.getParameter("CrApp" , WrappedRequest.NO_HTML_ENCODE);
Any ideas?
Regards,
Stuart MillingtonOkay, then I understand your problem.
You can only cast request to WrappedRequest when request IS A WrappedRequest - ie the statement request = new WrappedRequest(request) was called. You are apparently trying to convert a default implementation of HttpServletRequest into a WrappedRequest without first 'Wrapping' the request.
What does Wrapping a Request mean and do? A request object is generated by the servlet container and it isn't easy to switch in your own implementation. So instead you make a WrappedRequest which takes the original instance of the HttpServletRequest generated from by the container and adds functionality to it. A WrappedRequest would have to extend an HttpServletRequest, and implement all the public API of said parent class. Most of the time the methods would look something like this:
public String getParameter(String key) { return this.parentRequest.getParameter(key); } That is, it simply delegates most of the work to the HttpServletRequest it is wrapping. But some functions it may want to change behavior for and for those you insert your implementation.
What you need to do:
1) Learn how to use Java before you touch Servlets and server side stuff. You are adding too much complication by going straight to the end game. Use a book and the tutorials to get you through.
2) Take the time to run the JavaEE tutorial.
3) Start with your own code. Taking code snippets you see around the net and trying to get them to work is tough when you don't understand the concepts. For example, using a WrappedRequest is normally fairly useless if it isn't implemented using a Filter, and they work the best when they don't require a change to the request interface (i.e. when you never actually have to do a cast). Since you don't know Filters, and don't yet understand how the wrapper works I would suggest not using them.
This is probably a mis-use of the RequestWrapper idea anyway (since, like I said, it requires a change in interface). What you would be better off doing is simply choosing to pass the parameter through a utility function that does the encoding for you. Example like:
String changeApproval = HTMLEncoder.encode(request.getParameter("CrApp");when you want the parameter encoded and
String changeApproval = request.getParameter("CrApp");when you don't.
If you don't want to make your own utility for this purpose (and why would you) you can download a library that does it for you. One example is the [org.apache.commons.lang.StringEscapeUtils#escapeXML|http://commons.apache.org/lang/apidocs/org/apache/commons/lang/StringEscapeUtils.html#escapeXml(java.lang.String)] class#method from the Apache Foundation. The StringEscapeUtils is part of the Apache Commons Lang project, which you can reach [At the Commons/lang website.|http://commons.apache.org/lang/] -
ClassCastException - While type casting Home object after EJB JNDI Lookup
Sun One Application Server throws a ClassCastException when I try to type cast Home object to it's respective interface type.
Here is the code ---
==============================================
Object obj = PortableRemoteObject.narrow( context.lookup( jndiName ), homeClass);
System.out.println("Remote Object - obj : "+obj);
if (obj != null) {
System.out.println("obj.getClass().getName() : "+obj.getClass().getName());
System.out.println("obj.getClass().getSuperclass() : "+obj.getClass().getSuperclass());
Class[] interfaces = obj.getClass().getInterfaces();
if (interfaces != null) {
for (int count = 0; count < interfaces.length; count++) {
System.out.println("interfaces[ " + count + " ].getName() : " + interfaces[ count ].getName());
}==============================================
The class name is dislpayed as the Stub class name.
While displaying the interfaces, the Home Interface name is displayed.
But later when I try to type cast it into Home Interface type, it throws a ClassCastException.
Can somebody please check this?Please post the stack trace. Also, take a look at our EJB FAQ to make sure you're doing the
recommended lookup :
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
Maybe you are looking for
-
Regarding the printing the output as many no of times
hi , the issue is, i need to print the report output as many number of times as i want based on the value of input parameter. how can i do it? we are using format type as xml so no layout model. can anybody plz give the solution. regards arun.b
-
Convert data on pdf to a xml doc
hi i am really stuck looking for a api (FREE) to convert PDF to xml does anyone know anything related please tell me it will be a good help
-
Workshop 8.1 startup problem
I was working on a project in workshop lastnight and had to remove the application I was working on. Since then I cannot start workshop again. When I start it, it starts for a while then just crashes off. No error messages or anything. Just disappear
-
Hi, I've a table having customer code, customer name, dr_cr, amount fields SELECT a.CUCODE, a.cuname, a.DR_CR, decode(a.DR_CR,'D',a.AMOUNT) Debit, decode(a.DR_CR,'C',a.AMOUNT) Credit, nvl(decode(a.DR_CR,'D',a.AMOUNT),0)-nvl(decode(a.DR_CR,'C',a.AMOUN
-
Desktop acting like Disk Image?
I am having some very strange issues with my Mac right now. Whenever I try to move something from the desktop to the trash can, I get a warning saying the item will be permenantly deleted immediately. This is before I empty the trash. I am also havin