Parameter class casting problem

The question is: how to get the right method based on the type of the parameter passed?
Here is the code:
public class Test {
  public static void main(String[] args) {
    Integer l = 57; // automatic boxing
    Object o = 43;  // automatic boxing and widening casting (?)
    print( l ); // OK: calls Integer
    print( o ); // calls Object: not what I want, but could be
    print( (Integer)o );  // OK: calls Integer
    print( Integer.class.cast(o) ); // OK: calls Integer
    print( o.getClass().cast(o) );  //  NOT OK: dinamic casting does't work?
  static void print( Integer l ) {
    System.out.println("Integer: " + l.toString());
  static void print( Object o ) {
    System.out.println("Object: " + o.toString() + " (" + o.getClass().toString() + ")");
}

Method overloads are resolved at compile time; meaning only the compile time type of the expression used as parameter is taken into account.
Class<T>.cast(Object)returns T.
Class<Integer>.cast returns Integer, so the first overload is chosen.
Class<Object>.cast returns Object, so here the second overload is chosen.

Similar Messages

  • Class Casting problem

    hi,
    i�ve loaded a class at runtime and to parse it to another type, also loaded at runtime, but an error occures!
    in this code i dont write the try�s and catches, they doesn�t matter in this problem
    Class prototype; //source class
    Class parser;    //target class
    Class parsed;    //parsed class (source -> target / prototype -> parser)
    prototype = Class.forName("Prototype");
    parser    = Class.forName("Parser");
    parsed    = (parser) prototype; //Compiler: "Class parser not found"what does it mean?
    can somebody help me?
    thx anyway
    cu Errraddicator

    parser    = Class.forName("Parser");
    parsed    = (parser) prototype; //Compiler: "Class1st. "Parser" or "parser" ... what's the name of your class?
    2nd. all your variables are of type Class. why would you want something of type Class cast into type Parser and then assign it back to a variable of class parsed?
    try something like:
    Class parserClass = Class.forName("Parser");
    Parser parser = (Parser) parserClass.newInstance();of course this is not really THE way to construct an object if you know about the Class type beforehand....
    ulrich

  • Class casting problem when using two class loaders

    Hi, I have a problem with class casting using two different ClassLoader...
    I created an instance of Test class, which is a subclass of AbstractTest and stored it for later use to ArrayList<AsbtractTest>. The instance was created with a custom class loader which extends URLClassLoader. Later when I got the stored instance from the ArrayList<AbstractTest> in default ClassLoader context and cast it to Test, it failed saying "java.lang.ClassCastException: com.test.Test cannot be cast to com.test.Test".
    Does anybody have an idea why this happens?

    Yes - a class is identified by it's package, it's name and it's class loader so the same class code loaded with two different class loaders are two different classes.
    An approach to dealing with your problem is to have the class implement an interface that is loaded by the parent class (assuming, of course, that the two class loaders have the same parent) then you can cast to the interface.

  • Class Cast problem in BiBeans 905

    I am now using BiBeans 905 beta. These days when I was developing a jsp page, a class cast error comes to me.
    first I define the following Crosstab:
    <orabi:Presentation location="UserLeftCrosstab"
    id="biuntitled1_pres1"/>
    and then, I wrote such code:
    ThinGridView crosstab = (ThinGridView)biuntitled1_pres1;
    when I compiled this page, the error occurs:
    Error(26,41): cannot cast oracle.dss.thin.beans.dataView.Presentation to oracle.dss.thin.beans.gridView.ThinGridView
    but I believe such kind of code can run in Bibeans 904

    Things have changed in that the MVC implementation has been expanded. This is the proper call....
    ThinCrosstab crosstab = (ThinCrosstab)presentation1.getView();

  • Class cast problem !!!

    I am getting a class cast exception here
    DecodeArray decode = ((SmppDeliverRequest)obj).getDecodeArray();
    getDecodeArray() returns an object of type DecodeArray ..then why is not able to cast it I have no idea ...
    any guesses ??

    Hi Matt,
    Thanks for your help !!
    here is the output of the code. please check it and let me know your comments !!!
    obj is of type com.logica.omg.ext.cingular.submit.DecodeArray
    obj is an instance of SmppDeliverRequest
    java.lang.ClassCastException
    at com.logica.omg.cdrnode.logging.property.contexts.smpp.SmppDeliverRequestPropertyContext$SourceChargedProperty.access(SmppDeliverRequestPropertyContext.java:71)
    at com.logica.omg.cdrnode.logging.property.Property.get(Property.java:52)
    at com.logica.omg.cdrnode.logging.property.PropertyContextTest.assertProperty(PropertyContextTest.java:104)
    at com.logica.omg.cdrnode.logging.property.PropertyContextTest.assertProperty(PropertyContextTest.java:67)
    at com.logica.omg.cdrnode.logging.property.contexts.smpp.SmppDeliverRequestPropertyContextTest.testSourceChargedProperty(SmppDeliverRequestPropertyContextTest.java:136)
    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:324)
    at junit.framework.TestCase.runTest(TestCase.java:166)
    at junit.framework.TestCase.runBare(TestCase.java:140)
    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:131)
    at junit.framework.TestSuite.runTest(TestSuite.java:173)
    at junit.framework.TestSuite.run(TestSuite.java:168)
    at junit.framework.TestSuite.runTest(TestSuite.java:173)
    at junit.framework.TestSuite.run(TestSuite.java:168)
    at junit.swingui.TestRunner$17.run(TestRunner.java:644)
    obj is of type com.logica.omg.ext.cingular.submit.DecodeArray
    obj is an instance of SmppDeliverRequest
    Satish

  • Class casting problems in JSP's

    Folks,
              Several people, including myself, have written about the problems they
              ran into when trying to cast a class in JSP's. The following link might
              provide the answer:
              http://www.weblogic.com/docs51/classdocs/API_jsp.html#sessions
              I believe this is a major limitation Weblogic put on web app
              development, and hope BEA would eventually find a way to allow non-user
              defined types being stored in servlet sessions.
              Jeff
              

    Folks,
              Several people, including myself, have written about the problems they
              ran into when trying to cast a class in JSP's. The following link might
              provide the answer:
              http://www.weblogic.com/docs51/classdocs/API_jsp.html#sessions
              I believe this is a major limitation Weblogic put on web app
              development, and hope BEA would eventually find a way to allow non-user
              defined types being stored in servlet sessions.
              Jeff
              

  • Class Cast problem when attempting to add Object in TreeSet, Please Help...

    hi friends,
    I have a TreeSet Object in which i add Object of type WeatherReport but when I trying to add my Second WeatherReport Object it throwing ClassCastException please Help Me in figure out the mistake that i did...
    /*code sample of my WeatherReport.class*/
    package com;
    class WeatherReport implements Serializable
    private String region;
    private String desc;
    private String temp;
    /*equvalent getter and setters come here*/
    /*in my jsp*/
    <%@ page import="com.WeatherReport"%>
    <%
    TreeSet<com.WeatherReport> ts=new TreeSet<com.WeatherReport>();
    while(condition)
    WeatherReport wp=new WeatherReport();
    /*setting data for all the Methods*/
    ts.add(wp);
    %>
    Error:
    java.lang.ClassCastException: com.WeatherReport
            at java.util.TreeMap.compare(TreeMap.java:1093)
            at java.util.TreeMap.put(TreeMap.java:465)
            at java.util.TreeSet.add(TreeSet.java:210)
            at org.apache.jsp.Weather_jsp._jspService(Weather_jsp.java:138)
            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:332)
            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.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            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.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:869)
            at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
            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)Edited by: rajaram on Oct 31, 2007 12:56 AM

    hi ChuckBing,
    Thank you very much, your suggestion helps me a lot...
    I change the WeatherReport Class as follows and its working now...
    public class WeatherReport implements Serializable,Comparable {
        private String location;
        private String temp;
        private String desc;
        public int compareTo(Object o) {
            if(o instanceof WeatherReport)
                WeatherReport wp=(WeatherReport)o;
                String l1=wp.getLocation();
                String l2=this.getLocation();
                return l2.compareTo(l1);
            return -1;
    }Once Again Thanks a lot ...
    Edited by: rajaram on Oct 31, 2007 9:11 PM

  • (Class cast Exception)Problem while loading data fro database in java class

    Dear all,
    Please help me...to solve this
    I have a database having two columns of String and Date Types.
    In my java code i was trying to load the data to a UI.
    I am successfull in loading the String type value.
    But while loading date field value,is showing Class cast Exception.
    What i am doing is Getting the values from database to a String[] array.
    So my question is how to
    get the Date field as date field itself,Then convert it to a String..Then put it in to String[] array...
    Any body please help...If any one want more clarification in question i will give......

    Hi,
    I am using GWT to display my data in a Grid.
    So it will accept a Single two dimensional String array....Here i have one as String and other as Date.
    So i was trying to get each row in a sindle dimensional array array[] then store it in a list.
    Iteration goes up to 10 rows.After i am setting it in to a list
    ie list.add(array);
    Now while returning this list i am doing this
    "return (String[][])list.toArray(new String[0][]);"
    When i tried to get the date element to String array it is showing class cast exception. When i tried with toString() method it is showing the same problem.

  • Type problem - Class Cast Exception - trying to understand

    hello,
    i get a Class cast exception in the following code.
    interface Foo {}
    class Alpha implements Foo {}
    class Beta extends Alpha {}
    class Delta extends Beta {
    public static void main( String[] args ) {
    Beta x = new Beta();
    Beta b = (Beta)(Alpha)x; //fine
    Foo f = (Delta)x; //CCE
    Object ob = new Object();
    String s = new String();
    ob = s; //fine, no need of case
    s = (String)ob; //needs a castI was just thinking, implicitly Delta and Beta both of them IS-A Foo, and assigning x to a type foo shouldnt be a problem(while making it refer to the Delta class) so, what could cause the CCE ?
    I would appreciate if someone could please help me understand this.
    Rgds

    Hi.
    Assigning your "x" to a variable typed Foo is not a problem. The problem is that you are trying to cast an instance of Beta ("x") into type Delta which is not possible. Every Delta is a Beta, but not every Beta will be a Delta!
    Simple as that.
    Bye.

  • Extended a class, getting a class cast error

    Hi all,
    I'm writing a program that uses a closed-source jar in its library (with permission, of course).
    One of the classes in that jar wasn't working as I wanted it to, so I extended the class and overwrote one of its methods. So, when using the class, instead of callingThirdPartyClass obj = new ThirdPartyClass();I could useMyThirdPartyClass obj = new MyThirdPartyClass();This seems to work, until a certain line of their code throws a class cast exception:
    java.lang.ClassCastException: org.thirdparty.ThirdPartyClass$2
         at org.thirdparty.Event.findTop(Event.java:279)
         at org.thirdparty.ThreadUtils$4.run(ThreadUtils.java:86
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
        ....Why does this occur? Surely, since MyThirdPartyClass is a child of ThirdPartyClass, anything that expects a ThirdPartyClass shouldn't have any problem, right? Or do I have that backwards? And if so, is there anything I can do to fix the problem?
    Thanks!
    Sam

    paulcw wrote:
    Specifically, the ThirdPartyClass itself was an extension of a JApplet. Since I wanted to use it directly in my code, I couldn't set the applet's parameters, so I overwrote the getParameters(String) method to return strings of my choosing.Your approach makes little sense to me. Applets follow a well-defined lifecycle. If you wanted to embed the applet into your own application, all you have to do is use the applet following its lifecycle (that is, instantiate it, set the context, invoke init and start and stop and destroy). Overriding anything should not be necessary.That's exactly what I want to do. However, the applet requires one parameter to be set (DefaultModel = some url) -- if this isn't set I can't run the applet. As far as I can tell (and I have an as-yet unanswered question in the Applets forum asking about this), there is no way to set the parameters in an Applet in any way besides putting in in the 'param' tag in the Applet code in the HTML.
    If I'm wrong about that, please let me know.
    On the assumption that I was right, I decided to extend the getParameters(String) method, so that it would return the desired String when asked. Naturally, to do this, I had to extend the entire class.
    This solved the problem of the program failing when it asked for the parameter, but then it failed when it checked the codebase. I overrode the getCodeBase() method, and the applet no longer had a problem there.
    Then I got the exceptions I got above.
    I'm fairly certain (but, naturally, not 100% certain of anything) that neither of my methods should have affected the inner-workings of LiteApplet -- I was overriding methods that were from Applet (and not overridden in LiteApplet, I checked) that are just supposed to pass back strings -- the same Strings that would be passed back if it were embedded in a web page -- and not affect the applet in any way.
    Naturally, I'm wrong about one or more of my assumptions above, but I just can't work out how overriding those two methods could have created the error that I'm getting.
    Sam
    PS: Here is the entire exception, if you think it could help. I was scrubbing it merely so as not to confuse matters and make my posts overly long. The last exception below gets repeated indefinitely.
    AutoConverter.runVisitor() failed: CREATE-SUN expected 2 inputs, a number and a command block (optional).
    java.lang.NullPointerException
         at org.nlogo.swing.OptionDialog.show(OptionDialog.java:36)
         at org.nlogo.window.GUIWorkspace$11.handleError(GUIWorkspace.java:1125)
         at org.nlogo.compiler.AutoConverter.convert(AutoConverter.java:161)
         at org.nlogo.window.ProceduresLite.handleLoadSectionEvent(ProceduresLite.java:44)
         at org.nlogo.event.LoadSectionEvent.beHandledBy(LoadSectionEvent.java:38)
         at org.nlogo.event.Event.doRaise(Event.java:215)
         at org.nlogo.event.Event.raise(Event.java:116)
         at org.nlogo.window.ModelLoader.loadHelper(ModelLoader.java:76)
         at org.nlogo.window.ModelLoader.load(ModelLoader.java:45)
         at org.nlogo.window.LiteApplet.go(LiteApplet.java:128)
         at org.nlogo.window.LiteApplet$1.run(LiteApplet.java:26)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    java.lang.ClassCastException: org.nlogo.window.CompilerManager
         at org.nlogo.event.Event.findTop(Event.java:279)
         at org.nlogo.event.Event.doRaise(Event.java:190)
         at org.nlogo.event.Event.raise(Event.java:116)
         at org.nlogo.window.CompilerManager.compileAll(CompilerManager.java:68)
         at org.nlogo.window.CompilerManager.handleLoadEndEvent(CompilerManager.java:61)
         at org.nlogo.event.LoadEndEvent.beHandledBy(LoadEndEvent.java:11)
         at org.nlogo.event.Event.doRaise(Event.java:215)
         at org.nlogo.event.Event.raise(Event.java:116)
         at org.nlogo.window.ModelLoader.loadHelper(ModelLoader.java:115)
         at org.nlogo.window.ModelLoader.load(ModelLoader.java:45)
         at org.nlogo.window.LiteApplet.go(LiteApplet.java:128)
         at org.nlogo.window.LiteApplet$1.run(LiteApplet.java:26)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    java.lang.ClassCastException: org.nlogo.window.LiteApplet$2
         at org.nlogo.event.Event.findTop(Event.java:279)
         at org.nlogo.event.Event.doRaise(Event.java:190)
         at org.nlogo.event.Event.raise(Event.java:116)
         at org.nlogo.window.GUIWorkspace$6.run(GUIWorkspace.java:660)
         at org.nlogo.window.ThreadUtils$2.run(ThreadUtils.java:37)
         at org.nlogo.window.ThreadUtils$4.run(ThreadUtils.java:86)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

  • Class Cast Expection

    I am trying to use the sample cciBlacbox JCA Resource adapters provided by sun and am getting the problem described below. I am using Weblogic 7.0.
              1. From a stateless EJB I am calling the 'execute(InteractionSpec interactionSpec, Record record, Record record2)' method of an instance of class CciInteraction which implements javax.resource.cci.Interaction.
              2. To the above 'execute' method, I pass an instance of the class CciInteractionSpec which is implementing javax.resource.cci.InteractionSpec
              3. In the above 'execute' method when I typecast the parameter 'interactionSpec' to CciInteractionSpec (the class implementing javax.resource.cci.InteractionSpec), I get a ClassCastException.
              Has anyone one faced the above problem or have any clue as to what could be the problem?
              Thanks
              Rajesh
              

    Hi Tony,
              We have an implementation class of "InteractionSpec". This has all
              methods(InteractionSpec + some our own) implemented. This implementation
              calss is "myInteractionSpec".
              We have an implementation class for "Interaction". This class is
              "myIntertactionImpl".
              When we are calling "execute" method on "myInteractionImpl" from EJB, we are
              passing an instance of "myInteractionSpec".
              Inside myInteractionImpl.execute(), We are casting to "myInteractionSpec",
              like below
              ========================================
              public Record execute(InteractionSpec ispec, Record input)
              throws AEResourceException, ResourceException
              myInteractionSpec spec = (myInteractionSpec)ispec;
              ========================================
              But it is perfectly working for me. But We have added our connector jar in
              the server class path. From the begining we are testing this way. It is not
              only supports weblogic but other servers also.May be because of I added
              connector jar in the calsspath, it is working for me. I have also saw your
              postings "saying defect". Unknowingly I am following the workaround of
              weblogic, Thats what I feel why I am not getting this class cast exception.
              I am testing the connector as a standlone RAR and not with an EAR?. I am not
              clear How are you doing, is it same?
              However, Thanks for inforamtion.
              Regards
              Kumar
              "Tony Cheng" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Kumar:
              >
              > I encounter same Cast Exception problem also.
              >
              > Do you have any progress on this issue?
              >
              > TIA
              > Tony
              >
              > "Kumar" <[email protected]> wrote:
              > >Hi Prashant,
              > >
              > >Sorry for inturrpting..
              > >
              > >Yes, it would be good to not to cast the InteractionSpec to
              > >CCIInteractionSpec. This works for if we implement the methods defined
              > >in
              > >the interafce InteractionSpec and no new methods. If the
              CCIInteractionSpec
              > >not only implementing the methods of InteractionSpec and it also adding
              > >some
              > >new methods of its own. Then that wil be a problem.
              > >
              > >Then we need to cast it to the Implemetation class to use those new
              methods.
              > >The same thing we are doing in our adapter and we dont have any problem.
              > >
              > >Thanks
              > >Kumar
              > >"Prashant" <[email protected]> wrote in message
              > >news:[email protected]...
              > >>
              > >> Rajesh,
              > >> It should not be necessary to cast the parameter to CciInteractionSpec
              > >since the
              > >> execute() method expects an InteractionSpec.
              > >> Regards,
              > >> Prashant.
              > >>
              > >> Rajesh <[email protected]> wrote:
              > >> >I am trying to use the sample cciBlacbox JCA Resource adapters
              provided
              > >> >by sun and am getting the problem described below. I am using Weblogic
              > >> >7.0.
              > >> >
              > >> >1. From a stateless EJB I am calling the 'execute(InteractionSpec
              > >interactionSpec,
              > >> >Record record, Record record2)' method of an instance of class
              > >CciInteraction
              > >> >which implements javax.resource.cci.Interaction.
              > >> >2. To the above 'execute' method, I pass an instance of the class
              > >CciInteractionSpec
              > >> >which is implementing javax.resource.cci.InteractionSpec
              > >> >3. In the above 'execute' method when I typecast the parameter
              > >'interactionSpec'
              > >> >to CciInteractionSpec (the class implementing
              > >javax.resource.cci.InteractionSpec),
              > >> >I get a ClassCastException.
              > >> >
              > >> >Has anyone one faced the above problem or have any clue as to what
              > >could
              > >> >be the problem?
              > >> >
              > >> >Thanks
              > >> >Rajesh
              > >>
              > >
              > >
              >
              

  • Oracle Arrays and getVendorConnection API and Class Cast Exception

    I 've gone through various threads relating to the topic of Oracle Arrays and the getVendorConnecton API call to avoid the class Cast Exception.. i ve used all these but am still facing the problem...
    I would appreciate it if some one could resolve the following queries :
    I am using Weblogic 8.1 SP5 with oracle 8i
    1. I read that the need to use the getVendorConnection API to make pl/sql proc calls with oracle arrays from the WL Server wont be required to avoid classCastException...
    I tried to use the connection from the WL connection pool ..but it didnot work....I used the getVendorConnection API ..which also doesnot seem to work..
    I got the Heurisitc Hazard exception...I used the Oracle 9i driver ie ojdbc14.jar ...after this the exception is not coming but still the code doesnt seem to work...
    the snippet of the code is pasted below :
    ~~~~~~~~~~~~~~~~~~~~~~~code is : ~~~~~~~~~~~~~~~~~~~
    /*below :
    logicalCon is the Connection from the WL connection pool
    JDBCcon is the JDBC connection. */
    <div> try </div>
    <div>{ </div>
    <div>
    <b>vendorConn</b> = ((WLConnection)logicalCon).getVendorConnection();
    </div>
    <div>
    //Calling the procedure
    </div>
    <div>
    //java.util.Map childMap1 = JDBCcon.getTypeMap();
    </div>
    <div>
    java.util.Map childMap1 = <b>vendorConn</b>.getTypeMap();
    </div>
    <div>
    childMap1.put("SST_ROUTE_ENTRY", Class.forName("svm.stport.ejb.StaticRouteEntry"));
    </div>
    <div>
    //JDBCcon.setTypeMap(childMap1);
    <b>vendorConn</b>.setTypeMap(childMap1);
    </div>
    <div>
    // Create an oracle.sql.ARRAY object to hold the values
    </div>
    <div>
    /*oracle.sql.ArrayDescriptor arrayDesc1 = oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", JDBCcon); */
    </div>
    <div>
    oracle.sql.ArrayDescriptor arrayDesc1 =
    oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", <b>vendorConn</b>); // here if i use the JDBCcon it works perfectly.... <u>^%^%^%</u>
    </div>
    <div>
    code to fill in the sst route entry array....
    .....arrayValues1 */
    </div>
    <div>
    /* oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, JDBCcon, arrayValues1); */
    </div>
    <div>
    oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, <b>vendorConn</b>, arrayValues1);
    </div>
    <div>
    callStatement = logicalCon.prepareCall( "? = call procName(?, ?, ?)");
    </div>
    <div>
    /* ..code to set the ?s ie array1 */
    </div>
    <div>
    callStatement.execute();
    </div>
    <div>
    }catch(Exceptio e){
    </div>
    <div>
    }</div>
    <div>
    finally </div>
    </div>{</div>
    <div>System.out.println(" I ve come to finally"); </div>
    <div>}</div>
    <div>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~code snippet ends here ~~~~~~~~~~~~~~``
    </div>
    I have observed that the control immediately comes to the finally block after the call to the createDescriptor line above with <u>^%^%^%</u> in the comment. If i use the JDBCCon in this line...it works perfectly fine.
    Any pointers to where anything is getting wrong.
    I have jst set the vendorCon to null in the end of the file and not closed it. Subsequently i have closed the logicalCon. This has been mentioned in some of the thread in this forum also.
    Thanks,
    -jw

    Jatinder Wadhwa wrote:
    I 've gone through various threads relating to the topic of Oracle Arrays and the getVendorConnecton API call to avoid the class Cast Exception.. i ve used all these but am still facing the problem...
    I would appreciate it if some one could resolve the following queries :
    I am using Weblogic 8.1 SP5 with oracle 8i
    1. I read that the need to use the getVendorConnection API to make pl/sql proc calls with oracle arrays from the WL Server wont be required to avoid classCastException...
    I tried to use the connection from the WL connection pool ..but it didnot work....I used the getVendorConnection API ..which also doesnot seem to work..
    I got the Heurisitc Hazard exception...I used the Oracle 9i driver ie ojdbc14.jar ...after this the exception is not coming but still the code doesnt seem to work...
    the snippet of the code is pasted below :
    ~~~~~~~~~~~~~~~~~~~~~~~code is : ~~~~~~~~~~~~~~~~~~~Hi. Show me the whole exception and stacktrace if you do:
    try
    vendorConn = ((WLConnection)logicalCon).getVendorConnection();
    java.util.Map childMap1 = vendorConn.getTypeMap();
    childMap1.put("SST_ROUTE_ENTRY" Class.forName("svm.stport.ejb.StaticRouteEntry"));
    vendorConn.setTypeMap(childMap1);
    oracle.sql.ArrayDescriptor arrayDesc1 =
    oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR",
    vendorConn);
    oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, vendorConn, arrayValues1);
    callStatement = logicalCon.prepareCall( "? = call procName(? ? ?)");
    callStatement.execute();
    }catch(Exception e){
    e.printStackTrace();
    finally
    try{logicalCon.close();}catch(Exception ignore){}
    System.out.println(" I ve come to finally");
    /*below :
    logicalCon is the Connection from the WL connection pool
    JDBCcon is the JDBC connection. */
    <div> try </div>
    <div>{ </div>
    <div>
    <b>vendorConn</b> = ((WLConnection)logicalCon).getVendorConnection();
    </div>
    <div>
    //Calling the procedure
    </div>
    <div>
    //java.util.Map childMap1 = JDBCcon.getTypeMap();
    </div>
    <div>
    java.util.Map childMap1 = <b>vendorConn</b>.getTypeMap();
    </div>
    <div>
    childMap1.put("SST_ROUTE_ENTRY", Class.forName("svm.stport.ejb.StaticRouteEntry"));
    </div>
    <div>
    //JDBCcon.setTypeMap(childMap1);
    <b>vendorConn</b>.setTypeMap(childMap1);
    </div>
    <div>
    // Create an oracle.sql.ARRAY object to hold the values
    </div>
    <div>
    /*oracle.sql.ArrayDescriptor arrayDesc1 = oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", JDBCcon); */
    </div>
    <div>
    oracle.sql.ArrayDescriptor arrayDesc1 =
    oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", <b>vendorConn</b>); // here if i use the JDBCcon it works perfectly.... <u>^%^%^%</u>
    </div>
    <div>
    code to fill in the sst route entry array....
    .....arrayValues1 */
    </div>
    <div>
    /* oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, JDBCcon, arrayValues1); */
    </div>
    <div>
    oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, <b>vendorConn</b>, arrayValues1);
    </div>
    <div>
    callStatement = logicalCon.prepareCall( "? = call procName(?, ?, ?)");
    </div>
    <div>
    /* ..code to set the ?s ie array1 */
    </div>
    <div>
    callStatement.execute();
    </div>
    <div>
    }catch(Exceptio e){
    </div>
    <div>
    }</div>
    <div>
    finally </div>
    </div>{</div>
    <div>System.out.println(" I ve come to finally"); </div>
    <div>}</div>
    <div>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~code snippet ends here ~~~~~~~~~~~~~~``
    </div>
    I have observed that the control immediately comes to the finally block after the call to the createDescriptor line above with <u>^%^%^%</u> in the comment. If i use the JDBCCon in this line...it works perfectly fine.
    Any pointers to where anything is getting wrong.
    I have jst set the vendorCon to null in the end of the file and not closed it. Subsequently i have closed the logicalCon. This has been mentioned in some of the thread in this forum also.
    Thanks,
    -jw

  • 'Class Cast Exception' while invoking a EJB from a Servlet

              Hi,
              I am working on J2EE applications.I am using Webgain studio and weblogic server.I
              got a problem while invoking EJB from the servlet.
              While calling an EJB from the servlet, it is giving that "Class Cast Exception".This
              is because, the remote home reference is not able to type casted to the"Home Interface"
              of the EJB, even if I type casted explicitly. It is creating the context and able
              to identify the EJB with the JNDI name.
              Could please help me in solving this problem.I am pasting the code here.
              Thanks in advance,
              Dharma
              public void doGet(HttpServletRequest req, HttpServletResponse resp)
                   throws ServletException, IOException
                        resp.setContentType("text/html");
                        PrintWriter out = new PrintWriter(resp.getOutputStream());
              try
              Context context=getInitialContext();
              Object reference=context.lookup("ArlProjContractorAppletSession");
              ArlProjContractorAppletSessionHome home=(ArlProjContractorAppletSessionHome)PortableRemoteObject.narrow(reference,ArlProjContractorAppletSessionHome.class);
              //Exception is occuring in the above statement. It is unable
              //to cast to the home interface          
                        ArlProjContractorAppletSession the_ejb=null;
              try
              the_ejb=home.create();
              System.out.println("the_ejb = " + the_ejb.toString());
              catch(Exception e)
              e.printStackTrace();
              catch(Exception e)
              e.printStackTrace();
                        // to do: code goes here.
                        out.println("<HTML>");
                        out.println("<HEAD><TITLE>Contractor TimeTracker</TITLE></HEAD>");
                        out.println("<BODY>");
                        // to do: your HTML goes here.
                        out.println("</BODY>");
                        out.println("</HTML>");
                        out.close();
              

              I came across this kind of problem once. My problem went away after I upgraded
              from 5.1 SP6 to 5.1 SP8.
              "Dharma" <[email protected]> wrote:
              >
              >Hi,
              >
              >I am working on J2EE applications.I am using Webgain studio and weblogic
              >server.I
              >got a problem while invoking EJB from the servlet.
              >
              >While calling an EJB from the servlet, it is giving that "Class Cast
              >Exception".This
              >is because, the remote home reference is not able to type casted to the"Home
              >Interface"
              >of the EJB, even if I type casted explicitly. It is creating the context
              >and able
              >to identify the EJB with the JNDI name.
              >
              >Could please help me in solving this problem.I am pasting the code here.
              >
              >Thanks in advance,
              >Dharma
              >
              >
              >public void doGet(HttpServletRequest req, HttpServletResponse resp)
              >     throws ServletException, IOException
              >     {
              >          resp.setContentType("text/html");
              >          PrintWriter out = new PrintWriter(resp.getOutputStream());
              >
              > try
              > {
              >
              > Context context=getInitialContext();
              >
              > Object reference=context.lookup("ArlProjContractorAppletSession");
              >
              > ArlProjContractorAppletSessionHome home=(ArlProjContractorAppletSessionHome)PortableRemoteObject.narrow(reference,ArlProjContractorAppletSessionHome.class);
              >
              >//Exception is occuring in the above statement. It is unable
              >//to cast to the home interface          
              >
              >          ArlProjContractorAppletSession the_ejb=null;
              >
              > try
              > {
              > the_ejb=home.create();
              >
              > System.out.println("the_ejb = " + the_ejb.toString());
              >
              > }
              > catch(Exception e)
              > {
              > e.printStackTrace();
              > }
              > }
              > catch(Exception e)
              > {
              > e.printStackTrace();
              > }
              >          // to do: code goes here.
              >
              >          out.println("<HTML>");
              >          out.println("<HEAD><TITLE>Contractor TimeTracker</TITLE></HEAD>");
              >          out.println("<BODY>");
              >
              >          // to do: your HTML goes here.
              >
              >          out.println("</BODY>");
              >          out.println("</HTML>");
              >          out.close();
              >     }
              >
              >
              >
              >
              >
              

  • Class cast exception using Finder method

    Hello. I'm new to J2EE. I have set up one entity bean but am having trouble
    with my current one.
    Basically, I have two finder methods:
    public ShareHistory findByPrimaryKey(Integer historyId)
            throws FinderException, RemoteException;
        public Collection findByShare(String shareId)
             throws FinderException, RemoteException; findByPrimaryKey works fine, but findByShare causes a class cast exception in java.lang.String.
    The stack trace in the server logs shows that it is my ejbActivate method in my entity bean causing the problem:
    public void ejbActivate() {
          //String numberString = (String) context.getPrimaryKey();
          //historyId = new Integer(numberString);
        historyId = (Integer) context.getPrimaryKey();
        }The stack trace from my client shows that the class cast exception occurs
    in the client at the System.out.println("shareid" + ": " + sh.getShareId());
    line:
    Collection c = sharesHistoryHome.findByShare("DCAN");
                     Iterator i = c.iterator();
                          while (i.hasNext()) {
                         ShareHistory sh = (ShareHistory) i.next();
                    System.out.println("shareid" + ": " + sh.getShareId());
                    System.out.println("value" + ": " + sh.getValue());
                     System.out.println("time" + ": " + sh.getTime());
                     System.out.println("date" + ": " + sh.getDate());
                     }//whileAs you can see I tried casting to a string in ejbactivate, but that simply causes an Integer class cast exception during findByprimaryKey instead. How do I allow both Integer and String objects to be used?
    Also I am a bit confused as to why the String passed to findByShare(String) is being used in context.getPrimaryKey() in the first place (if that is actually what's happening).

    Oops my FindByShare method was returning a collection of shareId's (strings) instead of a collection of Integer primary keys, which would explain the class cast exception.

  • Class Cast exception when clicking Search Button in Query component

    Hi
    We have to implement the Query component in ADF programmatically.. We are using Toplink as the Model layer for ADF.
    We followed the Web User Interface Guide for ADF development, Chapter 12 (Using Query Components) for the same.
    We already have implemented the following classes:
    1) QueryModel
    2) QueryDescriptor
    3) AttributeDescriptor
    4) ConjuctionCriterion
    5) AttributeCriterion etc.
    We are able to see the Search panel in UI with selected fields in Basic as well as Advanced mode.
    When we click on Search button, we are getting Class Cast exception.
    The stacktrace of the exception is below:
    <LifecycleImpl> <_handleException> ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase INVOKE_APPLICATION 5
    javax.el.ELException: java.lang.ClassCastException: view.QueryDescriptorImpl cannot be cast to oracle.adfinternal.view.faces.model.binding.FacesCtrlSearchBinding$QueryDescriptorImpl
         at com.sun.el.parser.AstValue.invoke(Unknown Source)
         at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodExpression(UIXComponentBase.java:1300)
         at oracle.adf.view.rich.component.UIXQuery.broadcast(UIXQuery.java:116)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:902)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:313)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:186)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         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:205)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
         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:136)
         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)
    Caused by: java.lang.ClassCastException: view.QueryDescriptorImpl cannot be cast to oracle.adfinternal.view.faces.model.binding.FacesCtrlSearchBinding$QueryDescriptorImpl
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlSearchBinding.processQuery(FacesCtrlSearchBinding.java:374)
         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:597)
         ... 44 more
    <RegistrationConfigurator> <handleError> ADF_FACES-60096:Server Exception during PPR, #1
    javax.el.ELException: java.lang.ClassCastException: view.QueryDescriptorImpl cannot be cast to oracle.adfinternal.view.faces.model.binding.FacesCtrlSearchBinding$QueryDescriptorImpl
         at com.sun.el.parser.AstValue.invoke(Unknown Source)
         at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodExpression(UIXComponentBase.java:1300)
         at oracle.adf.view.rich.component.UIXQuery.broadcast(UIXQuery.java:116)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:902)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:313)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:186)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         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:205)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
         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:136)
         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)
    Caused by: java.lang.ClassCastException: view.QueryDescriptorImpl cannot be cast to oracle.adfinternal.view.faces.model.binding.FacesCtrlSearchBinding$QueryDescriptorImpl
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlSearchBinding.processQuery(FacesCtrlSearchBinding.java:374)
         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:597)
         ... 44 more
    Any help will be highly appreciated.
    Thanks in advance.
    Anup

    Gary Tam wrote:
    I am working on a project that utilize Oracle Ultra Search that will crawl and tag documents in the database.
    The initial code that uses pure JDBC was working fine, but when we switch to get database connection from dataSource, we are getting classCast exception inside Oracle's ultra search. The problems is that the class we get from dataSource.getConnection() returns
    "weblogic.jdbc.wrapper.JTSConnection_oracle_jdbc_driver_T4CConnection". But Oracle UltraSearch is not expecting that.
    Is there anyway to unwrap the connection that we get from dataSource ? I tried casting to OracleConnection,
    assign the connection to "oracle.jdbc.driver.T4CConnection" without any success.
    Any help would be appricated.
    ThanksHi Gary. If the code you want to run is running inside WebLogic, such as in a JSP,
    then look for our documentation on our JDBC extension 'getVendorConnection()". It
    will get you a direct Oracle connection for their mis-declared UltraSearch
    classes (they declare they take java.sql.Connection, but they really demand a
    concrete thin driver connection. No other Oracle driver will be given a chance).
    Joe

Maybe you are looking for

  • Facing problems with readdir() function in Solaris 2.6

    Hi, I am working on Solaris 2.6 platform. Configuration details are: System = SunOS Release = 5.6 KernelID = Generic_105181-31 Machine = sun4u NumCPU = 16 sparc SUNW,Ultra-Enterprise-10000 I have written a piece of "C" code that is used to search fil

  • EXECUTE IMMEDIATE call to procedure

    need help on this piece of code. 1. lv_rec is a record of a table temp1 from which i need to validate lv_code. 2. The package1.proc_get_rec procedure has an IN OUT record parameter which is %ROWTYPE of the table in which the code exists. 3. lv_err_ms

  • IOS 8--DRM--external hard drive

    i sent an email to Apple tech support with no response--about 7 days ago. issue is we have an external hd we use in the car so kids can watch purchased iTunes movies. unable to get these movies to play. they are hd movies and take up to much storage

  • Skills for DBA

    What are all skills need for 2 year experience DBA ?

  • CMS_CBS Folder Not found for NWDI Configuration

    Hi All, We are presently configuring NWDI on WAS 7.0. We are presently stuck at a following step wherein the document asks us to pick up the following files SAP_BUILDT.sca, SAP_JTECHS.sca and SAP-JEE.sca from the folder CMS_CBS. The location mentione