[MGNLRES-142] Using the InstallTextResourcesTask(String pattern, String template) constructor results in InvalidItemStateException Created: 28/Apr/15 Updated: 29/Mar/22 Resolved: 17/Mar/16 |
|
| Status: | Closed |
| Project: | Magnolia Resources Module |
| Component/s: | None |
| Affects Version/s: | 2.3.7, 2.4.4 |
| Fix Version/s: | 2.3.8, 2.4.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Nils Breunese | Assignee: | Ilgun Ilgun |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | support | ||
| Remaining Estimate: | 0d | ||
| Time Spent: | 3d 1.5h | ||
| Original Estimate: | 3h | ||
| Issue Links: |
|
||||||||||||
| Template: |
|
||||||||||||
| Acceptance criteria: |
Empty
|
||||||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||||||||||
| Date of First Response: | |||||||||||||
| Sprint: | Basel 35 | ||||||||||||
| Story Points: | 2 | ||||||||||||
| Team: | |||||||||||||
| Description |
|
We have a version handler that tries to install some CSS text resources like this: setInstallOrUpdateTask(new InstallTextResourcesTask("/vpro/module/vprotemplatingkit/.*\\.css", ResourceTypes.CSS)); However, running this version handler results in the following error: 2015-04-28 17:00:36,177 ERROR info.magnolia.module.InstallContextImpl : > Could not install or update vpro-templating-kit module. Task 'Install text resources' failed. (InvalidItemStateException: Item does not exist anymore: 77c448aa-6817-453b-8afe-b48af1647ca7/{}modelClass) info.magnolia.module.delta.TaskExecutionException: Can't install resource [/vpro/module/vprotemplatingkit/css/reset.css] at info.magnolia.module.resources.setup.InstallTextResourceTask.execute(InstallTextResourceTask.java:116) at info.magnolia.module.resources.setup.InstallTextResourcesTask.doExecute(InstallTextResourcesTask.java:109) at info.magnolia.module.delta.AbstractRepositoryTask.execute(AbstractRepositoryTask.java:57) at info.magnolia.module.ModuleManagerImpl.applyDeltas(ModuleManagerImpl.java:514) at info.magnolia.module.ModuleManagerImpl.installOrUpdateModule(ModuleManagerImpl.java:496) at info.magnolia.module.ModuleManagerImpl$1.doExec(ModuleManagerImpl.java:274) at info.magnolia.context.MgnlContext$VoidOp.exec(MgnlContext.java:414) at info.magnolia.context.MgnlContext$VoidOp.exec(MgnlContext.java:411) at info.magnolia.context.MgnlContext.doInSystemContext(MgnlContext.java:385) at info.magnolia.module.ModuleManagerImpl.performInstallOrUpdate(ModuleManagerImpl.java:268) at info.magnolia.module.ui.ModuleManagerNullUI.onStartup(ModuleManagerNullUI.java:66) at info.magnolia.cms.beans.config.ConfigLoader.load(ConfigLoader.java:149) at info.magnolia.init.MagnoliaServletContextListener$1.doExec(MagnoliaServletContextListener.java:248) at info.magnolia.context.MgnlContext$VoidOp.exec(MgnlContext.java:414) at info.magnolia.context.MgnlContext$VoidOp.exec(MgnlContext.java:411) at info.magnolia.context.MgnlContext.doInSystemContext(MgnlContext.java:385) at info.magnolia.init.MagnoliaServletContextListener.startServer(MagnoliaServletContextListener.java:245) at info.magnolia.init.MagnoliaServletContextListener.contextInitialized(MagnoliaServletContextListener.java:171) at info.magnolia.init.MagnoliaServletContextListener.contextInitialized(MagnoliaServletContextListener.java:125) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632) at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1740) 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.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:618) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565) 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.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466) at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307) at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399) at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:828) 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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323) at sun.rmi.transport.Transport$1.run(Transport.java:200) at sun.rmi.transport.Transport$1.run(Transport.java:197) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:196) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$254(TCPTransport.java:683) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$1/1630123354.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: javax.jcr.InvalidItemStateException: Item does not exist anymore: 77c448aa-6817-453b-8afe-b48af1647ca7/{}modelClass at org.apache.jackrabbit.core.ItemImpl.itemSanityCheck(ItemImpl.java:116) at org.apache.jackrabbit.core.ItemImpl.sanityCheck(ItemImpl.java:104) at org.apache.jackrabbit.core.PropertyImpl.getName(PropertyImpl.java:892) at info.magnolia.jcr.wrapper.DelegatePropertyWrapper.getName(DelegatePropertyWrapper.java:241) at info.magnolia.jcr.wrapper.DelegatePropertyWrapper.getName(DelegatePropertyWrapper.java:241) at info.magnolia.jcr.wrapper.MgnlPropertySettingContentDecorator$LastUpdatePropertyWrapper.updateLastModifiedProperty(MgnlPropertySettingContentDecorator.java:393) at info.magnolia.jcr.wrapper.MgnlPropertySettingContentDecorator$LastUpdatePropertyWrapper.setValue(MgnlPropertySettingContentDecorator.java:360) at info.magnolia.jcr.wrapper.DelegatePropertyWrapper.setValue(DelegatePropertyWrapper.java:101) at info.magnolia.audit.MgnlAuditLoggingContentDecoratorPropertyWrapper.setValue(MgnlAuditLoggingContentDecoratorPropertyWrapper.java:79) at info.magnolia.module.resources.setup.AbstractInstallResourceTask.setProperty(AbstractInstallResourceTask.java:134) at info.magnolia.module.resources.setup.InstallTextResourceTask.execute(InstallTextResourceTask.java:105) ... 64 more |
| Comments |
| Comment by Nils Breunese [ 28/Apr/15 ] |
|
The problem seems to be that the InstallTextResourcesTask(String pattern, String template) constructor results in using the constructor with more arguments where modelClass is set to null (and processed is set to true, even though the template denotes a non-processed resource type in this case!). InstallTextResourcesTask#doExecute(ctx) constructs an InstallTextResourceTask for every resource where it passes null for the modelClass argument and then in InstallTextResourceTask#execute(installContext) this results in this.setProperty("modelClass", modelClass) getting called with modelClass set to null. Apparently this results in an attempt to remove the modelClass property from the node, but since there is no modelClass property on the node, we get the InvalidItemStateException. This seems like unexpected behavior to me. Question 1: should we use a constructor that explicitly specifies STKResourceModel.class.getName() as the modelClass, or should we be in theory be OK using the InstallTextResourcesTask(String pattern, String template) constructor for our use case. |
| Comment by Nils Breunese [ 28/Apr/15 ] |
|
As a workaround we're now using this longer form constructor: setInstallOrUpdateTask(new InstallTextResourcesTask("/vpro/module/vprotemplatingkit/.*\\.css", ResourceTypes.CSS, false, STKResourceModel.class.getName(), false)); |
| Comment by Trang Truong [ 28/May/15 ] |
|
@Zdenek: Could you give more info if this issue can reproduce from your side? I have created some unit tests to install css resources using InstallTextResourcesTask(String pattern, String template) then it works well from my side. |
| Comment by Michiel Meeuwissen [ 05/Jan/16 ] |
|
Where is a resource supposed to exist? If we have a javascript 'impl.js' on the class-path. Should there be a node 'impl' or should it be 'impl.js'? Adding to the confusing is the fact that info.magnolia.module.resources.setup.InstallTextResourcesTask#InstallTextResourcesTask(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, java.lang.String, boolean) has an optional parameter 'stripExtension', which default is 'true'. |
| Comment by Michiel Meeuwissen [ 06/Jan/16 ] |
|
And to elaborate a bit further. After activation of one hotfix, nearly all our sites got broken, because for some reason I don't quite understand yet that introduces something that made all processed resources broken and result in a 404. It may have been caused by our version handler, or whatever, but the whole system seems to me horribly fragile. |
| Comment by Zdenek Skodik [ 27/Jan/16 ] |
|
We've got another occurrence of the issue, this time related to version parameter. It turned out the issue is not reproducable with Derby, or once your webapp is started up, but for instance a Postgres 9 based repository suffers from it. |
| Comment by Zdenek Skodik [ 04/Feb/16 ] |
|
Still trying to come up with a clean reproduction path. |
| Comment by Zdenek Skodik [ 04/Mar/16 ] |
|
IIRC it's been ilgun who pinged me on this issue, how about if you tried:
? |