11-28-2005 08:49 PM
02-07-2006 11:28 PM
Hi, Russ,
I'm trying to get RMI access as well. I was trying to get to your download (http://www.posit-group.org/cache/jcr-rmi-alfresco.zip) but the link's broken, any chance you could make it available somewhere else?
Cheers,
Fraser
03-09-2006 09:16 PM
Download the following
http://devartisan.org/jcr-rmi-alfresco.zip
this is the things you need to change in alfresco to expose the JCR. …
03-26-2006 04:43 PM
03-27-2006 12:12 AM
Hi,
I'm a student in the computerscience and I'm using Alfresco for my thesis. I would like to access the JCR through a java application. So far I haven't been able to retrieve a Session object with the code from the example of the tutorial. I would like to try this with your rmi library, but I don't know what exactly where I should put the files from the jcr-rmi-alfresco.zip file. Do I have to rebuild the Alfresco.war again with your files added, or can I just add them when I already deployed Alfresco. I use Tomcat 5.5.12.
Can you help me out?
Thanks
Steven
03-27-2006 02:41 AM
03-28-2006 10:03 AM
Hi,
Thank you for your time and help. You probably have better things to do than helping a student with his problems, so I really appreciate your help. I'll hope to hear from you soon.
Thanks in advance!
Steven
03-28-2006 03:13 PM
03-28-2006 04:07 PM
Hi Russ,
I originally wanted to access Alfresco through JCR (with the example code from the tutorial), but I had some difficulties and I decided to take a different road. Then I found your post from the RMI library and I thought this might work with me to. Maybe I should give you some background on my project. I made a java application on top of jackrabbit using the JSR-170 standard. The only thing that I use the content management system for is to persist my data. Now I would like to put another content management system (Alfresco) under my application. If my application keeps working without changing any of my code, that would be a nice conclusion for my thesis and would also defend the use of the JSR-170 standard. So I would like to get JCRobjects the easiest way possible.
I'll tell you how I currently access Alfresco and which errors I get, and maybe you can help me out then. This is the code of a simple testprogram I made to check my JCR connection with Alfresco:
System.setProperty("java.rmi.server.useCodebaseOnly", "true");
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/jcr-context.xml");
Repository repository = (Repository)context.getBean("JCR.Repository");
Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()), null);
try{
rn = session.getRootNode();
Node testNode = rn.addNode("Test2");
testNode.addNode("Test4");
session.save();
}catch (Exception e){
e.printStackTrace();
}
This is the error I receive:
javax.jcr.RepositoryException: Cannot determine node type for child within parent workspace://SpacesStore/b06a1ec1-be95-11da-b3fa-dbcbf8133280: Cannot determine node type for child within parent workspace://SpacesStore/b06a1ec1-be95-11da-b3fa-dbcbf8133280
at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:167)
at $Proxy67.addNode(Unknown Source)
at Remote_Test.main(Remote_Test.java:58)
Caused by: org.alfresco.error.AlfrescoRuntimeException: Cannot determine node type for child within parent workspace://SpacesStore/b06a1ec1-be95-11da-b3fa-dbcbf8133280
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/b06a1ec1-be95-11da-b3fa-dbcbf8133280
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:58)
I don't understand, since the code I run works fine in Jackrabbit. Do you know what the problem might be?
Further I'm working with Eclipse as editor, and I get these strange errors only when I run my program in debug mode.
JDI thread evaluations (Error: Exception processing async thread queue)
I don't know if this is a problem with eclipse or with the connection to Alfresco, but I just mention it (maybe you also know the cause of these errors). When I just run my program (no debug mode) I don't get these erros.
Can you help me?
Thanks!
Steven
03-28-2006 04:30 PM
03-28-2006 05:20 PM
Hi Russ,
Thanks for the quick reply… I made a mistake in the previous reply. The code to get a session object indeed differs from the jackrabbit implementation, but what I actually meaned was once I received a session object I run the same code. I mean that when I do testNode.addNode("Test4") it works fine in Jackrabbit but not in Alfresco. I see in your example code that you also give a nodeType as a second argument in this method. Well in all my code I just give the name as argument and that works in jackrabbit and apparentlt not in Alfresco. I read in the JSR-170 spec that the inheritance of nodeTypes to childnodes is implementation specific, so my guess is that jackrabbit automatically gives a nodeType on creation of a node and with Alfresco you have to specify it in the second argument. I also tested the setProperty("Test","TestValue") method which also gives an error. It seems that Alfresco implements the JSR-170 standard differently than Jackrabbit.
I'm kind of a newbie in the whole Alfresco repository environment so I don't really know what you mean with a different data model and bootstrap. Can you explain this to me? In jackrabbit you can just start adding nodes under the rootNode and that what I'm doing in my application, so I can't really change my code since I want it to be backwards compatible with the jackrabbit JCR interface. I already have a data structure that works in jackrabbit and I would like to use exactly the same datastructure in Alfresco.
Thanks for all your effort,
Steven
/**
* Get the default child association definition for the specified node
*
* @param nodeService node service
* @param dictionaryService dictionary service
* @param nodeRef node reference
* @return child association definition
*/
private ChildAssociationDefinition getDefaultChildAssocDefForParent(NodeService nodeService, DictionaryService dictionaryService, NodeRef nodeRef)
{
QName type = nodeService.getType(nodeRef);
Set<QName> aspects = nodeService.getAspects(nodeRef);
ClassDefinition classDef = dictionaryService.getAnonymousType(type, aspects);
Map<QName, ChildAssociationDefinition> childAssocs = classDef.getChildAssociations();
if (childAssocs.size() != 1)
{
throw new AlfrescoRuntimeException("Cannot determine node type for child within parent " + nodeRef);
}
ChildAssociationDefinition childAssocDef = childAssocs.values().iterator().next();
return childAssocDef;
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.