-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: java.util.ArrayList cannot be cast to java.util.Set
PostPosted: Mon Sep 10, 2007 7:37 pm 
Beginner
Beginner

Joined: Thu Aug 17, 2006 12:44 pm
Posts: 22
Location: Ohio
This has to be the strangest bug I've ever seen. I have taken over this project from another developer who was not using Hibernate. The misspellings are not mine. ;)

I am going thru and adding Hibernate 3.1 with MyEclipse to this project. All was going fine until I needed a one to many relationship. ServiceCatagories (sp) have many Services.

As you can see in the mapping file I added a <set ...> with a <one-to-many> entry. My site actually works for the first few clicks. Its after the 3rd or 4th click after Services is click that I get the mess below.

Now the strange part is that the error is coming from LinksDAO which does not have a Set in it's mapping anywhere! Only the ServiceCatagory mapping has a set that contains all of the related Services. I have even changed the return type for getCatagories(parent) from Object[] to List, etc and that change is reflected in the error from LinksDAO which is called from an <@include...> but should not be related to this issue.

I am just beside myself on this one.

Please help

Mike.



Hibernate version:3.1 Core and Advanced - MyEclipse

Mapping documents:

Code:
<hibernate-mapping>
    <class name="com.kayenta.hibernate.links.Links" table="links">
        <id name="linkId" type="java.lang.Integer">
            <column name="link_id" />
            <generator class="increment"></generator>
        </id>
        <property name="pneumonic" type="java.lang.String">
            <column name="pneumonic" length="30" />
        </property>
        <property name="url" type="java.lang.String">
            <column name="url" length="50" />
        </property>
        <property name="enLink" type="java.lang.String">
            <column name="en_link" length="50" />
        </property>
        <property name="esLink" type="java.lang.String">
            <column name="es_link" length="50" />
        </property>
        <property name="frLink" type="java.lang.String">
            <column name="fr_link" length="50" />
        </property>
    </class>
</hibernate-mapping>

<hibernate-mapping>
    <class name="com.kayenta.hibernate.servicecategories.ServiceCatagories" table="service_catagories">
        <id name="serviceCatagoryId" type="java.lang.Integer">
            <column name="service_catagory_id" />
            <generator class="increment" />
        </id>
        <property name="enServiceCatagory" type="java.lang.String">
            <column name="en_service_catagory" length="50" />
        </property>
        <property name="enDescription" type="java.lang.String">
            <column name="en_description" length="16277215" />
        </property>
        <property name="esServiceCatagory" type="java.lang.String">
            <column name="es_service_catagory" length="50" />
        </property>
        <property name="esDescription" type="java.lang.String">
            <column name="es_description" length="16277215" />
        </property>
         
        <set name="services" table="services">
           <key column="service_catagory_id"/>
           <one-to-many class="com.kayenta.hibernate.services.Services"/>
        </set>

    </class>
</hibernate-mapping>

<hibernate-mapping>
    <class name="com.kayenta.hibernate.services.Services" table="services">
        <id name="serviceId" type="java.lang.Integer">
            <column name="service_id" />
            <generator class="increment" />
        </id>
        <property name="serviceCatagoryId" type="java.lang.Integer">
            <column name="service_catagory_id" not-null="true" />
        </property>
        <property name="enService" type="java.lang.String">
            <column name="en_service" length="50" />
        </property>
        <property name="enDescription" type="java.lang.String">
            <column name="en_description" length="16277215" />
        </property>
        <property name="esService" type="java.lang.String">
            <column name="es_service" length="50" />
        </property>
        <property name="esDescription" type="java.lang.String">
            <column name="es_description" length="16277215" />
        </property>
    </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
Sep 10, 2007 7:23:33 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0\bin;C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin
Sep 10, 2007 7:23:33 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Sep 10, 2007 7:23:33 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 592 ms
Sep 10, 2007 7:23:33 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Sep 10, 2007 7:23:33 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.14
Sep 10, 2007 7:23:35 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Sun's JavaServer Faces implementation (1.2_04-b07-FCS) for context '/kayenta-icefaces'
Sep 10, 2007 7:23:37 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Sep 10, 2007 7:23:37 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Sep 10, 2007 7:23:37 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/36 config=null
Sep 10, 2007 7:23:37 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4255 ms
19:24:07,468 WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%206.0/webapps/kayenta-icefaces/WEB-INF/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
Sep 10, 2007 7:24:21 PM org.apache.catalina.core.ApplicationContext log
INFO: null
19:25:03,784 ERROR LinksDAO:119 - find all failed
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Set
at org.hibernate.type.SetType.wrap(SetType.java:39)
at org.hibernate.event.def.WrapVisitor.processArrayOrNewCollection(WrapVisitor.java:84)
at org.hibernate.event.def.WrapVisitor.processCollection(WrapVisitor.java:51)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101)
at org.hibernate.event.def.WrapVisitor.processValue(WrapVisitor.java:98)
at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55)
at org.hibernate.event.def.DefaultFlushEntityEventListener.wrapCollections(DefaultFlushEntityEventListener.java:178)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:111)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:954)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1099)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.kayenta.hibernate.links.LinksDAO.findAll(LinksDAO.java:117)
at wellnessnetwork.website.backing.links.getHyperLinks(links.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at org.apache.el.parser.AstValue.getValue(AstValue.java:97)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at javax.faces.component.UIData.getValue(UIData.java:582)
at javax.faces.component.UIData.getDataModel(UIData.java:1063)
at javax.faces.component.UIData.setRowIndex(UIData.java:417)
at com.icesoft.faces.renderkit.dom_html_basic.TableRenderer.renderFacet(TableRenderer.java:133)
at com.icesoft.faces.renderkit.dom_html_basic.TableRenderer.encodeBegin(TableRenderer.java:102)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:785)
at javax.faces.component.UIData.encodeBegin(UIData.java:879)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:558)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:535)
at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:153)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
at com.icesoft.faces.webapp.http.core.PageServer$1.respond(PageServer.java:26)
at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:143)
at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet$ThreadBlockingRequestResponse.respondWith(ThreadBlockingAdaptingServlet.java:36)
at com.icesoft.faces.webapp.http.core.PageServer.service(PageServer.java:31)
at com.icesoft.faces.webapp.http.core.SingleViewServer.service(SingleViewServer.java:46)
at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer$Matcher.serviceOnMatch(PathDispatcherServer.java:50)
at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:19)
at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:29)
at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:109)
at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:35)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Sep 10, 2007 7:25:03 PM com.sun.faces.lifecycle.LifecycleImpl phase
WARNING: executePhase(RENDER_RESPONSE 6,com.icesoft.faces.context.BridgeFacesContext@4173b9) threw exception
javax.faces.FacesException: javax.el.ELException: Error reading 'hyperLinks' on type wellnessnetwork.website.backing.links
at javax.faces.component.UIData.getValue(UIData.java:585)
at javax.faces.component.UIData.getDataModel(UIData.java:1063)
at javax.faces.component.UIData.setRowIndex(UIData.java:417)
at com.icesoft.faces.renderkit.dom_html_basic.TableRenderer.renderFacet(TableRenderer.java:133)
at com.icesoft.faces.renderkit.dom_html_basic.TableRenderer.encodeBegin(TableRenderer.java:102)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:785)
at javax.faces.component.UIData.encodeBegin(UIData.java:879)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:558)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:535)
at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:153)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
at com.icesoft.faces.webapp.http.core.PageServer$1.respond(PageServer.java:26)
at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:143)
at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet$ThreadBlockingRequestResponse.respondWith(ThreadBlockingAdaptingServlet.java:36)
at com.icesoft.faces.webapp.http.core.PageServer.service(PageServer.java:31)
at com.icesoft.faces.webapp.http.core.SingleViewServer.service(SingleViewServer.java:46)
at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer$Matcher.serviceOnMatch(PathDispatcherServer.java:50)
at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:19)
at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:29)
at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:109)
at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:35)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.el.ELException: Error reading 'hyperLinks' on type wellnessnetwork.website.backing.links
at javax.el.BeanELResolver.getValue(BeanELResolver.java:66)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at org.apache.el.parser.AstValue.getValue(AstValue.java:97)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at javax.faces.component.UIData.getValue(UIData.java:582)
... 49 more
Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Set
at org.hibernate.type.SetType.wrap(SetType.java:39)
at org.hibernate.event.def.WrapVisitor.processArrayOrNewCollection(WrapVisitor.java:84)
at org.hibernate.event.def.WrapVisitor.processCollection(WrapVisitor.java:51)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101)
at org.hibernate.event.def.WrapVisitor.processValue(WrapVisitor.java:98)
at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55)
at org.hibernate.event.def.DefaultFlushEntityEventListener.wrapCollections(DefaultFlushEntityEventListener.java:178)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:111)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:954)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1099)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.kayenta.hibernate.links.LinksDAO.findAll(LinksDAO.java:117)
at wellnessnetwork.website.backing.links.getHyperLinks(links.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
... 54 more
Sep 10, 2007 7:25:03 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Persistent Faces Servlet threw exception
javax.faces.FacesException: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Set
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:310)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
at com.icesoft.faces.webapp.http.core.PageServer$1.respond(PageServer.java:26)
at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:143)
at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet$ThreadBlockingRequestResponse.respondWith(ThreadBlockingAdaptingServlet.java:36)
at com.icesoft.faces.webapp.http.core.PageServer.service(PageServer.java:31)
at com.icesoft.faces.webapp.http.core.SingleViewServer.service(SingleViewServer.java:46)
at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer$Matcher.serviceOnMatch(PathDispatcherServer.java:50)
at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:19)
at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:29)
at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:109)
at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:35)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Set
at org.hibernate.type.SetType.wrap(SetType.java:39)
at org.hibernate.event.def.WrapVisitor.processArrayOrNewCollection(WrapVisitor.java:84)
at org.hibernate.event.def.WrapVisitor.processCollection(WrapVisitor.java:51)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101)
at org.hibernate.event.def.WrapVisitor.processValue(WrapVisitor.java:98)
at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55)
at org.hibernate.event.def.DefaultFlushEntityEventListener.wrapCollections(DefaultFlushEntityEventListener.java:178)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:111)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:954)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1099)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.kayenta.hibernate.links.LinksDAO.findAll(LinksDAO.java:117)
at wellnessnetwork.website.backing.links.getHyperLinks(links.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at org.apache.el.parser.AstValue.getValue(AstValue.java:97)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at javax.faces.component.UIData.getValue(UIData.java:582)
at javax.faces.component.UIData.getDataModel(UIData.java:1063)
at javax.faces.component.UIData.setRowIndex(UIData.java:417)
at com.icesoft.faces.renderkit.dom_html_basic.TableRenderer.renderFacet(TableRenderer.java:133)
at com.icesoft.faces.renderkit.dom_html_basic.TableRenderer.encodeBegin(TableRenderer.java:102)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:785)
at javax.faces.component.UIData.encodeBegin(UIData.java:879)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:558)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:565)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:535)
at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:153)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
... 28 more

Name and version of the database you are using: MySQL 5.0

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 11, 2007 12:49 am 
Newbie

Joined: Wed Sep 05, 2007 6:34 pm
Posts: 13
Is ServiceCategories.services a List or a Set? Could that be the problem? (i.e. using <list> instead of <set>)

http://www.hibernate.org/hib_docs/v3/re ... ns-mapping


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 11, 2007 1:09 am 
Beginner
Beginner

Joined: Thu Aug 17, 2006 12:44 pm
Posts: 22
Location: Ohio
I would have preferred to use <list> because I am using Faces with this project. I wasn't sure which field to use as an index so i with with <Set> and do some conversions from the getter property.

In the getter I do something like:

Code:
List services = new ArrayList();
services.addAll(this.services);   // Defined as private Set services;

return services;


I am assuming there is nothing wrong with my setter, which is called my Hibernate, takes a Set as a parameter, but I return an ArrayList from the getter for Faces.

Thanx.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 11, 2007 1:22 am 
Newbie

Joined: Wed Sep 05, 2007 6:34 pm
Posts: 13
Hmm.. considering that the error is "java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Set", I think it casts suspicion on the discrepancy between the used ArrayList and the defined Set.

I'm not clear about how Hibernate does this, but is it not possible that Hibernate calls getServices() expecting a Set, and freaks out when it's a list? (ArrayList does not implement the Set interface). http://java.sun.com/j2se/1.5.0/docs/api ... yList.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 11, 2007 1:45 am 
Newbie

Joined: Wed Sep 05, 2007 6:34 pm
Posts: 13
I just read into your reply again and understood more...

I had more hackish ideas, but then I read "If your table doesn't have an index column, and you still wish to use List as the property type, you should map the property as a Hibernate <bag>. A bag does not retain its order when it is retrieved from the database, but it may be optionally sorted or ordered."


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 11, 2007 2:08 am 
Beginner
Beginner

Joined: Thu Aug 17, 2006 12:44 pm
Posts: 22
Location: Ohio
I just got up outta bed with the exact same thought. I was laying there going over and over in my mind what I had replied to you.

THAT WAS IT!! I added another property that gives me what I need as a list and all is good.

What is still very strange is the LinksDAO that was reporting the error which does not access the Services or Service Categories at all. Very odd.

Thanx for the effort!

Mike.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.