Project

General

Profile

Actions

bug #5556

closed

Class Cast Exception in DefinedTermDaoImpl.getPartOf

Added by Andreas Müller over 8 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Priority14
Category:
cdmlib
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
Severity:
normal
Found in Version:
Tags:

Description

The following CCE appeared when calling DescriptionPortalController.doGetDistributionInfo.

Class casting is not correct in getPartOf (and maybe similar methods !!) as it takes the class of the first term and applies it to all other terms.

Caused by:

java.lang.ClassCastException: Cannot cast eu.etaxonomy.cdm.model.location.NamedArea to eu.etaxonomy.cdm.model.location.Country
    at java.lang.Class.cast(Class.java:3176)
    at eu.etaxonomy.cdm.hibernate.HibernateProxyHelper.deproxy(HibernateProxyHelper.java:34)
    at eu.etaxonomy.cdm.model.common.CdmBase.deproxy(CdmBase.java:312)
    at eu.etaxonomy.cdm.persistence.dao.hibernate.common.DefinedTermDaoImpl.getPartOf(DefinedTermDaoImpl.java:626)
    at eu.etaxonomy.cdm.api.service.DistributionTree.loadAllParentAreas(DistributionTree.java:126)
    at eu.etaxonomy.cdm.api.service.DistributionTree.orderAsTree(DistributionTree.java:97)
    at eu.etaxonomy.cdm.api.utility.DescriptionUtility.orderDistributions(DescriptionUtility.java:261)
    at eu.etaxonomy.cdm.ext.geo.EditGeoService.composeDistributionInfoFor(EditGeoService.java:385)
    at sun.reflect.GeneratedMethodAccessor1729.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)

Related issues

Related to EDIT - feature request #6794: Improve term structureIn ProgressAndreas Müller

Actions
Related to EDIT - bug #10277: HibernateSystemException and BridgeException not in taxeditor dependenciesClosedAndreas Müller

Actions
Actions #1

Updated by Andreas Müller over 8 years ago

Full stacktrace in CDM Server was:

Caused by:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.ClassCastException: Cannot cast eu.etaxonomy.cdm.model.location.NamedArea to eu.etaxonomy.cdm.model.location.Country
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:948)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:91)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle(Server.java:497)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: Cannot cast eu.etaxonomy.cdm.model.location.NamedArea to eu.etaxonomy.cdm.model.location.Country
    at java.lang.Class.cast(Class.java:3176)
    at eu.etaxonomy.cdm.hibernate.HibernateProxyHelper.deproxy(HibernateProxyHelper.java:34)
    at eu.etaxonomy.cdm.model.common.CdmBase.deproxy(CdmBase.java:312)
    at eu.etaxonomy.cdm.persistence.dao.hibernate.common.DefinedTermDaoImpl.getPartOf(DefinedTermDaoImpl.java:626)
    at eu.etaxonomy.cdm.api.service.DistributionTree.loadAllParentAreas(DistributionTree.java:126)
    at eu.etaxonomy.cdm.api.service.DistributionTree.orderAsTree(DistributionTree.java:97)
    at eu.etaxonomy.cdm.api.utility.DescriptionUtility.orderDistributions(DescriptionUtility.java:261)
    at eu.etaxonomy.cdm.ext.geo.EditGeoService.composeDistributionInfoFor(EditGeoService.java:385)
    at sun.reflect.GeneratedMethodAccessor1729.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at com.sun.proxy.$Proxy2458.composeDistributionInfoFor(Unknown Source)
    at eu.etaxonomy.cdm.remote.controller.DescriptionPortalController.doGetDistributionInfo(DescriptionPortalController.java:258)
    at sun.reflect.GeneratedMethodAccessor1728.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
    ... 56 more

Caused by:

java.lang.ClassCastException: Cannot cast eu.etaxonomy.cdm.model.location.NamedArea to eu.etaxonomy.cdm.model.location.Country
    at java.lang.Class.cast(Class.java:3176)
    at eu.etaxonomy.cdm.hibernate.HibernateProxyHelper.deproxy(HibernateProxyHelper.java:34)
    at eu.etaxonomy.cdm.model.common.CdmBase.deproxy(CdmBase.java:312)
    at eu.etaxonomy.cdm.persistence.dao.hibernate.common.DefinedTermDaoImpl.getPartOf(DefinedTermDaoImpl.java:626)
    at eu.etaxonomy.cdm.api.service.DistributionTree.loadAllParentAreas(DistributionTree.java:126)
    at eu.etaxonomy.cdm.api.service.DistributionTree.orderAsTree(DistributionTree.java:97)
    at eu.etaxonomy.cdm.api.utility.DescriptionUtility.orderDistributions(DescriptionUtility.java:261)
    at eu.etaxonomy.cdm.ext.geo.EditGeoService.composeDistributionInfoFor(EditGeoService.java:385)
    at sun.reflect.GeneratedMethodAccessor1729.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
Actions #2

Updated by Andreas Müller over 8 years ago

  • Keywords set to mexico_ws,
Actions #3

Updated by Andreas Müller over 8 years ago

I tried to find relevant data by

select dtb2.*
from DefinedTermBase dtb
INNER JOIN DefinedTermBase dtb2 ON dtb2.id = dtb.partof_id where dtb.partof_id is not null AND dtb.DTYPE <> dtb2.DTYPE;

WS1 cyryophyllales_test but couldn't find any.

Actions #4

Updated by Andreas Müller over 8 years ago

  • Priority changed from New to Priority14
Actions #5

Updated by Andreas Müller over 8 years ago

  • Status changed from New to Resolved

should be fixed with r27262.

Can be tested with Lymanbensonia on WS1, Caryophyllales_test, if data wasn't change there in the meanwhile.

Fix went into develop, not hotfix for now.

Actions #6

Updated by Andreas Müller over 8 years ago

  • Target version changed from Unassigned CDM tickets to Release 4.0
Actions #7

Updated by Andreas Müller over 1 year ago

  • Description updated (diff)
  • Status changed from Resolved to In Progress
  • Target version changed from Release 4.0 to Release 5.36

Got a very similar problem again:

last remote service : http://132.248.13.83:8080/cdmserver/cdm_flora_mexico/remoting/term.service
last remote method : getDbSchemaVersion
last remote request client time : 2023-03-22T09:13:19.099
last remote request response header time : Wed, 22 Mar 2023 08:12:35 GMT
client error time : 2023-03-22T09:13:19.768
login : admin
editor version : 5.35.0
server : 132.248.13.83 (Mexico) / cdm_flora_mexico
schema version : 5.35.1.0.20221218
os : Windows Server 2012 R2 6.3 amd64
java : 1.8.0_131
org.eclipse.e4.core.di.InjectionException: java.lang.ClassCastException: Cannot cast eu.etaxonomy.cdm.model.location.NamedArea to eu.etaxonomy.cdm.model.location.Country
            at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:65)
            ...
            at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
Caused by: java.lang.ClassCastException: Cannot cast eu.etaxonomy.cdm.model.location.NamedArea to eu.etaxonomy.cdm.model.location.Country
            at java.lang.Class.cast(Class.java:3369)
            at eu.etaxonomy.cdm.hibernate.HibernateProxyHelper.deproxy(HibernateProxyHelper.java:55)
            at eu.etaxonomy.cdm.model.common.CdmBase.deproxy(CdmBase.java:339)
            at eu.etaxonomy.cdm.model.term.DefinedTermBase.getPartOf(DefinedTermBase.java:291)
            at eu.etaxonomy.cdm.model.location.NamedArea.getPartOf(NamedArea.java:281)
            at eu.etaxonomy.cdm.model.location.NamedArea.getPartOf(NamedArea.java:1)
            at eu.etaxonomy.cdm.persistence.dto.TermDto.fromTerm(TermDto.java:79)
            at eu.etaxonomy.cdm.persistence.dto.TermDto.fromTerm(TermDto.java:64)
            at eu.etaxonomy.taxeditor.termtree.e4.handler.AbstractAddTermHandler.execute(AbstractAddTermHandler.java:86)
            at eu.etaxonomy.taxeditor.termtree.e4.handler.AddTermHandler.execute(AddTermHandler.java:38)
            ... 36 more

So the problem can't be fixed yet.

Actions #8

Updated by Andreas Müller over 1 year ago

  • Private changed from Yes to No
Actions #9

Updated by Andreas Müller over 1 year ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 70
Actions #10

Updated by Andreas Müller over 1 year ago

  • Tags changed from mexico_ws to mexico, terms
  • Assignee changed from Andreas Müller to Katja Luther

I guess this should be fixed now. Can you please review?

Actions #11

Updated by Andreas Müller over 1 year ago

Actions #12

Updated by Andreas Müller over 1 year ago

  • Related to bug #10277: HibernateSystemException and BridgeException not in taxeditor dependencies added
Actions #13

Updated by Andreas Müller over 1 year ago

  • Status changed from Resolved to Closed
  • Assignee changed from Katja Luther to Andreas Müller
  • % Done changed from 70 to 100

reviewed by reviewing #10277

Actions

Also available in: Atom PDF