Hi,
I've made a java application who saves its data to a CMS (jackrabbit) using the JSR-170 standard. Now I want to replace this CMS with Alfresco. I thought since I always used methods from the JSR-170 standard that this wouldn't give much problems. I'm receiving an error when adding a simple node to an already existing node. Below is my code followed by the error I receive:
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/jcr-context.xml");
Repository repository = (Repository)context.getBean("JCR.Repository");
session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()), null);
try{
rn = session.getRootNode();
Node testNode = rn.addNode("Test");
testNode.addNode("Affiliations"); // this is the line where I get the error
session.save();
Workspace ws = session.getWorkspace();
System.out.println(ws.getName());
session.save();
boolean test = rn.hasNode("Test");
System.out.println(test);
}catch (Exception e){
e.printStackTrace();
}
Here is the stacktrace printout:
javax.jcr.RepositoryException: Cannot determine node type for child within parent workspace://SpacesStore/e8bd735a-bd89-11da-b562-17a0deba8955: Cannot determine node type for child within parent workspace://SpacesStore/e8bd735a-bd89-11da-b562-17a0deba8955
at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:167)
at $Proxy67.addNode(Unknown Source)
at Remote_Test.main(Remote_Test.java:59)
Caused by: org.alfresco.error.AlfrescoRuntimeException: Cannot determine node type for child within parent workspace://SpacesStore/e8bd735a-bd89-11da-b562-17a0deba8955
at org.alfresco.jcr.item.NodeImpl.getDefaultChildAssocDefForParent(NodeImpl.java:209)
at org.alfresco.jcr.item.NodeImpl.addNode(NodeImpl.java:177)
at org.alfresco.jcr.item.NodeImpl.addNode(NodeImpl.java:133)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:130)
… 2 more
org.alfresco.error.AlfrescoRuntimeException: Cannot determine node type for child within parent workspace://SpacesStore/e8bd735a-bd89-11da-b562-17a0deba8955
at org.alfresco.jcr.item.NodeImpl.getDefaultChildAssocDefForParent(NodeImpl.java:209)
at org.alfresco.jcr.item.NodeImpl.addNode(NodeImpl.java:177)
at org.alfresco.jcr.item.NodeImpl.addNode(NodeImpl.java:133)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:130)
at $Proxy67.addNode(Unknown Source)
at Remote_Test.main(Remote_Test.java:59)
Can anyone tell me what I'm doing wrong here?
Thanks!
Steven