Exception retrieving last modified date of asset after 5 minutes

62 views
Skip to first unread message

arsdeep.singh

unread,
Jul 9, 2015, 7:43:01 AM7/9/15
to hippo-c...@googlegroups.com

I am using Hippo 7.9


I am getting the las modified date of an asset.

With the Java code:

public static Date getCurrentModifiedDate(HippoAsset file) {

    try {

        if (file != null) {

            return file.getAsset().getNode().getProperty("jcr:lastModified").getDate().getTime();

        }

    } catch (RepositoryException ex) {

        Logger.getLogger(DealerHelper.class.getName()).log(Level.SEVERE, null, "RepositoryException " + ex);

    }

    return null;

}

 

Problem

The first 5 minutes time  a get a valid date, but after 5 minutes when calling the same method I get an nullpointer exception. I went to debug mode and discovered that the file.getAsset() is null.

Does anyone know how to fix this? Do I need another java code? This is weird that it is working for approx the first 5 minutes.

 

Any solutions ideas, thanks in advance for your time and effort.

 

 

Regards,

Arsdeep

arsdeep.singh

unread,
Jul 10, 2015, 4:36:59 AM7/10/15
to hippo-c...@googlegroups.com
The exception is throw at: Class HippoItem method getBean line 240 Object o = this.objectConverter.getObject(node, relPath);
Stacktrace is:
________________
Exception occurred in target VM: javax.jcr.InvalidItemStateException: Item does not exist anymore: 86015231-bc1b-48ed-82b6-94b8325069e2 
org.hippoecm.hst.content.beans.ObjectBeanManagerException: javax.jcr.InvalidItemStateException: Item does not exist anymore: 86015231-bc1b-48ed-82b6-94b8325069e2
    at org.hippoecm.hst.site.request.CachingObjectConverter$CacheKey.<init>(CachingObjectConverter.java:192)
    at org.hippoecm.hst.site.request.CachingObjectConverter$CacheKey.<init>(CachingObjectConverter.java:169)
    at org.hippoecm.hst.site.request.CachingObjectConverter.getObject(CachingObjectConverter.java:97)
    at org.hippoecm.hst.content.beans.standard.HippoItem.getBean(HippoItem.java:240)
    at org.hippoecm.hst.content.beans.standard.HippoAsset.getAsset(HippoAsset.java:24)
    at nl.atag.components.rest.helper.DealerHelper.getCurrentModifiedDate(DealerHelper.java:67)
    at nl.atag.components.rest.DealerResource.getDealers(DealerResource.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
    at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
    at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
    at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:165)
    at org.hippoecm.hst.jaxrs.cxf.AroundProcessableJAXRSInvoker.invoke(AroundProcessableJAXRSInvoker.java:94)
    at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:89)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:57)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:93)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:237)
    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:239)
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:213)
    at org.hippoecm.hst.jaxrs.cxf.CXFJaxrsService.invoke(CXFJaxrsService.java:147)
    at org.hippoecm.hst.core.container.JaxrsRestServiceValve.invoke(JaxrsRestServiceValve.java:38)
    at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:271)
    at org.hippoecm.hst.core.container.GenericResponseHeadersValve.invoke(GenericResponseHeadersValve.java:83)
    at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:271)
    at org.hippoecm.hst.core.container.SubjectBasedSessionValve.invoke(SubjectBasedSessionValve.java:58)
    at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:271)
    at org.hippoecm.hst.core.container.SecurityValve.invoke(SecurityValve.java:177)
    at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:271)
    at org.hippoecm.hst.core.container.CmsSecurityValve.invoke(CmsSecurityValve.java:80)
    at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:271)
    at org.hippoecm.hst.core.container.InitializationValve.invoke(InitializationValve.java:72)
    at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:271)
    at org.hippoecm.hst.core.container.HstSitePipeline.invokeValves(HstSitePipeline.java:170)
    at org.hippoecm.hst.core.container.HstSitePipeline.invoke(HstSitePipeline.java:153)
    at org.hippoecm.hst.core.container.HstRequestProcessorImpl.processRequest(HstRequestProcessorImpl.java:79)
    at org.hippoecm.hst.container.HstFilter.doFilter(HstFilter.java:504)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.hippoecm.hst.container.XSSUrlFilter.doFilter(XSSUrlFilter.java:49)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.onehippo.forge.rewriting.HippoRewriteFilter.doFilter(HippoRewriteFilter.java:300)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
Caused by: javax.jcr.InvalidItemStateException: Item does not exist anymore: 86015231-bc1b-48ed-82b6-94b8325069e2
    at org.apache.jackrabbit.core.ItemImpl.itemSanityCheck(ItemImpl.java:116)
    at org.apache.jackrabbit.core.ItemImpl.perform(ItemImpl.java:90)
    at org.apache.jackrabbit.core.ItemImpl.getPath(ItemImpl.java:376)
    at org.hippoecm.repository.decorating.ItemDecorator.getPath(ItemDecorator.java:89)
    at org.hippoecm.hst.site.request.CachingObjectConverter$CacheKey.<init>(CachingObjectConverter.java:190)
    ... 67 more


Any solutions?

Regards,
Arsdeep 

Op donderdag 9 juli 2015 13:43:01 UTC+2 schreef arsdeep.singh:

Jasper Floor

unread,
Jul 10, 2015, 4:41:38 AM7/10/15
to hippo-c...@googlegroups.com
Did you make any changes to the asset? Where do you get the file object?

mvg,
Jsaper

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.

arsdeep.singh

unread,
Jul 10, 2015, 4:51:32 AM7/10/15
to hippo-c...@googlegroups.com
Hi Jasper,

No i did not make any changes to the asset.

The code to get the file is:

private final   HippoBean root = RequestContextProvider.get().getSiteContentBaseBean();

private final   HippoBean assetsFolder = root.getParentBean().getParentBean().getBean("assets/mycompany/files");


private final   HippoAsset   file = assetsFolder.getBean("test.xls");

 

This code is in an util

And the method getCurrentModifiedDate is called  in a rest-call. 


Op vrijdag 10 juli 2015 10:41:38 UTC+2 schreef Jasper Floor:

Arsdeep Singh

unread,
Jul 10, 2015, 5:13:07 AM7/10/15
to hippo-c...@googlegroups.com
Hi,

It seems that the method getCurrentModifiedDate cannot be static in the rest-service class.
No it seems to be fixed, but i am not sure why. Now i have to create a new object of the Utilclass in the rest-call class this is not what i want.  If i have 1000 calls to the rest-call it would create 1000 Utilclass objects. 

Regards,
Arsdeep

Arsdeep Singh
Consultant online

e:  arsdee...@incentro.com
t:  +31204090444 
m:  +31621257791
w:  www.incentro.com

amsterdam office | mediahaven
moermanskkade 113  |  1013 bc   |  amsterdam

incentro

incentro news


You received this message because you are subscribed to a topic in the Google Groups "Hippo Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hippo-community/5OQm8zFaX3s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hippo-communi...@googlegroups.com.

marijan milicevic

unread,
Jul 10, 2015, 5:21:21 AM7/10/15
to hippo-c...@googlegroups.com
Hi,

On Fri, Jul 10, 2015 at 10:51 AM, arsdeep.singh <arsdee...@incentro.com> wrote:
Hi Jasper,

No i did not make any changes to the asset.

The code to get the file is:

private final   HippoBean root = RequestContextProvider.get().getSiteContentBaseBean();

private final   HippoBean assetsFolder = root.getParentBean().getParentBean().getBean("assets/mycompany/files");


private final   HippoAsset   file = assetsFolder.getBean("test.xls");

 


I am afraid this wont work. HST components are not thread safe, so, you are just waiting for more bad things to happen,
Also,RequestContextProvider.get() is bound to current request (threadlocal)...so, you were just lucky it worked at all...

cheers
marijan

Olivier Bourgeois

unread,
Jul 10, 2015, 5:22:57 AM7/10/15
to hippo-c...@googlegroups.com
On Fri, Jul 10, 2015 at 11:13 AM, Arsdeep Singh <arsdee...@incentro.com> wrote:
Hi,

It seems that the method getCurrentModifiedDate cannot be static in the rest-service class.
No it seems to be fixed, but i am not sure why. Now i have to create a new object of the Utilclass in the rest-call class this is not what i want.  If i have 1000 calls to the rest-call it would create 1000 Utilclass objects. 

 Sounds more like a threading issue than a problem with the static. OTH it's cleaner to create 1000 objects than use static anyway.
Reply all
Reply to author
Forward
0 new messages