ClassCastException help

Hi
I am building a web application with servlet, JSP using Javabeans, I have created a Created Product and a sub class OrderedProduct
Class Product
Product(name, code, price)
Product(){}
Class OrderedProduct extends Product
OrderedProduct(){}
in the servlet I am trying to cast
Product selectedproduct = new Product(name,code, price);
OrderedProduct neworder = (OrderedProduct)productselected;
and this gives me an error java.lang.ClassCastException
can anyone know why, please help me not to wast my time I have tried it for two days.
Thank you in advance :)

Your question isn't really a JSP question, but I'll see what I can do to help you.
Essentially what you're doing is trying to cast from something general (Product) to something specific (OrderedProduct)
**NOTE** BTW Your code won't compile as it's written here because you have some of the object references wrong. Here's a sample of class casting that may (or may not help you)
public class Vehicle {
     private String name = null ;
     private String type = null ;
     private int crew = 0 ;
public class Airplane extends Vehicle {
     private int wingSurfaces = 0 ;
     private boolean extraAtmospheric = false ;
     public static void main(String[] args) {
          //     Create an instance of a vehicle
          Vehicle v1 = new Vehicle("Generic", "v1", 0) ;
          //     Create an instance of an airplane
          Airplane a1 = new Airplane("Airplane", "a1", 2, 1, false) ;
          //     Create an instance of a vehicle and then cast it as an airplane
          Vehicle v2 = new Vehicle("Generic", "v2", 0) ;
          //Airplane a2 = (Airplane) v2 ; Causes a ClassCastException at compile
          // Create an instance of an airplane and then cast it as a vehicle
          Airplane a3 = new Airplane("Airplane", "a3", 4, 2, false) ;
          Vehicle v3 = (Vehicle) a3 ;
          Airplane a4 = (Airplane) v3 ;
I've left out the constructors and the accessor / mutator methods for brevity. As you can see, the cast from Airplane to Vehicle works just fine, and you can cast it back to an Airplane if you need to. This is very important for some of the storage mechanisms of Java. But when you try to cast from Vehicle to Airplane the compiler complains because you are trying to cast from general to specific.
Hope this helps, your milage may vary.

Similar Messages

  • Object[] casting to String[] ERROR

    Hi! i have a LinkedBlockingQueue and by it's method .to Array() i want to cast it's type to String[] (it's initial is Object[])
    But i get a ClassCastException
    Help?

    An Object[] is not an String[] even if it only contains String objects: The content of the array does not define the type of the array, but the type of the array limits the possible types of the content.
    Look at the other .toArray() method that takes a parameter. If you put a String[] in, you get a String[] back out (you still have to cast, 'though, but then it will work).

  • HELP: Error while consuming Web Service: ClassCastException

    Hi,
    I am trying to consume a web service that I deployed on Tomcat/Axis. Any guideline will be helpful. I generated stubs using WSDL2Java utility from Axis. The method I am trying to call is getFibo(), which returns an object FiboHolder. Unfortunately everytime it is throwing ClassCastException. I have couple of other methods in the service that returns int and int[] and both works fine. Could anyone please help why I am not able to consume the service when it is returning the object FiboHolder but works fine when I consume other methods of the service that returns int or int[]?
    Following is my client code:
        FibonacciService service =  new FibonacciServiceLocator();
        FibonacciSoapBindingStub stub = (FibonacciSoapBindingStub) service.getfibonacci(new URL("http://localhost:8080/axis/services/fibonacci"));
        // Now use the service to get a stub to the service
        FiboHolder fibHold = stub.getFibo();  //code errors out at runtime here
        System.out.println(fibHold.getFibo1());Following is the error message I get:
    org.apache.axis.AxisFault: java.lang.ClassCastException
    AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.lang.ClassCastException
    faultActor:
    faultNode:
    faultDetail:
         {http://xml.apache.org/axis/}hostname:
    Thanks,

    Hi all,
    Please throw some light into this issue i am getting the following exception.
    com.sap.engine.services.webservices.jaxm.soap.accessor.NestedSOAPException: Problem in server response: Proxy Authentication Required.
    I have given the proxy settings in the com.sap.portal.ivs.httpservice  in the portal and also
    defined a proxy server in the Visual Administrator under Services -> Webservice Container -> HTTP Proxy Server
    I am calling service in the following manner.
    IPortalRuntimeResources runtime = PortalRuntime.getRuntimeResources();
       IService service = runtime.getService(IWS_P_Service.KEY);
       IWS_P_Service ws_service = (IWS_P_Service)service;
        Volumes from = new Volumes(Volumes.VOLUMES_KILOLITER_VALUE);
        Volumes to = new Volumes(Volumes.VOLUMES_LITER_VALUE);
        ChangeVolumeUnit cvu = new ChangeVolumeUnit(1200,from,to);
        // working upto here
         response.write("working");
         ChangeVolumeUnitResponse cvu_res = ws_service.ChangeVolumeUnit(cvu);
         double result = cvu_res.getChangeVolumeUnitResult();
         response.write(result+"");
    It is working upto "working".
    If any body has any solutions please post.
    Thanks

  • HELP!! ClassCastException with custom module classloader hierarchy and redeployment

    Hi,
    I am defining custom module classloader hierarchy to avoid redeploying of the
    entire application mainly because we have so many EJBs and it takes a long time
    to deploy the entire app. I deploy my app using the exploded directory, add a
    new method to an EJB in my dal.jar, redeploy, run my unittest and I get ClassCastException.
    I am using weblogic.Deployer utility to reploy my module using "-targets dal.jar@accsserver"
    argument. I even tried undeploying that module and redeploy again with no luck.
    here is weblogic-application.xml definition of the custom class loader
    <classloader-structure>
    <module-ref>
         <module-uri>floghmi.war</module-uri>
         </module-ref>
    <module-ref>
         <module-uri>cts.jar</module-uri>
         </module-ref>
    <module-ref>
         <module-uri>fdbs.jar</module-uri>
         </module-ref>
    <classloader-structure>
         <module-ref>
              <module-uri>dml.jar</module-uri>
         </module-ref>
    <classloader-structure>
         <module-ref>
         <module-uri>dal.jar</module-uri>
    </module-ref>
    </classloader-structure>
    </classloader-structure>
    </classloader-structure>
    thanks,
    Nasrin

    Rob,
    regarding your question on redeploying the whole app without the classloader
    structure, yes, that works fine. If I change a class and redeploy the whole app,
    things are ok. However, when I speocify the classloader structure, and try to
    redeploy the dal.jar, I get ClassClasException.
    You are right about dml.jar being in a separate classloader. I have changed my
    structure after I posted my question to load dml.jar from the application classloader.
    So Rob, is there a bug in Weblogic 8.1 that causes this exception?
    please let me know, I am anxiously waiting your response.
    thanks,
    Nasrin
    Rob Woollen <[email protected]> wrote:
    >
    >
    Nasrin Azordegan wrote:
    Rob,
    if I remove my classloader structure from weblogic-application.xml,I get an
    error during redeployment, saying "You must include all of<list ofmy module names
    here> in your files list to modify <dal.jar>. Yes, the server enforces constraints on partial redeployments. You must
    deploy all the modules in a given classloader and any modules in child
    classloaders.
    Just to make sure, if you initially deploy your app, or redeploy the
    whole thing, it works fine without the classloader-structure, right?
    The problem I am trying to solve is to minimize our deployment time.Our application
    has over 700 CMP 2.0 entity beans and 200 session beans. Our applicationdeployment
    follows the J2EE layer architecture. The data mapping layer which consistof 700
    entity beans are located in dml.jar. The data access layer which consistof 200
    session beans are located in dal.jar. We create our ear with thesetwo jar files
    plus some other framework jars and deploy on bea weblogic 8.1 SP2 andthat takes
    about an hour. I need to be able to modify a session bean, i.e. changethe implementation
    of a session bean or add a new method to a session bean interface andredeploy
    only data access layer, the dal.jar, not the entity beans. This explainswhy you
    see dml.jar in a classloader with a child classloader that loads dal.jar.
    I included the ClassCastException from weblogic server console below.What is
    happening is that I have a session bean with 6 methods that just doesa println.
    I deploy my session bean, ExerciseSessionBeanFactory, and run my unittest that
    invokes test1 through test6 methods. I modify my bean to add "test7"method and
    redeply dal.jar successfully. I run my unit test that invokes test1through test7
    methods and then I get a ClassCastException.
    I hope this helps. Please let me know if you need more details.If you push dml.jar into a subloader, that means you can change dml.jar
    without touching anything in the parent loader. However, it also means
    that you've isolated it's classes and other modules can't see them.
    -- Rob
    thanks,
    Nasrin
    in test method
    in test2 method
    in test3 method
    in test4 method
    in test5 method
    in test6 method
    <Apr 12, 2004 9:26:03 AM PDT> <Warning> <EJB> <BEA-010096> <The Message-Driven
    EJB: SimTimeListener is unable to connect
    to the JMS destination: cn=t.cms.cts.simTimeInfo. Connection failedafter 184
    attempts. The MDB will attempt to reconne
    ct every 10 seconds. This log message will repeat every 600 secondsuntil the
    condition clears.>
    <Apr 12, 2004 9:26:03 AM PDT> <Warning> <EJB> <BEA-010061> <The Message-Driven
    EJB: SimTimeListener is unable to connect
    to the JMS destination: cn=t.cms.cts.simTimeInfo. The Error was:
    [EJB:011011]The Message-Driven EJB attempted to connect to the JMSdestination
    with the JNDI name: cn=t.cms.cts.simTimeI
    nfo. However, the object with the JNDI name: cn=t.cms.cts.simTimeInfois not a
    JMS destination, or the destination found
    was of the wrong type (Topic or Queue).>
    in test method
    in test2 method
    in test3 method
    in test4 method
    in test5 method
    in test6 method
    <Apr 12, 2004 9:28:26 AM PDT> <Warning> <RMI> <BEA-080003> <RuntimeExceptionthrown
    by rmi server: com.trs.cv.infr.istr.
    sc.sim.factory.ejb.ExerciseSessionFactory_zhotso_EOImpl.test7()
    java.lang.ClassCastException.
    java.lang.ClassCastException
    at com.trs.cv.infr.istr.sc.sim.factory.ejb.ExerciseSessionFactory_zhotso_EOImpl_WLSkel.invoke(Unknown
    Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
    at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    Rob Woollen <[email protected]> wrote:
    You'll have to give me some more information on the ClassCastException.
    Where does it happen? Print out the classnames and the
    classloaders of the 2 objects.
    Does everything work fine if you remove your classloader-structure?
    -- Rob
    Nasrin Azordegan wrote:
    Hi,
    I am defining custom module classloader hierarchy to avoid redeployingof the
    entire application mainly because we have so many EJBs and it takesa long time
    to deploy the entire app. I deploy my app using the exploded directory,add a
    new method to an EJB in my dal.jar, redeploy, run my unittest and
    I
    get ClassCastException.
    I am using weblogic.Deployer utility to reploy my module using "-targetsdal.jar@accsserver"
    argument. I even tried undeploying that module and redeploy again
    with
    no luck.
    here is weblogic-application.xml definition of the custom class loader
    <classloader-structure>
    <module-ref>
         <module-uri>floghmi.war</module-uri>
         </module-ref>
    <module-ref>
         <module-uri>cts.jar</module-uri>
         </module-ref>
    <module-ref>
         <module-uri>fdbs.jar</module-uri>
         </module-ref>
    <classloader-structure>
         <module-ref>
              <module-uri>dml.jar</module-uri>
         </module-ref>
    <classloader-structure>
         <module-ref>
         <module-uri>dal.jar</module-uri>
    </module-ref>
    </classloader-structure>
    </classloader-structure>
    </classloader-structure>
    thanks,
    Nasrin

  • Help with java.lang.ClassCastException in JSSE

    I need an urgent help.
    i am writing code in JSSE for getting Server certificater(through SSL)
    i wrote
    public class url
    public static void main(String[] args)
    try
    System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
    Security.addProvider(new Provider());
    URL url=new URL("https://localhost:8443");
    HttpsURLConenction urlc=(HttpsURLConnection) url.openConnection();
    catch(Exception e)
    System.out.println(e);
    when i am executing this programing, i am getting the following run time error
    java.lang.ClassCastException
    I think i am getting error for the following line of code
    " HttpsURLConenction urlc=(HttpsURLConnection)url.openConnection(); "
    Please help me out to overcome this run time error.
    I would be grateful to you if you can solve my error

    Hi all
    I have the same error:
    java.lang.ClassCastException: com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl
    MY CODE IS:
    // Set the system and security properties
                   System.setProperty("javax.net.ssl.trustStore",
                             "C:\\certificados\\cacerts");
                   System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
                   // Keystore location and password
                   System.setProperty("javax.net.ssl.keyStore",
                             "C:\\certificados\\keystore");
                   System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
    //Set the request
    String url_ = "https://195.235.160.165";
    //Creamos la petici�n html
    StringBuffer buffer = new StringBuffer();
    buffer.append(url_);
    buffer.append("/GPP/WLServer?Method=M_FINDIT&CLIENT=");
    buffer.append(client);
    buffer.append("&CLI_PASSWD=");
    buffer.append(cli_passwd);
    buffer.append("&USER=");
    buffer.append(user_login);
    buffer.append("&USER_PASSWD=");
    buffer.append(user_passwd);
    buffer.append("&TUSERID=");
    buffer.append(MSISDN);
    buffer.append("&TUSERID_TYPE=MSISDN");
    buffer.append("&GROUP=");
    buffer.append(group_id);
    buffer.append("&SRS=GPP:UTM28");
    url_ = buffer.toString();
    URL url = new URL(url_);
    HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
    conn.setHostnameVerifier(new HostnameVerifier() {
    public boolean verify(String hostname, SSLSession session)
    // I don't care if the certificate doesn't match host name
    return true;
    BufferedReader in = new BufferedReader(
                        new InputStreamReader(
                        conn.getInputStream()));
    //Creates a writer with the encoding parameter as "UTF-8"
    Writer out_ = new OutputStreamWriter(response.getOutputStream(), "UTF-8" );
    String inputLine;
         String fichero_in = "";
         while ((inputLine = in.readLine()) != null){               
         if(inputLine.length()!=0){
              System.out.println(inputLine);
              fichero_in = inputLine;
              out_.write(inputLine);
         in.close();
    //Sets the Content-Type header
    response.setContentType("application/xml; charset=utf-8");
         //response.setContentType("text/html; charset=UTF-8");
    //Sends the response XML to the client
    out_.write(url_);
    //out_.write(fichero_in);
    out_.flush();
    response.sendRedirect(response.encodeRedirectURL("out_"));
    Anyone can hel me??
    Thanks in advance

  • ClassCastException calling EJB from EJB (diff  EARs) Urgent please help !!

    Hi,
    I�m trying to call a Remote EJB ( in jdev BBEAN.prj ) from another EJB (in jdev ABEAN.prj) located in a different EAR.
    In JDEVELOPER (oc4j 9.0.3) I also considered BBEAN as a libreary which is included in the ABEAN project.
    So that the ABEAN JAR contains the class definition for the Home and remote interface.
    From the ABEAN bean I call this code:
    DO ()
    private static Context getInitialContext() throws NamingException
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "manager");
    env.put(Context.PROVIDER_URL, "ormi://GSARNO-1/BBean");
    return new InitialContext(env);
    BBeanHome BBeanHome = (BBeanHome)PortableRemoteObject.narrow(context.lookup("BBean"), BBeanHome.class);
    BBean bBean;
    ������������..
    After having deployed both projects I then run a client (Calling the Do function).
    Doing so I keep receiving the following error when calling narrow.
    java.lang.ClassCastException
    java.lang.Object com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class)
    PortableRemoteObject.java:296
    java.lang.Object javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class)
    PortableRemoteObject.java:137
    java.lang.String mypackage1.impl.MySessionEJBBean.Do()
    MySessionEJBBean.java:39
    java.lang.String MySessionEJB_StatelessSessionBeanWrapper6.Do()
    MySessionEJB_StatelessSessionBeanWrapper6.java:85
    java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])
    native code
    void com.evermind.server.rmi.RMICallHandler.run(java.lang.Thread)
    RMICallHandler.java:119
    void com.evermind.server.rmi.RMICallHandler.run()
    RMICallHandler.java:48
    void EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run()
    PooledExecutor.java:803
    void java.lang.Thread.run()
    Thread.java:484
    Can anyone help ?
    What should I do to call remote e/o local interfaces located on different EARs ?
    I�m using OC4J 9.0.3

    Hi Giuseppe,
    If both EAR files are in the same OC4J instance you do not have to use RMIInitialContextFactory to invoke the EJB. You have to do the following:
    In OC4J
    1) Make the BBEAN as the parent for ABEAN application defined in the server.xml as follows:
    application name="ABEAN" path="../applications/abean.ear" parent="BBEAN" auto-start="true" />
    2)
    You can define ejb-ref or ejb-local-ref in the deployment descriptor of your application
    3) You can use the default InitialContext to lookup your EJB as if both EJBs are in the same application
    regards
    Debu

  • ClassCastException error  Please Help!

    When I run my Java Applet, I get a ClassCastException error. Here's the link: http://users.route24.net/~jtrost/bb4/bb4.html
    I have no idea what this means or how to fix it? Could someone please help me? Also, here are the two java files: http://users.route24.net/~jtrost/bb4/Guest.java
    http://users.route24.net/~jtrost/bb4/Picker.java
    Picker.java is the main one, and Guest.java just holds information about every instance of the array of Guest that I have.
    Thank you!

    dear friend
    well i have worked with java a lot. i went 2 ur site but i was unable to see ur applet. then i downloaded ur code and run it on my pc and it run fine. but i have some doubts. clear them so that i can better help u.
    1> this is an application and not an applet. please post the original version of ur applet so that i can study it. or atleast make ur applet available on the link u have given.
    2> ur coding is good but there are some loopholes which can cause indirect problems. i may clear them after studying ur applet.
    here are some solutions which i can give u at this stage
    ClassCastException is also thrown when u r using different versions (maybe compiled from two different java files) at different places. make sure ur class file is directly compiled in the spacified folder.
    dont make every class public
    run the applet on appletviewer and see if the same error exists
    set indirect debug points by writing System.out.println("something") on various places and try to find out origion of the exception (this works only with appletviewer)
    there was a problem when running this aplication that it was not exiting. try to find out why.
    write your problem in detail.jitin

  • Help! ClassCastException with Tomcat and HttpsUrlConnectionOldImpl

    Hi,
    I am trying to perform an HTTPS call from a servlet running under Tomcat 5.5, JDK 1.5.0 . When I do, I get this error:
    java.lang.ClassCastException: com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl
    at rcopia.util.WebUtils.setAutoVerify(WebUtils.java:1398)
    at rcopia.util.WebUtils.getURLConnection(WebUtils.java:1377)
    (etc).
    I have included
    System.setProperty("java.protocol.handler.pkgs", "javax.net.ssl");
    but it doesn't seem to help. How can I get Tomcat to use the new javax.net JSSE rather than the old com.sun.net... packages it is rying to use?
    Please help!
    Brandon

    System.setProperty("java.protocol.handler.pkgs", "javax.net.ssl");Don't do that. It's for JDK 1.3 and the JSSE extension.

  • Help ClassCastException !

    I use borland appserver4.5 and jbuilder5.0 to deploy ejb. My bean-managed includes:
         Home interface is TestHome
         Remote interface is Test and a findAll() method has a result is Enumeration(Collection)
    In my client program , i cast :
         Enumeration e=TestHome.findAll("...");
         while(e.hasMoreElements()){     
         Test t=(Test)e.nextElement();
    Then has a message :
         Return value from findByName(Monkey): com.inprise.ejb.util.VectorEnumeration@60e128.
         java.lang.ClassCastException: com.inprise.vbroker.rmi.CORBA.ObjectImpl
    is there a problem in Vbroker ? and how to resolve ClassCastException ? .
    Please help me ! Thanks a lot !           

    Try like this it will work.
    TestHome home =
    (TestHome) PortableRemoteObject.narrow(initialContext.lookup("TestEJB"),TestHome.class);
    Enumeration e = home.findByID(999);
    int i =0;
    while(e.hasMoreElements()){
    Test rt = (Test) PortableRemoteObject.narrow( e.nextElement(),Test.class);

  • Java.lang.ClassCastException in simple struts application. please help me!

    I have a simple struts application, it only have a login form. however, it's alway throw java.lang.ClassCastException when I submit the form. Here is full stack trace:
    14-03-2007 17:04:50 org.apache.struts.chain.ComposableRequestProcessor init
    INFO: Initializing composable request processor for module prefix ''
    14-03-2007 17:04:50 org.apache.struts.chain.commands.servlet.CreateAction getAction
    INFO: Initialize action of type: ndlinh.struts.lab.RegistrationForm
    14-03-2007 17:04:50 org.apache.struts.chain.commands.AbstractExceptionHandler execute
    WARNING: Unhandled exception
    java.lang.ClassCastException: ndlinh.struts.lab.RegistrationForm
         at org.apache.struts.chain.commands.servlet.CreateAction.getAction(CreateAction.java:66)
         at org.apache.struts.chain.commands.AbstractCreateAction.execute(AbstractCreateAction.java:82)
         at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:48)
         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:280)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:459)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.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)
    14-03-2007 17:04:50 org.apache.struts.chain.commands.ExceptionCatcher postprocess
    WARNING: Exception from exceptionCommand 'servlet-exception'
    java.lang.ClassCastException: ndlinh.struts.lab.RegistrationForm
         at org.apache.struts.chain.commands.servlet.CreateAction.getAction(CreateAction.java:66)
         at org.apache.struts.chain.commands.AbstractCreateAction.execute(AbstractCreateAction.java:82)
         at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:48)
         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:280)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:459)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.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)
    Here is my code:
    package ndlinh.struts.lab;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    public class RegistrationForm extends ActionForm {
         private String userid = null;
         private String password = null;
         private String password2 = null;
         public RegistrationForm() {
              System.out.println("************ Registration Form created *************");
          * @return the password
         public String getPassword() {
              return password;
          * @param password the password to set
         public void setPassword(String password) {
              this.password = password;       
          * @return the password2
         public String getPassword2() {
              return password2;
          * @param password2 the password2 to set
         public void setPassword2(String password2) {
              this.password2 = password2;
          * @return the userid
         public String getUserid() {
              return userid;
          * @param userid the userid to set
         public void setUserid(String userid) {
              this.userid = userid;
         public void reset(ActionMapping arg0, HttpServletRequest arg1) {
              userid = "";
              password = "";
              password2 = "";
    package ndlinh.struts.lab;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    public final class RegistrationAction extends Action {
         public ActionForward execute(ActionMapping mapping, ActionForm actionForm,
                                             HttpServletRequest request, HttpServletResponse response)
              try {
                   System.out.println("*******************" + actionForm.toString() + "*******************");
                   RegistrationForm form = (RegistrationForm)actionForm;     
                   String username = form.getUserid();
                   String password = form.getPassword();
                   System.out.println(username);
                   // simple login checking.
                   // if userid equals password, user can login to system
                   if ( username.equalsIgnoreCase(password)) {
                        return mapping.findForward("success");
                   } else {
                        return mapping.findForward("failure");
              } catch (Exception e) {
                   e.printStackTrace();
                   return mapping.findForward("failure");
    }registration.jsp
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
         <html:form action="/register">
              Username: <html:text property="userid" /> <br />
              Password: <html:password property="password" /> <br />
              Re-type: <html:password property="password2" />
              <html:submit value="Register" />
         </html:form>
    </body>
    </html>struts-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
      <form-beans>
           <form-bean name="registrationForm" type="ndlinh.struts.lab.RegistrationForm" />
      </form-beans>
      <action-mappings>
           <action path="/register"
                   type="ndlinh.struts.lab.RegistrationForm"
                   name="registrationForm"
                   validate="false"
                   scope="request"
                   input="registration.jsp" >
                <forward name="success" path="/jsp/success.jsp"  />
                <forward name="failure" path="/jsp/failure.jsp"  />
           </action>
      </action-mappings>
    </struts-config>web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>
      <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>
    </web-app>System information:
    Tomcat 5.5.20
    Struts 1.3.5
    JDK1.5.08

    struts-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
      <form-beans>
           <form-bean name="registrationForm" type="ndlinh.struts.lab.RegistrationForm" />
      </form-beans>
      <action-mappings>
           <action path="/register"
                   type="ndlinh.struts.lab.RegistrationAction" // action class
                   name="registrationForm" // form bean name
                   validate="false"
                   scope="request"
                   input="registration.jsp" >
                <forward name="success" path="/jsp/success.jsp"  />
                <forward name="failure" path="/jsp/failure.jsp"  />
           </action>
      </action-mappings>
    </struts-config>HTH

  • Plz help me out to solve classCastException

    if (loRec != null)
    if(loRec.getPOSN_SPLT_FL())
    //--------->>>>>getting classCastException at this point
    rowToBeAdded.setValue("POSN_SPLT_FL", "true");
    else
    rowToBeAdded.setValue("POSN_SPLT_FL", "false");
    }

    Zadok am adding the relevant code.........................................................................
    DataRow rowToBeAdded;
    SearchRequest loSrchReq = new SearchRequest();
    loSrchReq.addParameter("EMPL_ID", "INTERNAL_EMPL_ID", rowToBeAdded.getData("INTERNAL_EMPL_ID").getString()) ;
    loSrchReq.addParameter("EMPL_ASGNMT", "EFFECTIVE_DT", rowToBeAdded.getData("EFFECTIVE_DT").getVSDate().toString()) ;
    loSrchReq.addParameter("EMPL_ASGNMT", "APPOINTMENT_ID", rowToBeAdded.getData("APPOINTMENT_ID").getString()) ;
    loSrchReq.addParameter("EMPL_ASGNMT", "INTERNAL_POSN_ID", rowToBeAdded.getData("INTERNAL_POSN_ID").getString()) ;
    EMPL_ASGNMTImpl loRec = ( EMPL_ASGNMTImpl ) EMPL_ASGNMTImpl.getObjectByKey( loSrchReq, loSession ) ;
    if (loRec != null)
    if(loRec.getPOSN_SPLT_FL())
    rowToBeAdded.setValue("POSN_SPLT_FL", "true");
    else
    rowToBeAdded.setValue("POSN_SPLT_FL", "false");
    }

  • Help figuring out ClassCastException

    I inherited an unfinished (undocumented and uncommented) program from another programmer (now gone), and I'm trying to figure out a ClassCastException that gets thrown at runtime.
    The program contains a lot of custom classes for table manipulation. The two key classes here are TableIndex, and TableSorter. Their inheritance hierarchy is as follows:
    TableSorter extends TableMap
    TableMap extends AbstractTableModel
    AbstractTableModel implements TableModel
    TableIndex implements TableModel.
    At some point, a JTable is created that has a TableIndex as it's model:
    TableIndex ti = new TableIndex();
    JTable table = new JTable(ti);Later on, this call is made, and it throws a ClassCastException:
    (TableSorter) table.getModel();table.getModel() returns a TableIndex, which is being (illegally) cast to a TableSorter. Looking up the inheritance chain, both TableIndex and TableSorter are derived from TableModel. Why, then, is this not working? Is this problem because both classes are not extended from the same superclass? Can someone tell me where the break is?

    a cast doesnt convert the programm, it only "unhides" methods which the static type hides.
    every class extends object, hence you can always write Object o = new Bleh();
    however you can only access the methods declared in object on o. if you cast it to (Bleh) all the additional methods you wrote come available(they were always there, you just hid them)
    now if you have another class Blub, and you attempt to do (Blub)o, you will get an error, since o isnt of the type Blub(its Bleh). you will get an error, since o cant offer you all the methods you declared in Blub.
    in your particular case TableIndex would hav to extend TableSorter in order for this cast to work.

  • Remote object trying to return another remote object and a ClassCastExcepti

    I have a server running with a TreeModel (the tree model implements Remote). I also have the the TreeNodes all linked together on the server. Now, I can get to the TreeModel on the server and the root node of the remote tree model.
    treeModelStub = (treeModelIface)Naming.lookup(url+"remoteTM"); //works
    rootStub = (remoteTreeNodeIface)treeModelStub.getRoot(); //works. The call to getRoot returns Object
    But when I call
    remoteTreeNodeIface aChild = (remoteTreeNodeIface)rootStub.getChildAt(index) //Does not work. "Exception in thread "main" java.lang.ClassCastException
    at remoteTreeNode_Stub.getChildAt(Unknown Source)
    The remote tree node method getChildAt returns TreeNode because the class implements TreeNode:
    public class remoteTreeNode extends UnicastRemoteObject implements rdcaDataIface, Comparable, TreeNode {
    public TreeNode getChildAt(int idx) {
    System.out.println("DEBUG: class is "+this.getClass()); // class is remoteTreeNode
    return (remoteTreeNode)children.get(idx);
    The remote interface is defined as:
    public interface rdcaDataIface extends java.rmi.Remote {
    public TreeNode getChildAt(int idx) throws RemoteException;
    Any ideas why this does not work. Why can a remote object of type Object be returned just fine, but a TreeNode not be returned?
    Thank you for your help,
    Brent

    I have a server running with a TreeModel (the tree
    model implements Remote). I also have the the
    TreeNodes all linked together on the server. Now, I
    can get to the TreeModel on the server and the root
    node of the remote tree model.
    treeModelStub =
    (treeModelIface)Naming.lookup(url+"remoteTM");
    //works
    rootStub =
    (remoteTreeNodeIface)treeModelStub.getRoot();
    //works. The call to getRoot returns Object
    But when I call
    remoteTreeNodeIface aChild =
    (remoteTreeNodeIface)rootStub.getChildAt(index)******************************************
    can only be casted to rdcaDataIface. The returned object is an instanceof the rdcaDataIface_stub, which have nothing to do with TreeNode.
    //Does not work. "Exception in thread "main"
    java.lang.ClassCastException
    at remoteTreeNode_Stub.getChildAt(Unknown
    t(Unknown Source)
    The remote tree node method getChildAt returns
    TreeNode because the class implements TreeNode:
    public class remoteTreeNode extends
    UnicastRemoteObject implements rdcaDataIface,
    Comparable, TreeNode {
    public TreeNode getChildAt(int idx) {
    System.out.println("DEBUG: class is
    lass is "+this.getClass()); // class is
    remoteTreeNode
    return (remoteTreeNode)children.get(idx);
    The remote interface is defined as:
    public interface rdcaDataIface extends java.rmi.Remote
    public TreeNode getChildAt(int idx) throws
    ows RemoteException;
    Any ideas why this does not work. Why can a remote
    object of type Object be returned just fine, but a
    TreeNode not be returned?
    Thank you for your help,
    Brent

  • ClassCastException when deploying jsf war on Weblogic 10.3.2

    Hello everybody,
    We 're having an issue when deploying jsf war on Weblogic 10.3.2
    The war works fine on Tomcat 6.
    When deploying on Weblogic we got the following exception:
    java.lang.ClassCastException: weblogic.xml.jaxp.RegistryXMLReader cannot be cast to org.xml.sax.XMLReader
    I've already put <prefer-web-inf-classes>true</prefer-web-inf-classes> in weblogic.xml
    After "googling", people suggest to remove xml-apis jar from WEB-INF/lib, but doing so results in other exceptions.
    Is there any fix for this issue? Please help it's been more than a month that we are crawling in the dark with this error.
    Thanks in advance.

    Hello everybody,
    We 're having an issue when deploying jsf war on Weblogic 10.3.2
    The war works fine on Tomcat 6.
    When deploying on Weblogic we got the following exception:
    java.lang.ClassCastException: weblogic.xml.jaxp.RegistryXMLReader cannot be cast to org.xml.sax.XMLReader
    I've already put <prefer-web-inf-classes>true</prefer-web-inf-classes> in weblogic.xml
    After "googling", people suggest to remove xml-apis jar from WEB-INF/lib, but doing so results in other exceptions.
    Is there any fix for this issue? Please help it's been more than a month that we are crawling in the dark with this error.
    Thanks in advance.

  • HELP!  I can't  filter out jsf-impl.jar

    Every jar file can be filtered out of a deployment file EXCEPT jsf-impl.jar, Why?
    JDeveloper (older) version of jsf-impl.jar is causing problem with a newer version in JBossAS 4.2.0.CR1 and consequently, throwing java.lang.ClassCastException error. I can filter out every other jar file but not jsf-impl.jar.
    If I manually remove the jsf-impl.jar from my project /WEB-INF, JDeveloper complains about the missing jsf-impl.jar when I restart it. The other alternative is to manually delete the jsf-impl.jar from my *.war file every time I re-deploy it to JBossAS. This option is very tedious in production with frequent re-deployment.
    Could someone suggest a more civilised approach to excluding jsf-impl.jar from my deployment file? I will also like to know why it is not possible to filter out jsf-impl.jar like other jars. Could this be a bug?
    Thanks for your help

    I have found the problem: For those who might be interested and in addition to the normal way filtering deployment files, you also need to uncheck the jsf-impl.jar as follows;
    1 This is in the War Deployment Profile Property
    2 Right click web project name
    3 Click the ‘War Deployment Profile Property’ option
    4 The ‘War Deployment Profile Property’ dialog open
    5 Select File Group
    6 Select Web Filter
    7 Select Contribution
    8 Select Filter
    9 Select WEB-INF
    10 Select lib
    11 Uncheck jsf-imp.jar

Maybe you are looking for

  • I have a brand new iPad newest version. Wifi. The messaging won't send out but I receive messages from others. What is wrong?

    I have the newest version of the iPad (3rd generation) with wifi. The messaging won't send out but I'm receiving messages from others when I'm using it. They also come through on my iphone at the same time. But I can't send them out on the iPad. I tr

  • Writing area won't pop up - Digitizer issue

    My heavily used TX screen has a dead area (actually it's on life support). The dead area is the extreme lower right: the icon that expands and hides the writing area. Note that it works fine in landscape mode but that's not my favorite mode of use. M

  • Cannot see the elements in Web Service Action block

    Hi, When I use SoapUI I can see the elements of a Service but when I use Web Service Action block of MII, I can only see the first element (job). The children of job are not appearing in link editor. Any Idea? <soapenv:Envelope xmlns:soapenv="http://

  • Colors of the Icons in the Print Document Content Window

    When you right click a single source layout and click properties and then click next it takes you to the Print Document Content Window, where you can take topics and by clicking the arrow that points to the right hand frame, move the topics into your

  • PXI 5673 RFSG WriteScript Issue

    I generated niRFSG.mdd and implemented MATLAB code to do the same thing as the ScriptTrigger CVI code. However, an error occurs when calling invoke(sig_gen.GenerationConfigurationScripting,'writescript',waveformscript) NI PXIe-5673E The instrument re