portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Woonsan Ko (JIRA)" <jetspeed-...@portals.apache.org>
Subject [jira] [Comment Edited] (JS2-1284) ClassCastException in EhCacheDistributedElementImpl
Date Tue, 16 Jul 2013 19:54:48 GMT

    [ https://issues.apache.org/jira/browse/JS2-1284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13709939#comment-13709939
] 

Woonsan Ko edited comment on JS2-1284 at 7/16/13 7:54 PM:
----------------------------------------------------------

I don't know what is the cause, but there's a very suspicious code in EhCacheDistributedImpl.java:

- The member variable, 'refList', is supposed to keep a map keyed by EhCache key and valued
by object, the type of which is 'EhCacheDistributedElementImpl' (See EhCacheDistributedImpl#put()
method)

- However, the following code looks problematic:

	public void notifyElement( Ehcache cache, boolean local,Element arg1, int action)
	{
            // <SNIP>
		try
		{
            // <SNIP>

				if (action < 0)
					refList.remove(arg1.getKey());
				else if (action == CacheElement.ActionAdded)
					refList.put(arg1.getKey(), arg1);                          // <----- it gives Element
object instead of EhCacheDistributedElementImpl!
				e.notifyChange(action);
	            notifyListeners(local, action, arg1.getKey(), arg1.getObjectValue());
			}
			else
			{
	            notifyListeners(local, action, arg1.getKey(), null);
			}
		} catch (Exception e)
		{
			e.printStackTrace();
		}
	}


I think the 'refList.put(arg1.getKey(), arg1);' line caused the problem, which should have
put an EhCacheDistributedElementImpl instance instead of the raw ehcache Element instance.

                
      was (Author: woon_san):
    I don't know what is the cause, but there's a very suspicious code in EhCacheDistributedElementImpl.java:

- The member variable, 'refList', is supposed to keep a map keyed by EhCache key and valued
by object, the type of which is 'EhCacheDistributedElementImpl' (See EhCacheDistributedElementImpl#put()
method)

- However, the following code looks problematic:

	public void notifyElement( Ehcache cache, boolean local,Element arg1, int action)
	{
            // <SNIP>
		try
		{
            // <SNIP>

				if (action < 0)
					refList.remove(arg1.getKey());
				else if (action == CacheElement.ActionAdded)
					refList.put(arg1.getKey(), arg1);                          // <----- it gives Element
object instead of EhCacheDistributedElementImpl!
				e.notifyChange(action);
	            notifyListeners(local, action, arg1.getKey(), arg1.getObjectValue());
			}
			else
			{
	            notifyListeners(local, action, arg1.getKey(), null);
			}
		} catch (Exception e)
		{
			e.printStackTrace();
		}
	}


I think the 'refList.put(arg1.getKey(), arg1);' line caused the problem, which should have
put an EhCacheDistributedElementImpl instanced instead of the raw ehcache Element instance.

                  
> ClassCastException in EhCacheDistributedElementImpl
> ---------------------------------------------------
>
>                 Key: JS2-1284
>                 URL: https://issues.apache.org/jira/browse/JS2-1284
>             Project: Jetspeed 2
>          Issue Type: Bug
>            Reporter: Woonsan Ko
>
> While testing, I noticed the following error log in the console:
> --------------------------------------------------------------------------------
> java.lang.ClassCastException: net.sf.ehcache.Element cannot be cast to org.apache.jetspeed.cache.impl.EhCacheDistributedElementImpl
> 	at org.apache.jetspeed.cache.impl.EhCacheDistributedImpl.notifyElement(EhCacheDistributedImpl.java:241)
> 	at org.apache.jetspeed.cache.impl.EhCacheDistributedImpl.notifyElementPut(EhCacheDistributedImpl.java:275)
> 	at net.sf.ehcache.event.RegisteredEventListeners.notifyElementPut(RegisteredEventListeners.java:95)
> 	at net.sf.ehcache.Cache.put(Cache.java:866)
> 	at net.sf.ehcache.Cache.put(Cache.java:796)
> 	at org.apache.jetspeed.cache.impl.EhCacheDistributedImpl.put(EhCacheDistributedImpl.java:88)
> 	at org.apache.jetspeed.components.portletpreferences.PortletPreferencesServiceImpl.retrieveDefaultPreferences(PortletPreferencesServiceImpl.java:682)
> 	at org.apache.jetspeed.components.portletpreferences.PortletPreferencesServiceImpl.getDefaultPreferences(PortletPreferencesServiceImpl.java:135)
> 	at sun.reflect.GeneratedMethodAccessor122.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
> 	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
> 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
> 	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
> 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
> 	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
> 	at com.sun.proxy.$Proxy5.getDefaultPreferences(Unknown Source)
> 	at org.apache.pluto.container.impl.PortletPreferencesImpl.<init>(PortletPreferencesImpl.java:103)
> 	at org.apache.pluto.container.impl.PortletRequestImpl.getPreferences(PortletRequestImpl.java:459)
> 	at com.onehippo.jetspeed.portlets.FileContentPortlet.doView(FileContentPortlet.java:32)
> 	at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:348)
> 	at javax.portlet.GenericPortlet.render(GenericPortlet.java:253)
> 	at org.apache.jetspeed.portlet.PortletObjectProxy.proxyRender(PortletObjectProxy.java:280)
> 	at org.apache.jetspeed.portlet.PortletObjectProxy.invoke(PortletObjectProxy.java:172)
> 	at com.sun.proxy.$Proxy64.render(Unknown Source)
> 	at org.apache.jetspeed.factory.JetspeedPortletInstance.render(JetspeedPortletInstance.java:117)
> 	at org.apache.jetspeed.container.services.JetspeedFilterChain.doFilter(JetspeedFilterChain.java:142)
> 	at org.apache.jetspeed.container.services.JetspeedFilterChain.processFilter(JetspeedFilterChain.java:92)
> 	at org.apache.jetspeed.container.services.JetspeedFilterManager.processFilter(JetspeedFilterManager.java:112)
> 	at org.apache.jetspeed.container.JetspeedContainerServlet.doGet(JetspeedContainerServlet.java:290)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> 	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
> 	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:605)
> 	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:544)
> 	at org.apache.jetspeed.container.invoker.ServletPortletInvoker.invoke(ServletPortletInvoker.java:165)
> 	at org.apache.jetspeed.container.invoker.JetspeedPortletInvokerService.render(JetspeedPortletInvokerService.java:127)
> 	at org.apache.pluto.container.impl.PortletContainerImpl.doRender(PortletContainerImpl.java:157)
> 	at org.apache.jetspeed.container.JetspeedPortletContainerWrapper.doRender(JetspeedPortletContainerWrapper.java:69)
> 	at org.apache.jetspeed.aggregator.impl.RenderingJobImpl.executeInternal(RenderingJobImpl.java:245)
> 	at org.apache.jetspeed.aggregator.impl.RenderingJobImpl.access$000(RenderingJobImpl.java:57)
> 	at org.apache.jetspeed.aggregator.impl.RenderingJobImpl$1.run(RenderingJobImpl.java:206)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at javax.security.auth.Subject.doAsPrivileged(Subject.java:454)
> 	at org.apache.jetspeed.security.JSSubject.doAsPrivileged(JSSubject.java:187)
> 	at org.apache.jetspeed.aggregator.impl.RenderingJobImpl.execute(RenderingJobImpl.java:200)
> 	at org.apache.jetspeed.util.ServletRequestCleanupService.executeNestedRenderJob(ServletRequestCleanupService.java:79)
> 	at org.apache.jetspeed.aggregator.impl.RenderingJobImpl.run(RenderingJobImpl.java:154)
> 	at org.apache.jetspeed.aggregator.impl.WorkerImpl.run(WorkerImpl.java:173)
> --------------------------------------------------------------------------------

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message