[jira] [Commented] (OAK-4911) Can not read node Property when move code into a Thread (Java)
[ https://issues.apache.org/jira/browse/OAK-4911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15611200#comment-15611200 ] amin zamani commented on OAK-4911: -- Dear Support, is there any new news knowledge about the error(s) / why it does not work? Thanks and best regards, Amin > Can not read node Property when move code into a Thread (Java) > -- > > Key: OAK-4911 > URL: https://issues.apache.org/jira/browse/OAK-4911 > Project: Jackrabbit Oak > Issue Type: Bug >Affects Versions: 1.3.10 > Environment: MAC OS X >Reporter: amin zamani > Attachments: JCROakTest.java, java-code.txt, mixin-definitions.cnd > > > Hallo, > we develop an application and everything is working as it should. We upload > documents and for each document a new preview file (node) should be > generated. It works well when we execute the code synchron. But because of > the fact that the generation of a preview file (like PDF format) can take > very long time we decided to move the preview generation code into a usual > java thread so that after the user is upload a document the website is > responding very quick and does not wait till the preview file is generated > but the preview file is generated parallel. > No the problem: As soon as I move the same code regarding to the preview file > generation into a usual thread (no modifications to the logic, only a thread > is bordered to it) suddenly the node path does not exist, this is the error: > - > Caused by: javax.jcr.PathNotFoundException: jcr:lastModifiedBy not found on > /jcr:system/jcr:versionStorage/7e/f8/5b/7ef85b25-4598-4476-82df-446eb3a08a90/1.0/jcr:frozenNode/jcr:content > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:631) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:625) > at > org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:207) > at > org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl.getProperty(NodeImpl.java:625) > at > com.westernacher.noah.util.content_repository.JcrUtil.getStringProperty(JcrUtil.java:35) > --- > In my point of view this is a bug. This is the code that works: > Example: > /// 1) User Upload document through browser in our web app.. > // 2) ... document uploaded and saved in OAK CR > // 3) Now generate the preview: > updateDocumentPreview(documentId); > > Now the same in a thread that does not work: > => I have only moved the method "updateDocumentPreview(documentId);" in a > Thread (Java 8): > //Same code as before except the last line replaced by following lines: > Runnable run = ()-> {updateDocumentPreview(documentId);} > new Thread(run).start(); //Start the thread to generate a document preview > -- -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (OAK-4911) Can not read node Property when move code into a Thread (Java)
[ https://issues.apache.org/jira/browse/OAK-4911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15588775#comment-15588775 ] amin zamani commented on OAK-4911: -- Hi Marcel, thank you very much for investigating with me your time in this issue -> thanks for your help! I have attached attached the java Class "JCROakTest.java" to this ticket. There are maybe only 3 Things you may modify at the beginning of the class: private static Mongo mongo = new MongoClient("localhost"); private static String databaseName = "jcr-dev"; private String mixinDefs = "/mixin-definitions.cnd"; Inside the main start method (public static void main) you see that I create a document with no thread - that works. And then afterward I create a document inside a thread. The same code but only inside a thread. But unfortunately now I have the problem that the document creation inside the thread shows to me the error: => Exception in thread "Thread-1" java.lang.RuntimeException: javax.jcr.RepositoryException: This session has been closed. I use the same logic, exactly the same code inside our web application, the same kind of session but I don't know why we get in our webapp this error: Caused by: javax.jcr.PathNotFoundException: noah:createdBy not found on /jcr:system/jcr:versionStorage/d2/88/43/d28843a2-c666-4936-b08b-e53912da4ecf/1.0/jcr:frozenNode However, I think when we are able to fix the first problem (session closed) then the second error will appear. Thank you very much for your appreciated help! Shalom Amin > Can not read node Property when move code into a Thread (Java) > -- > > Key: OAK-4911 > URL: https://issues.apache.org/jira/browse/OAK-4911 > Project: Jackrabbit Oak > Issue Type: Bug >Affects Versions: 1.3.10 > Environment: MAC OS X >Reporter: amin zamani > Attachments: java-code.txt > > > Hallo, > we develop an application and everything is working as it should. We upload > documents and for each document a new preview file (node) should be > generated. It works well when we execute the code synchron. But because of > the fact that the generation of a preview file (like PDF format) can take > very long time we decided to move the preview generation code into a usual > java thread so that after the user is upload a document the website is > responding very quick and does not wait till the preview file is generated > but the preview file is generated parallel. > No the problem: As soon as I move the same code regarding to the preview file > generation into a usual thread (no modifications to the logic, only a thread > is bordered to it) suddenly the node path does not exist, this is the error: > - > Caused by: javax.jcr.PathNotFoundException: jcr:lastModifiedBy not found on > /jcr:system/jcr:versionStorage/7e/f8/5b/7ef85b25-4598-4476-82df-446eb3a08a90/1.0/jcr:frozenNode/jcr:content > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:631) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:625) > at > org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:207) > at > org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl.getProperty(NodeImpl.java:625) > at > com.westernacher.noah.util.content_repository.JcrUtil.getStringProperty(JcrUtil.java:35) > --- > In my point of view this is a bug. This is the code that works: > Example: > /// 1) User Upload document through browser in our web app.. > // 2) ... document uploaded and saved in OAK CR > // 3) Now generate the preview: > updateDocumentPreview(documentId); > > Now the same in a thread that does not work: > => I have only moved the method "updateDocumentPreview(documentId);" in a > Thread (Java 8): > //Same code as before except the last line replaced by following lines: > Runnable run = ()-> {updateDocumentPreview(documentId);} > new Thread(run).start(); //Start the thread to generate a document preview > -- -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (OAK-4911) Can not read node Property when move code into a Thread (Java)
[ https://issues.apache.org/jira/browse/OAK-4911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15584825#comment-15584825 ] Marcel Reutegger commented on OAK-4911: --- Please provide a self contained test that reproduces the behaviour you describe. The code you posted is not enough because it does not cover the threading aspect. Thanks. > Can not read node Property when move code into a Thread (Java) > -- > > Key: OAK-4911 > URL: https://issues.apache.org/jira/browse/OAK-4911 > Project: Jackrabbit Oak > Issue Type: Bug >Affects Versions: 1.3.10 > Environment: MAC OS X >Reporter: amin zamani > Attachments: java-code.txt > > > Hallo, > we develop an application and everything is working as it should. We upload > documents and for each document a new preview file (node) should be > generated. It works well when we execute the code synchron. But because of > the fact that the generation of a preview file (like PDF format) can take > very long time we decided to move the preview generation code into a usual > java thread so that after the user is upload a document the website is > responding very quick and does not wait till the preview file is generated > but the preview file is generated parallel. > No the problem: As soon as I move the same code regarding to the preview file > generation into a usual thread (no modifications to the logic, only a thread > is bordered to it) suddenly the node path does not exist, this is the error: > - > Caused by: javax.jcr.PathNotFoundException: jcr:lastModifiedBy not found on > /jcr:system/jcr:versionStorage/7e/f8/5b/7ef85b25-4598-4476-82df-446eb3a08a90/1.0/jcr:frozenNode/jcr:content > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:631) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:625) > at > org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:207) > at > org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl.getProperty(NodeImpl.java:625) > at > com.westernacher.noah.util.content_repository.JcrUtil.getStringProperty(JcrUtil.java:35) > --- > In my point of view this is a bug. This is the code that works: > Example: > /// 1) User Upload document through browser in our web app.. > // 2) ... document uploaded and saved in OAK CR > // 3) Now generate the preview: > updateDocumentPreview(documentId); > > Now the same in a thread that does not work: > => I have only moved the method "updateDocumentPreview(documentId);" in a > Thread (Java 8): > //Same code as before except the last line replaced by following lines: > Runnable run = ()-> {updateDocumentPreview(documentId);} > new Thread(run).start(); //Start the thread to generate a document preview > -- -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (OAK-4911) Can not read node Property when move code into a Thread (Java)
[ https://issues.apache.org/jira/browse/OAK-4911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15569516#comment-15569516 ] amin zamani commented on OAK-4911: -- And then we get this error if above method is called : Caused by: javax.jcr.PathNotFoundException: noah:createdBy not found on /jcr:system/jcr:versionStorage/d2/88/43/d28843a2-c666-4936-b08b-e53912da4ecf/1.0/jcr:frozenNode > Can not read node Property when move code into a Thread (Java) > -- > > Key: OAK-4911 > URL: https://issues.apache.org/jira/browse/OAK-4911 > Project: Jackrabbit Oak > Issue Type: Bug >Affects Versions: 1.3.10 > Environment: MAC OS X >Reporter: amin zamani > Attachments: java-code.txt > > > Hallo, > we develop an application and everything is working as it should. We upload > documents and for each document a new preview file (node) should be > generated. It works well when we execute the code synchron. But because of > the fact that the generation of a preview file (like PDF format) can take > very long time we decided to move the preview generation code into a usual > java thread so that after the user is upload a document the website is > responding very quick and does not wait till the preview file is generated > but the preview file is generated parallel. > No the problem: As soon as I move the same code regarding to the preview file > generation into a usual thread (no modifications to the logic, only a thread > is bordered to it) suddenly the node path does not exist, this is the error: > - > Caused by: javax.jcr.PathNotFoundException: jcr:lastModifiedBy not found on > /jcr:system/jcr:versionStorage/7e/f8/5b/7ef85b25-4598-4476-82df-446eb3a08a90/1.0/jcr:frozenNode/jcr:content > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:631) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:625) > at > org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:207) > at > org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl.getProperty(NodeImpl.java:625) > at > com.westernacher.noah.util.content_repository.JcrUtil.getStringProperty(JcrUtil.java:35) > --- > In my point of view this is a bug. This is the code that works: > Example: > /// 1) User Upload document through browser in our web app.. > // 2) ... document uploaded and saved in OAK CR > // 3) Now generate the preview: > updateDocumentPreview(documentId); > > Now the same in a thread that does not work: > => I have only moved the method "updateDocumentPreview(documentId);" in a > Thread (Java 8): > //Same code as before except the last line replaced by following lines: > Runnable run = ()-> {updateDocumentPreview(documentId);} > new Thread(run).start(); //Start the thread to generate a document preview > -- -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (OAK-4911) Can not read node Property when move code into a Thread (Java)
[ https://issues.apache.org/jira/browse/OAK-4911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15569513#comment-15569513 ] amin zamani commented on OAK-4911: -- and then the last method which is called inside of createDocument(..) is toDocument(versionNode) => In this method the exception is thrown: private Document toDocument(Node documentNode) { try { Node file = null; String identifier = null; // flag to show if current node is already versioned boolean isVersioned = true; if( documentNode instanceof Version ){ //Versioned node file = documentNode.getNode(Node.JCR_FROZEN_NODE); identifier = JcrUtil.getStringProperty(file, Property.JCR_FROZEN_UUID); }else{ //unversioned node file = documentNode; isVersioned = false; identifier = documentNode.getIdentifier(); } Node fileContent = file.getNode(Property.JCR_CONTENT); String versionName = documentNode.getName(); ZonedDateTime creationDate = DateUtil.toZonedDateTime(file.getProperty(Property.JCR_CREATED).getDate()); ZonedDateTime lastModificationDate = DateUtil.toZonedDateTime(JcrUtils.getLastModified(fileContent)); String createdBy = JcrUtil.getStringProperty(file, CustomProperty.NOAH_CREATED_BY); String lastModifiedBy = JcrUtil.getStringProperty(fileContent, Property.JCR_LAST_MODIFIED_BY); String title = JcrUtils.getStringProperty(file, Property.JCR_TITLE, null); String description = JcrUtils.getStringProperty(file, Property.JCR_DESCRIPTION, null); String entityUrl = JcrUtil.getStringProperty(file, CustomProperty.NOAH_ENTITY_URL); String documentTypeValue = JcrUtils.getStringProperty(file, CustomProperty.NOAH_DOCUMENT_TYPE_VALUE, null); String documentTypeLabel = JcrUtils.getStringProperty(file, CustomProperty.NOAH_DOCUMENT_TYPE_LABEL, null); ValueListEntry documentType = isNoneEmpty(documentTypeValue, documentTypeLabel) ? new ValueListEntry(documentTypeValue, documentTypeLabel) : null; String contentType = JcrUtil.getStringProperty(fileContent, Property.JCR_MIMETYPE); long fileSize = fileContent.getProperty(Property.JCR_DATA).getLength(); String previewType = JcrUtils.getStringProperty(file, CustomProperty.NOAH_PREVIEW_TYPE, null); return new Document(identifier,previewType, versionName, creationDate, lastModificationDate, createdBy, lastModifiedBy, title, description, entityUrl, documentType, contentType, fileSize); } catch (RepositoryException e) { throw new RuntimeRepositoryException(e); } } > Can not read node Property when move code into a Thread (Java) > -- > > Key: OAK-4911 > URL: https://issues.apache.org/jira/browse/OAK-4911 > Project: Jackrabbit Oak > Issue Type: Bug >Affects Versions: 1.3.10 > Environment: MAC OS X >Reporter: amin zamani > Attachments: java-code.txt > > > Hallo, > we develop an application and everything is working as it should. We upload > documents and for each document a new preview file (node) should be > generated. It works well when we execute the code synchron. But because of > the fact that the generation of a preview file (like PDF format) can take > very long time we decided to move the preview generation code into a usual > java thread so that after the user is upload a document the website is > responding very quick and does not wait till the preview file is generated > but the preview file is generated parallel. > No the problem: As soon as I move the same code regarding to the preview file > generation into a usual thread (no modifications to the logic, only a thread > is bordered to it) suddenly the node path does not exist, this is the error: > - > Caused by: javax.jcr.PathNotFoundException: jcr:lastModifiedBy not found on > /jcr:system/jcr:versionStorage/7e/f8/5b/7ef85b25-4598-4476-82df-446eb3a08a90/1.0/jcr:frozenNode/jcr:content > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:631) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:625) > at > org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:207) > at > org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl.getProperty(NodeImpl.java:625) > at > com.westernacher.noah.util.content_repository.JcrUtil.getStringProperty(JcrUtil.java:35) > --- > In my point of view this is a bug. This is the
[jira] [Commented] (OAK-4911) Can not read node Property when move code into a Thread (Java)
[ https://issues.apache.org/jira/browse/OAK-4911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15569505#comment-15569505 ] amin zamani commented on OAK-4911: -- Inside above createDocument at the end the document which was created is versioned, the above called "versionFile" method for versioning the document has this implementation: private Version versionFile(Node file, Binary fileContent) { try { VersionManager versionManager = file.getSession().getWorkspace().getVersionManager(); versionManager.checkout(file.getPath()); file.getNode(Property.JCR_CONTENT).setProperty(Property.JCR_LAST_MODIFIED, Calendar.getInstance()); file.getNode(Property.JCR_CONTENT).setProperty(Property.JCR_LAST_MODIFIED_BY, SecurityUtil.getCurrentUserLogin()); file.getNode(Property.JCR_CONTENT).setProperty(Property.JCR_DATA, fileContent); jcrSession.save(); Version version = versionManager.checkin(file.getPath()); versionManager.getVersionHistory(file.getPath()).addVersionLabel(version.getName(), NOAH_LAST_VERSION_LABEL, DO_MOVE_LABEL); return version; } catch (RepositoryException e) { throw new RuntimeRepositoryException(e); } } > Can not read node Property when move code into a Thread (Java) > -- > > Key: OAK-4911 > URL: https://issues.apache.org/jira/browse/OAK-4911 > Project: Jackrabbit Oak > Issue Type: Bug >Affects Versions: 1.3.10 > Environment: MAC OS X >Reporter: amin zamani > Attachments: java-code.txt > > > Hallo, > we develop an application and everything is working as it should. We upload > documents and for each document a new preview file (node) should be > generated. It works well when we execute the code synchron. But because of > the fact that the generation of a preview file (like PDF format) can take > very long time we decided to move the preview generation code into a usual > java thread so that after the user is upload a document the website is > responding very quick and does not wait till the preview file is generated > but the preview file is generated parallel. > No the problem: As soon as I move the same code regarding to the preview file > generation into a usual thread (no modifications to the logic, only a thread > is bordered to it) suddenly the node path does not exist, this is the error: > - > Caused by: javax.jcr.PathNotFoundException: jcr:lastModifiedBy not found on > /jcr:system/jcr:versionStorage/7e/f8/5b/7ef85b25-4598-4476-82df-446eb3a08a90/1.0/jcr:frozenNode/jcr:content > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:631) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:625) > at > org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:207) > at > org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl.getProperty(NodeImpl.java:625) > at > com.westernacher.noah.util.content_repository.JcrUtil.getStringProperty(JcrUtil.java:35) > --- > In my point of view this is a bug. This is the code that works: > Example: > /// 1) User Upload document through browser in our web app.. > // 2) ... document uploaded and saved in OAK CR > // 3) Now generate the preview: > updateDocumentPreview(documentId); > > Now the same in a thread that does not work: > => I have only moved the method "updateDocumentPreview(documentId);" in a > Thread (Java 8): > //Same code as before except the last line replaced by following lines: > Runnable run = ()-> {updateDocumentPreview(documentId);} > new Thread(run).start(); //Start the thread to generate a document preview > -- -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (OAK-4911) Can not read node Property when move code into a Thread (Java)
[ https://issues.apache.org/jira/browse/OAK-4911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15569500#comment-15569500 ] amin zamani commented on OAK-4911: -- I have now modified the structure of the code: Now in a thread a new file node is created but when I try to access the property I still get the same error. I access in the same java thread where I have created the file the properties of the node that I just have created before. Here a little exampe: new thread created with following content, it calls only the createDocument(...) method and then I get the exception - without a thread i don't have the exception: public Document createDocument(String folderId, CreateDocumentDto createDto) { try { Node node = jcrSession.getNodeByIdentifier(folderId); Binary binary = jcrSession.getValueFactory().createBinary(createDto.getContent()); try { Node file = JcrUtils.getOrCreateByPath( node, "", DO_CREATE_UNIQUE_LEAF, NodeType.NT_FOLDER, NodeType.NT_FILE, DO_AUTO_SAVE); file.addMixin(NodeType.MIX_VERSIONABLE); file.addMixin(NodeType.MIX_TITLE); file.setProperty(Property.JCR_TITLE, createDto.getTitle()); file.setProperty(Property.JCR_DESCRIPTION, createDto.getDescription()); file.addMixin(CustomNodeType.NOAH_ENTITY_DOCUMENT); if (createDto.getDocumentType() != null) { file.setProperty(CustomProperty.NOAH_DOCUMENT_TYPE_VALUE, createDto.getDocumentType().getValue()); file.setProperty(CustomProperty.NOAH_DOCUMENT_TYPE_LABEL, createDto.getDocumentType().getLabel()); } file.setProperty(CustomProperty.NOAH_ENTITY_URL, createDto.getEntityUrl()); file.addMixin(CustomNodeType.NOAH_AUDITABLE); file.setProperty(CustomProperty.NOAH_CREATED_BY, SecurityUtil.getCurrentUserLogin()); Node content = JcrUtils.getOrAddNode(file, Node.JCR_CONTENT, NodeType.NT_RESOURCE); content.setProperty(Property.JCR_DATA, binary); content.setProperty(Property.JCR_MIMETYPE, createDto.getContentType()); String previewFileType=""; if(createDto.getPreviewType() != null){ // Ok, we are creating a preview document, so add the preview type file.addMixin(CustomNodeType.NOAH_PREVIEW_DOCUMENT); System.out.println("Create preview document, set preview type:"+createDto.getPreviewType().name()); file.setProperty(CustomProperty.NOAH_PREVIEW_TYPE, createDto.getPreviewType().name()); previewFileType = createDto.getPreviewType().name(); } jcrSession.refresh(true); jcrSession.save(); jcrSession.refresh(true); System.out.println("Created "+previewFileType+" document,id: "+file.getIdentifier()+" ("+createDto.getTitle()+"),path: "+file.getPath()); LOG.debug("Created "+previewFileType+" document,id: "+file.getIdentifier()+" ("+createDto.getTitle()+"),path: "+file.getPath()); Version versionNode = versionFile(file, binary); jcrSession.refresh(true); return toDocument(versionNode); } finally { binary.dispose(); } } catch (RepositoryException e) { throw new RuntimeRepositoryException(e); } } > Can not read node Property when move code into a Thread (Java) > -- > > Key: OAK-4911 > URL: https://issues.apache.org/jira/browse/OAK-4911 > Project: Jackrabbit Oak > Issue Type: Bug >Affects Versions: 1.3.10 > Environment: MAC OS X >Reporter: amin zamani > Attachments: java-code.txt > > > Hallo, > we develop an application and everything is working as it should. We upload > documents and for each document a new preview file (node) should be > generated. It works well when we execute the code synchron. But because of > the fact that the generation of a preview file (like PDF format) can take > very long time we decided to move the preview generation code into a usual > java thread so that after the user is upload a document the website is > responding very quick and does not wait till the preview file is generated > but the preview file is generated parallel. > No the problem: As soon as I move the same code regarding to the preview file > generation into a usual thread (no modifications to the
[jira] [Commented] (OAK-4911) Can not read node Property when move code into a Thread (Java)
[ https://issues.apache.org/jira/browse/OAK-4911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15569437#comment-15569437 ] amin zamani commented on OAK-4911: -- I have added in each thread before it access the node this statement: jcrSession.refresh(true); But same error still exists -;( > Can not read node Property when move code into a Thread (Java) > -- > > Key: OAK-4911 > URL: https://issues.apache.org/jira/browse/OAK-4911 > Project: Jackrabbit Oak > Issue Type: Bug >Affects Versions: 1.3.10 > Environment: MAC OS X >Reporter: amin zamani > Attachments: java-code.txt > > > Hallo, > we develop an application and everything is working as it should. We upload > documents and for each document a new preview file (node) should be > generated. It works well when we execute the code synchron. But because of > the fact that the generation of a preview file (like PDF format) can take > very long time we decided to move the preview generation code into a usual > java thread so that after the user is upload a document the website is > responding very quick and does not wait till the preview file is generated > but the preview file is generated parallel. > No the problem: As soon as I move the same code regarding to the preview file > generation into a usual thread (no modifications to the logic, only a thread > is bordered to it) suddenly the node path does not exist, this is the error: > - > Caused by: javax.jcr.PathNotFoundException: jcr:lastModifiedBy not found on > /jcr:system/jcr:versionStorage/7e/f8/5b/7ef85b25-4598-4476-82df-446eb3a08a90/1.0/jcr:frozenNode/jcr:content > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:631) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:625) > at > org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:207) > at > org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl.getProperty(NodeImpl.java:625) > at > com.westernacher.noah.util.content_repository.JcrUtil.getStringProperty(JcrUtil.java:35) > --- > In my point of view this is a bug. This is the code that works: > Example: > /// 1) User Upload document through browser in our web app.. > // 2) ... document uploaded and saved in OAK CR > // 3) Now generate the preview: > updateDocumentPreview(documentId); > > Now the same in a thread that does not work: > => I have only moved the method "updateDocumentPreview(documentId);" in a > Thread (Java 8): > //Same code as before except the last line replaced by following lines: > Runnable run = ()-> {updateDocumentPreview(documentId);} > new Thread(run).start(); //Start the thread to generate a document preview > -- -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (OAK-4911) Can not read node Property when move code into a Thread (Java)
[ https://issues.apache.org/jira/browse/OAK-4911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15568404#comment-15568404 ] Chetan Mehrotra commented on OAK-4911: -- I believe what you are observing is write skew [1]. Which session does the preview generation thread uses? Is it created after the file is saved or its a long living session? If later then you need to do explicit refresh [1] https://jackrabbit.apache.org/oak/docs/differences.html#Session_state_and_refresh_behaviour > Can not read node Property when move code into a Thread (Java) > -- > > Key: OAK-4911 > URL: https://issues.apache.org/jira/browse/OAK-4911 > Project: Jackrabbit Oak > Issue Type: Bug >Affects Versions: 1.3.10 > Environment: MAC OS X >Reporter: amin zamani > Attachments: java-code.txt > > > Hallo, > we develop an application and everything is working as it should. We upload > documents and for each document a new preview file (node) should be > generated. It works well when we execute the code synchron. But because of > the fact that the generation of a preview file (like PDF format) can take > very long time we decided to move the preview generation code into a usual > java thread so that after the user is upload a document the website is > responding very quick and does not wait till the preview file is generated > but the preview file is generated parallel. > No the problem: As soon as I move the same code regarding to the preview file > generation into a usual thread (no modifications to the logic, only a thread > is bordered to it) suddenly the node path does not exist, this is the error: > - > Caused by: javax.jcr.PathNotFoundException: jcr:lastModifiedBy not found on > /jcr:system/jcr:versionStorage/7e/f8/5b/7ef85b25-4598-4476-82df-446eb3a08a90/1.0/jcr:frozenNode/jcr:content > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:631) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl$11.perform(NodeImpl.java:625) > at > org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:207) > at > org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112) > at > org.apache.jackrabbit.oak.jcr.session.NodeImpl.getProperty(NodeImpl.java:625) > at > com.westernacher.noah.util.content_repository.JcrUtil.getStringProperty(JcrUtil.java:35) > --- > In my point of view this is a bug. This is the code that works: > Example: > /// 1) User Upload document through browser in our web app.. > // 2) ... document uploaded and saved in OAK CR > // 3) Now generate the preview: > updateDocumentPreview(documentId); > > Now the same in a thread that does not work: > => I have only moved the method "updateDocumentPreview(documentId);" in a > Thread (Java 8): > //Same code as before except the last line replaced by following lines: > Runnable run = ()-> {updateDocumentPreview(documentId);} > new Thread(run).start(); //Start the thread to generate a document preview > -- -- This message was sent by Atlassian JIRA (v6.3.4#6332)