ClassCastException with t:datatable

Hi
I am using apache myfaces and trying to use its datatable with preserveDataModel=true attribute. I get the following exception when I click on a command link inside the datatable -
[Servlet Error]-[Faces Servlet]: java.lang.ClassCastException: javax.faces.model.ListDataModel incompatible with org.apache.myfaces.component.html.ext._SerializableDataModel
I do have the latest tomahawk-1.1.3.jar which is supposed to have one fix mentioned on tihs issue.
Reading the doc on JSF datatable it seems like the datamodel is not serializable for pure JSF. So how do I get the datamodel to be a subclass of what myfaces is looking for?
Any pointers wold be very helpful.
Thanks

Well here is a code snippet that works fine:
extract of JSP-page:
=============
<h:dataTable value="#{usrctrl.userList}" var="user" rowClasses="odd, even"
             styleClass="datatable" align="center">
    <h:column>
        <f:facet name="header">
            <h:outputText value="#{msg['name.first']}" />
        </f:facet>
        <h:outputText value="#{user.firstName}" />
    </h:column>
</h:datatable>source of usrctrl:
===========
    public java.util.List<User> getUserList () {
        java.util.List<User> users = new ArrayList ();
        users.addAll (userControl.getUsers ()); // get data from backeind
        return users   
...interface of userControl:
================
    public java.util.List<User> getUsers () {Class user has to implement a method named public String getFirstName().
Hope that gets you further.
Regards Mark

Similar Messages

  • ERROR:JAVA.LANG.CLASSCASTEXCEPTION WITH JDEVELOPER 10.0.1.3

    I´m trying to use JSTL functions but I have the error
    "Error:java.lang.ClassCastException with JDeveloper 10.0.1.3".
    When I make or rebuild the code I have the error.
    The test <c:when test="${fn:length(P_LIGACOES) > 0}" > has error. I´ve been
    used others functions and the error is the same.
    Please, see JSP code as follows:
    <%@ page import="java.text.DateFormat"%>
    <%@ page import="java.text.SimpleDateFormat"%>
    <%@ page import="java.text.NumberFormat"%>
    <%@ page import="com.celesc.tf.BilheteTelefonico"%>
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Ligações Telefônicas</title>
    <style type="text/css">
    Body{
    background-image: url(images/fdo.jpg);
    background-repeat: no-repeat;
    background-color: #FFFFFF;
    </style>
    <link href="css/ligtel.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    <h1 align=center> </h1>
    <h1 align=center> </h1>
    <c:choose>
    <c:when test="${!empty mensagem}">
    <h1 align=center>
    <img src="images/erro.jpg"><font size="5" face="Verdana, Arial, Helvetica,
    sans-serif"><c:out value="${mensagem}"/></font></h1>
    </c:when>
    <c:otherwise>
    <%
    Vector ligacoes = (Vector) request.getAttribute("P_LIGACOES");
    SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy
    HH:mm:ss");
    double totalligacoes = 0;
    NumberFormat preco = NumberFormat.getCurrencyInstance();
    %>
    <c:choose>
    <c:when test="${fn:length(P_LIGACOES) > 0}" >
    <h1 align=center><font size="5" face="Verdana, Arial, Helvetica,
    sans-serif">Nenhuma ligação Realizada</font></h1>
    </c:when>
    <c:otherwise>
    <h1 align=center><font size="5" face="Verdana, Arial, Helvetica,
    sans-serif">Relação das Ligações</font></h1>
    <table class="table-normal" width="70%" align="center">
    <tr class="table-result">
    <td colspan="5"><b><%= ligacoes.size()%> </b> Ligações Realizadas</td>
    </tr>
    <tr class="table-title">
    <td>Fone Chamado</td>
    <td>Ramal</td>
    <td>Data</td>
    <td>Duração</td>
    <td>Custo(R$)</td>
    </tr>
    <c:forEach items="${P_LIGACOES}" var="bilhete">
    <tr class="table-content">
    <td><c:out value="${bilhete.numeroChamado}"/></td>
    <td><c:out value="${bilhete.ramalOrigem}"/></td>
    <td><c:out value="${bilhete.dataLigacao}"/></td>
    <td><c:out value="${bilhete.duracao}"/></td>
    <!--<td><c:out value="${bilhete.custo}"/></td>-->
    <td><c:out value="${bilhete.custo}"/></td>
    <c:set var="totalligacoes" value="${totalligacoes +
    bilhete.custo}"/>
    </tr>
    </c:forEach>
    <tr class="table-result">
    <td colspan="4" align="right"><B>Total</B></td>
    <!-- <td ><B><%= preco.format(totalligacoes)%></B></td> -->
    <td><B><c:out value="${totalligacoes}" /></B></td>
    </tr>
    </table>
    </c:otherwise>
    </c:choose>
    </c:otherwise>
    </c:choose>
    </body>
    </html>

    Hi,
    Please make sure that there is no other version of *"net.nrj.alf.DimensionLabel"* class present in any other Class Loader
    There are various kind of Class Loaders : PreMordial Class Loader, BootStrap ClassLoader, System Class Loader (WebLogic ClassLoader), Application ClassLoader, Module Class Loader....
    net.nrj.service.SearchServiceProcessor java.lang.ClassCastException: net.nrj.alf.DimensionLabel java.lang.ClassCastException: net.nrj.alf.DimensionLabel If your code is working fine in WLS9.2 it means in WLS10.3.3 the same class is getting loaded from different Class Loaders...In order to find out which classLoader is being used to load that class please do the following:
    <b><font color=maroon>
    Class dimentionLevel=Class.forName("net.nrj.alf.DimensionLabel")
    ClassLoader cl=dimentionLevel.getClassLoader();
    System.out.println("\n\n\t DimentionLevel is loaded from ClassLoader: "+cl);
    </font></b>
    Above 3 Lines of code you need to write for "net.nrj.service.SearchServiceProcessor" class as well...Because i suspect that these two classes are getting loaded from two different class Loaders.
    If the Application Code is 100% correct The Main reason of ClassCastException is Classes are getting Loaded from two Different Class Loaders. You can also look at the Filtering ClassLoader Feature of WebLogic to Tell WebLogic to Load some Classes from a Specific ClassLoaders...As described Here .*http://middlewaremagic.com/weblogic/?page_id=192*
    Thanks
    Jay SenSharma
    http://middlewaremagic.com/weblogic/?page_id=2261  (Middleware magic Is Here)

  • I need help with JSF DataTable

    hi all,
    i have a problem with my DataTable items ...
    i need to access the actuell item of the Table dynamiclly something like this :
    <TD width=1000><h:dataTable id="myId" width="0" border="0" cellspacing="0" cellpadding="10"
    value="#{PageIteratorBean.first}" var="item">
    <h:column>
    <f:verbatim>
    <br>
    <h:outputText value="#{item.discription}" />
    </f:verbatim>
    <h:commandLink action="#{NewsReadBean.linkNews}" styleClass="readMoreLink">
    <h:outputText value="read more ..." styleClass="newsDate" />
    <f:param name="newsPath" value="#{item.path}" />
    </h:commandLink>
    <f:verbatim>
    <jsp:include page='<%=item.path%>' flush="true">
    </jsp:include>
    how can i realise this code ... in this 2 rows i get allways that
    "item.path" cannt be resolved.... what should i do??
    maybe u have an idea or other solutions
    help me please i need to include dynamiclly to every item some other information...
    </f:verbatim>
    </h:column>

    Hi,
    Enter:      79649908
    Regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

  • Datascroller working with dataDefinitionList/datatable issue

    Hi
    I used the datascroller in conjunction with the dataDefintionList to achieve pagination for search results.
    If I search for an item which has 10 pages of results, clicking on page 1,2,...,10 works fine. However, if I click on *>>* it loads page 7 of the search results. However, the *>>* control works perfect after this. I am wondering if anyone else has come upon this.
    I have also noted this behavior using the datascroller in conjunction with a datatable. Like I say, the *>>* control works fine after the first usage. Why it jumps to page 7(generally) on the first usage of it I don't know.
    Thanks
    Joe
    <rich:datascroller for="calendarEntries"
         binding="#{calendarController.dataScroller}"
         maxPages="#{calendarController.maxPages}" fastControls="show"
         pagesVar="#{calendarController.pageCount}"
         pageIndexVar="pageIndex" pages="page"
         page="#{calendarController.currentPage}" boundaryControls="show"
         renderIfSinglePage="false" reRender="tableDisplayMode"
         tableStyleClass="dataScroller" selectedStyleClass="active"
         inactiveStyleClass="inActive"
         actionListener="#{calendarController.viewPageActionListener}">
    </rich:datascroller>
    <rich:datascroller for="listDisplayMode"
         maxPages="#{searchController.maxPages}"
         fastControls="show"
         pagesVar="#{searchController.pageCount}"
         pageIndexVar="pageIndex"
         pages="page"
         page="#{searchController.currentPage}"
         boundaryControls="show"
         renderIfSinglePage="false"
         reRender="listDisplayMode"
         tableStyleClass="dataScroller"
         selectedStyleClass="active"
         inactiveStyleClass="inActive"
         actionListener="#{searchController.viewPageActionListener}"
         rendered="#{searchController.searchReturned and sessionController.listDisplayMode}">
    </rich:datascroller>

    Hi,
    I have find the way.
    We should use
                                <f:verbatim>
                                    <br />
                                </f:verbatim>here is the example
    <h:column binding="#{general$Job_Details.column4}" id="column4">
                                <h:outputText binding="#{general$Job_Details.outputText7}" id="outputText7" value="Low Bid : #{currentRow['LOW_BID']}"/>
                                <f:verbatim>
                                    <br />
                                </f:verbatim>
                                <h:outputText binding="#{general$Job_Details.outputText9}" id="outputText9" value="High Bid : #{currentRow['HIGH_BID']}"/>
                                <f:verbatim>
                                    <br />
                                </f:verbatim>
                                <h:outputText binding="#{general$Job_Details.outputText13}" id="outputText13" value="Bid Count : #{currentRow['BID_COUNT']}"/>
                                <f:facet name="header">
                                    <h:outputText binding="#{general$Job_Details.outputText8}" id="outputText8" value="Bid Status"/>
                                </f:facet>
                            </h:column>Regards
    Sudhakar

  • Problem with jsf DataTable

    when data is fetch using user criteria:
    i have a problem with jsf DataTable. I use e request bean to populate the datatable and i insert a commandButton column. The data dispay successfully into the datatable, but when a push the button on the row...the page simply refresh and notinhg else
    when data is fetch using constants:
    The data dispay successfully into the datatable, when a push the button on the row...the action execute OK

    Hi,
    I don't think that with this description only anybody on this list is able to help you.
    I use e request bean to populate the datatable and i insert a commandButton column
    What is a command button column and what does it do ?
    but when a push the button on the row...the page simply refresh and notinhg else
    What did you do to debug the problem ?
    when data is fetch using constants
    What does this mean ?
    Frank

  • Show HashMap in Datatable. UIColumn with embedded Datatable. Help Needed

    Hi,
    I am trying to display a HashMap in a datatable where the values for each key is an ArrayList e.g.
            ArrayList al = new ArrayList();
            al.add("AA");
            al.add("BB");
            al.add("CC");
            HashMap hm = new HashMap();
            hm.put("ONE", al);
            ArrayList al2 = new ArrayList();
            al2.add("AA2");
            al2.add("BB2");
            al2.add("CC2");
            hm.put("TWO", al2);Now I have a Datatable with two columns. First column shows the key and the second column I again have
    a datatable to show the ArrayList. So I will have one row with a key and the values again shown in a
    datatable. So far I no luck and need some help on how to achieve this. Here is the index2.jsp code I have:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <f:view>
      <html>
        <head>
          <meta http-equiv="Content-Type"
                content="text/html; charset=windows-1252"/>
          <title>index2</title>
        </head>
        <body><h:form binding="#{backing_index2.form1}" id="form1">
        <h:dataTable value="#{backing_index2.entrySet}" var="var1"
                         binding="#{backing_index2.dataTable1}" id="dataTable1" border="1">         
              <h:column>
                <f:facet name="header">
                  <h:outputText value="Keys"/>
                </f:facet>
                <h:outputText value="#{var1.key}"/>
              </h:column>
              <h:column>
                  <f:facet name="header">
                      <h:outputText value="Values"/>
                    </f:facet>
                  <h:dataTable value="#{backing_index2.entrySet}" var="var2"
                             binding="#{backing_index2.dataTable2}" id="dataTable2">             
                      <h:column id="col2">
                        <h:outputText id="out3" value="#{var2.value}"/>
                      </h:column>
                </h:dataTable>
              </h:column>
            </h:dataTable>
        </h:form></body>
      </html>
    </f:view>And here is the backing bean Index2.java I have:
    package project1.backing;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import javax.faces.component.html.HtmlDataTable;
    import javax.faces.component.html.HtmlForm;
    public class Index2 {
        private HtmlForm form1;
        private HtmlDataTable dataTable1;
        private HtmlDataTable dataTable2;
        private List entrySet;
        private HashMap hm;
        public Index2() {
            ArrayList al = new ArrayList();
            al.add("AA");
            al.add("BB");
            al.add("CC");
            hm = new HashMap();
            hm.put("ONE", al);
            ArrayList al2 = new ArrayList();
            al2.add("AA2");
            al2.add("BB2");
            al2.add("CC2");
            hm.put("TWO", al2);
            entrySet = new java.util.ArrayList(hm.entrySet());
         //here it only prints two rows as i have two keys but on the output it
         //does not come up fine
            for (int i = 0; i < entrySet.size(); i++) {
                System.out.println("==== " + entrySet.get(i));
        public void setForm1(HtmlForm form1) {
            this.form1 = form1;
        public HtmlForm getForm1() {
            return form1;
        public void setDataTable1(HtmlDataTable dataTable1) {
            this.dataTable1 = dataTable1;
        public HtmlDataTable getDataTable1() {
            return dataTable1;
        public void setDataTable2(HtmlDataTable dataTable2) {
            this.dataTable2 = dataTable2;
        public HtmlDataTable getDataTable2() {
            return dataTable2;
        public void setEntrySet(List entrySet) {
            this.entrySet = entrySet;
        public List getEntrySet() {
            return entrySet;
        public void setHm(HashMap hm) {
            this.hm = hm;
        public HashMap getHm() {
            return hm;
    }Now when I run this application the keys are shown in the respective column but values are coming up as
    [AA2, BB2, CC2] in one row rather in a separate Row as I am using a Datatable inside UIColumn to show the values.
    Here is what I see in the output:
    keys        Values
    TWO         [AA2, BB2, CC2]
                [AA, BB, CC]
    ONE         [AA2, BB2, CC2]
                [AA, BB, CC] As above output is not correct as it shows both list values in front of each key rather than what those
    keys are tied to. I wanted the following output:
    keys        Values
    ONE         AA
                BB
             CC
    TWO         AA2
                BB2
             CC2So I can do sorting pagination on the values datatable. But currently the output is not shown correctly. Any help
    is really appreciated. My hashmap will be populated dynamically so wants to show the key and values in separate column
    but also need to show the values in an embedded datatable as the list can be huge.

    Rather use a Collection of DTO's. See http://balusc.xs4all.nl/srv/dev-jep-dat.html for some insights. There is also a section "Nesting datatables".

  • ClassCastException with javax.jms.ObjectMessage

    Hello
              I have the following problem:
              I filled a JMS queue with ObjectMessages containing a so called container class (self written, plain old java class implementing serializable).
              I have also written a Servlet that runs in the same EAR like the EJB that fills the JMS queue. This servlet uses a JMS QueueBrowser to show the messages. It casts the Message to ObjectMessage, calls getObject() and casts again in my container class.
              Now when I shutdown the server, regenerate my source and restart the server, the last cast to my container class doesn't work anymore (ClassCastException). When I print out the hash value of the class (containerFromObjectMessage.getClass().hashCode() and Container.class.hashCode() those two hashcodes are different!
              Does anybody have an idea? Is there a switch that I have to set to my WLS 8.1 be a little less secure?
              Regards,
              Stephan

    Correction:
              This only happens when I don't restart my server. So when I hot deploy the EAR with the new compiled classes it doesn't work (ClassCastException). But when I restart the server the servlet runs fine.
              So there must be a cache in the server or something like that.
              Does anybody know any hints or tips to help me?
              Stephan

  • ClassCastException with OracleConnection in Oracle 9i

    I have a piece of code that works perfectly with Oracle 8i and JDK 1.3.
    Now I've migrated to Oracle 9i and JDK 1.4. I continue working with tomcat and I've configured server.xml file (some changes about 'url' and 'username').
    I get a ClassCastException when I try to make a explicit cast to OracleConnection of the connection object recovered. This is the code:
    public class CargadorRecursos {
         public Connection devuelveConexion()
              throws javax.naming.NamingException, SQLException {
              Context envContext = devuelveContexto();
              DataSource ds = (DataSource) envContext.lookup("jdbc/prosegur");
              Connection conn = ds.getConnection();
              return conn;
    in another classes I do:
    OracleConnection conn = (OracleConnection) CargadorRecursos.getCargador().devuelveConexion();
    and then the ClassCastException is raised in the web browser.
    Please, help.

    Cast class exception means you are trying to cast an object to something that it can't be case too.
    You can determine the actual class of an instance by doing the following...
    System.out.println("class=" + myinstance.getClass().getName());
    Once you know the class that actually is being used you can determine the course of action to take...
    1. It isn't the class that you think it is, something is wrong with your code.
    2. Something changed outside of your code and you will have to code around the problem.
    3. Class loaders are being used and you are using class instances from two different class loaders - use the same class loader.

  • 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

  • Problem with a datatable and selectOneMenu

    Hello
    I'm pretty new at java, so this might be an easy problem to solve, but I've been stuck in this for a couple of days now, so any help will be appreciated.
    I have a selectOneMenu item that when it's changed this value loads the info for a datatable below it, this works fine.... but I need that when for example, the select one menu has the value "1", the data tabla loads the activities for the option "1", inside the datatable there is a checkbox for a column, now, in this scenario, when I check 3 options in the datatable, I need to change the value in the selectOneMenu and put, for example the value "2", when this happens now I have to reload the datatable with the values corresponding to the activities for the option "2".
    The problem is when I change the value of the selectOneMenu on the backingBean, because this selectOneMenu has implemented the onchange event, but this is only activated if the the value is changed in the UI, not in the code as I need to do it.
    This are the lilbs that I'm using:
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
    <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    This is the fragment of code of the selectOneMenu:
    <h:selectOneMenu id="ddlTipoVisita" value="#{VisitaDomiciliarBean.idTipoVisita}" disabled="#{VisitaDomiciliarBean.modoEdicion == false}"
    rendered="#{VisitaDomiciliarBean.mostrarSegunOpcionMenu}">
    <f:selectItems value="#{VisitaDomiciliarBean.selectItemsTipoVisita}" />
    <a4j:support status="statustablaSubtipoVisita" event="onchange" action="#{VisitaDomiciliarBean.cargarTablaSubtipoVisita}" reRender="tablaSubtipoVisita">
    </a4j:support>
    </h:selectOneMenu>
    This is the datatable section:
    <t:dataTable id="tablaSubtipoVisita" styleClass="scrollerTable2" headerClass="standardTable_Header"
    footerClass="standardTable_Header" rowClasses="standardTable_Row1,standardTable_Row2"
    columnClasses="columna_centrada" value="#{VisitaDomiciliarBean.subtiposVisita}" var="subtipo"
    preserveDataModel="false" rows="10" >
    <%--columna de seleccion multiple--%>
    <t:column rendered="#{VisitaDomiciliarBean.seleccionMultiple == true}">
    <f:facet name="header">
    <h:outputText value="#{recursos['actividades.seleccionar']}" />
    </f:facet>
    <a4j:region>
    <h:selectBooleanCheckbox
    value="#{subtipo.seleccionado}" disabled="#{VisitaDomiciliarBean.modoEdicion == false}">
    <a4j:support event="onchange" status="statustablaSubtipoVisita"
    actionListener="#{VisitaDomiciliarBean.seleccionar}" reRender="ddlTipoVisita" >
    </a4j:support>
    </h:selectBooleanCheckbox>
    </a4j:region>
    </t:column>
    <t:column>
    <f:facet name="header">
    <h:outputText value="#{recursos['actividades.descripcion']}"/>
    </f:facet>
    <h:outputText value="#{subtipo.descripcion}"></h:outputText>
    </t:column>
    </t:dataTable>
    Is there any way to do this using the rendered option of the components? Or does anybody has another idea or recomendation?
    I tried to solve it using two data tables, one for the option "2" and another for all the rest of the options, I tried to hide or show the one I need acoording to the data inside the array that has the info for the datatables, but this failed, because when I change the value for the selectOneMenu from the bean, both datatables are shown and not only the one that I need.
    I would really appreciate any help with this!
    Greetings,

    Well turns out I had a some bad code in the back end that was resetting the model to the 'initial' value. I didn't require the FacesContext.getCurrentInstance().renderResponse(); after all.
    But I still find it disturbing the model generator code being called twice.
    If anyone has any suggestions on how to prevent this I'm all ears.

  • ClassCastException with ClassLoader issues

    I'm using JBoss 3.2.3, with Kodo 3.1.0
    After doing a hot deploy in JBoss, ClassCastExceptions start occuring.
    String filter = "reference==param1";
    Extent extent = pm.getExtent(Customer.class, false);
    KodoQuery query = (KodoQuery) pm.newQuery(extent, filter);
    Collection col = null;
    try {
    query.declareParameters("String param1");
    col = (Collection) query.execute("x34c");
    if (col.isEmpty())
    return null;
    Customer cust = (Customer) col.iterator().next();
    finally {
    if (query != null)
    query.close(col);
    At the line: Customer cust = (Customer) col.iterator().next();
    a ClassCastException is thrown. The class loader for Customer.class point
    to the deployed ear file, whilst the loader for
    col.iterator().next().getClass() points to null.
    Now, what is even more interesting is if I amend the above code slightly:
    Extent extent = pm.getExtent(Customer.class, false);
    KodoQuery query = (KodoQuery) pm.newQuery(extent);
    Collection col = null;
    try {
    col = (Collection) query.execute();
    if (col.isEmpty())
    return null;
    Customer cust = (Customer) col.iterator().next();
    finally {
    if (query != null)
    query.close(col);
    With the above, everything works fine. The only difference is that one
    uses a filter to retrieve a particular object from the datastore, and the
    other retrieves all objects from the datastore. I don't understand why it
    throws a ClassCastException in one instance and not the other. Note that
    this only happens after a hot deploy.
    This problem only surfaced recently after I added a few more classes to be
    persistent capable. After adding a further two classes, the
    ClassCastException moved to another class.
    Can anyone explain this?
    Cheers

    A N-
    Did you make absolutely sure that you enhanced all of the new classes
    and deployed them to correctly, and that you have clobbered any caches
    JBoss may have to any of the old .ear files?
    It might be the case that when you obtain the first in the list of all
    the Customer instances, it doesn't have a relation to one of the new
    classes, or its concrete instance is not one of the new classes, as
    opposed to when you execute the filter.
    If this doesn't help, can you provide us with some more information? At
    a minimum, a complete stack trace is usually a prerequisite for being
    able to diagnose problems like this.
    In article <[email protected]>, A N wrote:
    >
    I'm using JBoss 3.2.3, with Kodo 3.1.0
    After doing a hot deploy in JBoss, ClassCastExceptions start occuring.
    String filter = "reference==param1";
    Extent extent = pm.getExtent(Customer.class, false);
    KodoQuery query = (KodoQuery) pm.newQuery(extent, filter);
    Collection col = null;
    try {
    query.declareParameters("String param1");
    col = (Collection) query.execute("x34c");
    if (col.isEmpty())
    return null;
    Customer cust = (Customer) col.iterator().next();
    finally {
    if (query != null)
    query.close(col);
    At the line: Customer cust = (Customer) col.iterator().next();
    a ClassCastException is thrown. The class loader for Customer.class point
    to the deployed ear file, whilst the loader for
    col.iterator().next().getClass() points to null.
    Now, what is even more interesting is if I amend the above code slightly:
    Extent extent = pm.getExtent(Customer.class, false);
    KodoQuery query = (KodoQuery) pm.newQuery(extent);
    Collection col = null;
    try {
    col = (Collection) query.execute();
    if (col.isEmpty())
    return null;
    Customer cust = (Customer) col.iterator().next();
    finally {
    if (query != null)
    query.close(col);
    With the above, everything works fine. The only difference is that one
    uses a filter to retrieve a particular object from the datastore, and the
    other retrieves all objects from the datastore. I don't understand why it
    throws a ClassCastException in one instance and not the other. Note that
    this only happens after a hot deploy.
    This problem only surfaced recently after I added a few more classes to be
    persistent capable. After adding a further two classes, the
    ClassCastException moved to another class.
    Can anyone explain this?
    Cheers
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • ClassCastException with Local Interfaces

    Hi,
    My environment is
    WLS6.1SP3 (JDK131)
    DB2 7.1
    Windows 2000
    I am trying to access an entity bean through it's local interface from a stateless session bean. I can see the jndi tree contains both remote and local names. I get the correct local home object from the lookup, howevere when I cast it to LocalHome, I get ClassCastException.
    Any help would be greatly appreciated.
    Thanks.
    zahid

    Thanks for your comments. In case of clustered
    anvironment doesn't each node has it's own startup
    script which could contain these local inerfaces ?Yes, it has , but again if you deploy ear to clustered environment everything will get propagated to participating nodes.
    If you put jar with interfaces in classpath of each node you will have hard time to do hot deployment ( you can't ) and to keep things in sync.
    >
    I tried ear and it worked fine too.
    However I still got the problem as it worked on
    windows 2000 but doesn't work on aix where we want to
    deploy it.if it is same setting as win box it shouldn't have problem

  • ClassCastException with PortableRemoteObject.narrow call

    I want to call an ejb component located on a different machine and I can not get it to work. So I tried to deploy it under my version of jboss and try to invoke it. I was able to call it but when I added Context.PROVIDER_URL to my properties I get a classCastException.
    String host = "jnp://localhost:1099";
    props.setProperty(Context.PROVIDER_URL, host);
    I started getting the following exception
    2006-11-03 10:17:18,319 ERROR [STDERR] java.lang.ClassCastException
    2006-11-03 10:17:18,319 ERROR [STDERR]      at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narr
    ow(PortableRemoteObject.java:229)
    2006-11-03 10:17:18,319 ERROR [STDERR]      at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObjec
    t.java:137)
    As soon as I uncomment that props.setProperty(Context.PROVIDER_URL, host);
    line everything works fine.
    I have seen this type of exception before when I tried invoking the ejb on a different computer as well. When I inspect the object with reflection I see that it found the right interface.
    This is my code again:
    Properties props = new Properties();
    props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.security.jndi.JndiLoginInitialContextFactory");
    props.setProperty(Context.SECURITY_PRINCIPAL, "admin");
    props.setProperty(Context.SECURITY_CREDENTIALS, "admin");
    props.put(javax.naming.Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
    String host = "jnp://localhost:1099";
    props.setProperty(Context.PROVIDER_URL, host);
    ctx = new InitialContext( props );
    Object object = ctx.lookup( "ejb/com/blah/Manager" );
    ManagerRemoteHome home = (ManagerRemoteHome)PortableRemoteObject.narrow ( object, ManagerRemoteHome.class);
    ManagerRemote manager = home.create();
    Thanks

    1099 is the RMI/JRMP Registry. You are using RMI/IIOP. Is this port number really correct?

  • ClassCastException with Document

    I have an abstract class implements DOM Document.
    public abstract class XDataDoc implements Document {
    I get ClassCastException when I try to parse and XML.
    public XDataDoc xDataDoc ;
    factory = DocumentBuilderFactory.newInstance();
    parser = factory.newDocumentBuilder();
    xDataDoc = parser.parse("http://url");
    I have the same problem also with the classes implements Node or NodeList. I need this custom Document to use as a data source.
    What am I doing wrong? Is there a better way than creating a class implements Document? (Shall I create an interface extends?)
    Any help about extends / implements abstract classes and interfaces will be great useful. (I am still a newbie as you will understand)
    Thanks in advance.

    I have to prepare too many screens for data entry in a
    web application.
    I have an Oracle 8i database and servlets creating xml
    from database and receiving xml to write to database.
    Xml created with servlets have all similar schema as
    master row and detail rows as childnode of master.
    Idea is to create also custom swing objects (such as
    JTextField, JcomboBox, Jlist etc) that can work bound
    to DOM document. So creating screens will be easy as
    easy as placing swing objects on layout.
    I forget to mention also that gives the same
    exception:
    xDataDoc = (XDataDoc) parser.parse("http://url");
    Those requirements you describe have nothing to do with your problem, though, and I don't see where they require you to implement Document. In fact you can't implement Document because the parser has already done it for you. Your code needs to look like this:
    Document xDataDoc = parser.parse("http://url");

  • Problem with h:dataTable and conditional rowClasses

    Hi!
    I have a problem which I hoped somebody could have a look at. It might be that what I'm trying to do isn't possible, but I think it should have worked ;)
    To give you a quick presentation of my "case" or problem:
    - I have a dataTable which is filled with Document objects retrieved from a database.
    - The Document object has a property "created" which is a Date timestamp
    - In the dataTable I alternate the background of each row with white and blue
    - Then, what I would like to do, is to do a test on the "created" property, if the Document has been created within a fixed time, present it with a yellow line instead.
    - I set the different background-colors with three different styles, tableViewRow1 - tableViewRow2 and tableViewRow3 (the latest is the yellow line).
    To do a test on the dates I convert them into milliseconds and do a simple subtraction - if todayDate minus createdDate is smaller than criteriaDate, then the Document is considered "new" and should have a yellow background.
    This is how I've defined my dataTable:
    <h:dataTable id="documentsTableView"
    binding="#{documentModelFactory.htmlDataTable}"
    value="#{documentModelFactory.documents}"
    var="document"
    columnClasses="tableViewColumn"
    rowClasses="#{ (documentModelFactory.todayInMillisec - document.createdInMillisec) < documentModelFactory.criteriaInMillisec ? 'tableViewRow3':'tableViewRow1,tableViewRow2'}"
    styleClass="tableView"
    footerClass="tableViewFooter"
    headerClass="tableViewHeader"
    >
    So this would be the interesting lines:
    rowClasses="#{ (documentModelFactory.todayInMillisec - document.createdInMillisec)< documentModelFactory.criteriaInMillisec ? 'tableViewRow3':'tableViewRow1,tableViewRow2'}"
    I don't get an exception, and my expression seems valid. But it seems like it is always rendered to be false, I only get the white and blue rows, and I don't understand why.
    I have done different tests on the expression, and this confuses me, because it seems like the result is what it should be.
    # Test 1
    For each row I created a column printing the result of the expression, false or true.
    <h:column>
    <f:facet name="header">
    <h:outputText value="Test " />
    </f:facet>
    <h:outputText value="#{ (documentModelFactory.todayInMillisec - document.createdInMillisec)< documentModelFactory.criteriaInMillisec }" />
    </h:column>
    In all cases this is giving me the correct result, new documents get 'true' and the old ones get 'false'.
    So then I thought that there is a problem setting the tableViewRow3 param properly for the <tr class="" > :
    #Test 2
    I created a selectDocument action which basically just sets the document in my bean when a commandLink in the dataTable is fired.
    Then, in my method I retrieve the HtmlDataTable object, and do a logging of the current rowClasses for that row:
    htmlDataTable.getRowClasses() - which returns a String
    If I selected an "old" document, it returned "'tableViewRow1,tableViewRow2", but if i selected a new document, it returned 'tableViewRow3'.
    So it seems like my expression is rendered correctly, the rowClass is set properly, but still I don't get a yellow line. In the html source I have only <tr>'s with
    'tableViewRow1' and 'tableViewRow2'.
    Anybody? :)
    I don't know if it has something to do with the time / when the rowClasses param is "rendered", that it doesn't know what the "document" property is at that time??? I had the impression that the html was encoded "on the fly", and then this shouldn't be a problem? But I'm not exactly an expert so.. :)
    I guess an alternative solution is to do the testing in my bean and build up a comma-separated String to specify a rowClass for each row displayed in the dataTable, and then set the rowClasses to something like
    rowClasses="#{bean.rowStyles}"
    but first solution seems like a much easier approach (less costly as well), and it would also be interesting to know why it doesn't work.
    I'm using the 1.1.3 version of myfaces-impl, myfaces-api and tomahawk
    Thank you for your time!
    Eivind Roennevik

    I'm not sure whether i understand your problem,
    It doesnot need using the binding attribute If you wanna updating the value of each rows in the datatable.
    below is a sample that updating each rows of a datatable
    jsp file
    <h:dataTable value="#[sampleBean.data}" var="row">
        <h:column><h:inputText value="#{row.col1}"/></h:column>
    </h:dataTable>
    <h:commandButton value="update" action="#{sampleBean.update}"/>BackingBean:
    SampleBean.java
    public class Samplebean{
      private SampleRow[] rows[];
      public SampleRow[] getData{
              return rows;
      public String update(){
          for(int i=0; i<rows.length; i++){
             rows.update();
    return "success";
    SampleRow.java
    public class SampleRow{
      private String col1;
      public String getCol1(){
        return col1;
      public void setCol1(String col1){
        this.col1 = col1;
      public void update(){
         //write your code to save one row data to db/file here

Maybe you are looking for