AnsweredAssumed Answered

XPATH problems in queries....

Question asked by euleon on Dec 15, 2008
Hello:

I'm developing a standard API based on JAVA JCR to consume resources of Alfresco: get files. So, I need to search
through the repository. My company decided to research on XPATH. By the way, I connect to Alfresco via RMI.

My problems are that I can`t get the result/s I want when I execute the query/s. I've tried to do more that 200 querys and
I don't get success in more than 25 %.


The firsts goals I want to reach are:
1)Get all descendants of a node (without knowing where the directory is)
2)Get all descendants of a node (without knowing where the directory is) whose names have a pattern
3)Get all files of repository that have a pattern name


I've tried this queries:

Query query = queryManager.createQuery("//cm:Proyectos", Query.XPATH);
in this one I get all nodes in repository with this name –> OK, what I was waiting for

Query query = queryManager.createQuery("//cm:MCA_x0020_-_x0020_Marcos_x0020_Cerdá_x0020_Ayora/*", Query.XPATH);
In this one, I get all descendants of that node BUT also the nodes that are ancestors….  And I don't need them. Any way to solve it?

Query query = queryManager.createQuery("/cm:MCA_x0020_-_x0020_Marcos_x0020_Cerdá_x0020_Ayora//*", Query.XPATH);
This one, however, I get all nodes from the repository


Query query = queryManager.createQuery("//cm:MCA_x0020_-_x0020_Marcos_x0020_Cerdá_x0020_Ayora//*[contains(name(),'pdf')]", Query.XPATH)
This one genrates an error that throws this exception: Why??
I also get the same error using "pdf" (with scape characters…)instead of 'pdf' .


********************OUTPUT ********************
Error unmarshaling return; nested exception is:
   java.lang.ClassNotFoundException: org.alfresco.thread.DispatchException (no security manager: RMI class loader disabled)

org.apache.jackrabbit.rmi.client.RemoteRepositoryException: Error unmarshaling return; nested exception is:
   java.lang.ClassNotFoundException: org.alfresco.thread.DispatchException (no security manager: RMI class loader disabled): Error unmarshaling return; nested exception is:
   java.lang.ClassNotFoundException: org.alfresco.thread.DispatchException (no security manager: RMI class loader disabled)
   at org.apache.jackrabbit.rmi.client.ClientQuery.execute(ClientQuery.java:66)
   at xPath.main(xPath.java:119)
Caused by: java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
   java.lang.ClassNotFoundException: org.alfresco.thread.DispatchException (no security manager: RMI class loader disabled)
   at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:217)
   at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
   at org.apache.jackrabbit.rmi.server.ServerQuery_Stub.execute(Unknown Source)
   at org.apache.jackrabbit.rmi.client.ClientQuery.execute(ClientQuery.java:64)
   … 1 more
Caused by: java.lang.ClassNotFoundException: org.alfresco.thread.DispatchException (no security manager: RMI class loader disabled)
   at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:371)
   at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
   at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
   at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
   at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
   at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
   at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
   at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
   at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
   at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
   at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
   at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
   at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
   at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
   at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:215)
   … 4 more
java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
   java.lang.ClassNotFoundException: org.alfresco.thread.DispatchException (no security manager: RMI class loader disabled)
   at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:217)
   at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
   at org.apache.jackrabbit.rmi.server.ServerQuery_Stub.execute(Unknown Source)
   at org.apache.jackrabbit.rmi.client.ClientQuery.execute(ClientQuery.java:64)
   at xPath.main(xPath.java:119)
Caused by: java.lang.ClassNotFoundException: org.alfresco.thread.DispatchException (no security manager: RMI class loader disabled)
   at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:371)
   at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
   at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
   at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
   at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
   at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
   at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
   at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
   at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
   at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
   at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
   at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
   at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
   at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
   at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:215)
   … 4 more
Exception in thread "main" java.lang.NullPointerException
   at $Proxy93.isLive(Unknown Source)
   at org.apache.jackrabbit.rmi.server.ServerSession.isLive(ServerSession.java:234)
   at sun.reflect.GeneratedMethodAccessor587.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
   at sun.rmi.transport.Transport$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at sun.rmi.transport.Transport.serviceCall(Unknown Source)
   at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
   at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
   at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
   at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
   at org.apache.jackrabbit.rmi.server.ServerSession_Stub.isLive(Unknown Source)
   at org.apache.jackrabbit.rmi.client.ClientSession.isLive(ClientSession.java:465)
   at org.apache.jackrabbit.rmi.client.ClientSession.logout(ClientSession.java:313)
   at xPath.main(xPath.java:146)



*******************************

These problems are my problems (bad queries) or is there a bug on XPATH 1.0 with Alfresco?. If so, In the new version, Alfresco 3.0, I suppose it uses XPATH 2.0. Is it right?
Are there any bugs with XPATH??

I've installed the patch extension-jcr-thread-bound-1.1.jar.


Any Help would be graceful!

Thank you!

Outcomes