cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Web Services API doesn't work

bensonfungjava
Champ in-the-making
Champ in-the-making
Hi,

I am new to Alfresco Web Service API.  I recently insert almost 6 million document into Alfresco via Alfresco Web Service API.
However, it looks like cannot continue to insert more and keep throwing exception at WebServiceFactory.getRepositoryService().query(…)  and return a null value with Socket TimedOut.

However, if the Alfresco only contains few documents, the API works fine.

Please suggest what could be the problem look like.


Thanks
12 REPLIES 12

mrogers
Star Contributor
Star Contributor
More information please:

What version of alfresco are you using?
Which web services are you using?   Please post your code.
What have you done?   For example, are you trying to upload 6 million documents to a single folder and reading them all each time?
Stack trace of error please.

bensonfungjava
Champ in-the-making
Champ in-the-making
Hi,

The version is community version 3.2

First of all, I setup the Web Service EndPoint Address by :
         WebServiceFactory.setEndpointAddress("http://[IP Address]:8080/alfresco/api");

The code fragment is(forgive me I cannot disclose too many codes here) :

         Query query = new Query(
               Constants.QUERY_LANG_LUCENE,
               "PATH :\"//"+rootPath+"//*\" "
                + " AND @cm\\:name:\""+escapeStr(folderName)+"\""
               +  " AND TYPE:\"cm:folder\""
         );            
         System.out.println(query.getStatement());
         QueryResult queryResult=null;
         try{
            queryResult =  WebServiceFactory.getRepositoryService().query(STORE, query, false);

         }catch(Exception e){
            e.printStackTrace();
         }
         ResultSet resultSet = queryResult.getResultSet();   <—-  Exception is NUllPointerException here.

The entire exception is(where loadingTest2 is the space under Company Home) :
D:\LoadTest\WS Testing>java -jar test_alfresco.jar http://[IP Address]:8080/alfre

sco/api loadingTest2

Session start

PATH :"//app:company_home//*"  AND @cm\:name:"loadingTest2" AND TYPE:"cm:folder"



AxisFault

faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException

faultSubcode:

faultString: java.net.SocketTimeoutException: Read timed out

faultActor:

faultNode:

faultDetail:

        {http://xml.apache.org/axis/}stackTrace:java.net.SocketTimeoutException:

Read timed out

        at java.net.SocketInputStream.socketRead0(Native Method)

        at java.net.SocketInputStream.read(Unknown Source)

        at java.io.BufferedInputStream.fill(Unknown Source)

        at java.io.BufferedInputStream.read(Unknown Source)

        at org.apache.axis.transport.http.HTTPSender.readHeadersFromSocket(HTTPS

ender.java:583)

        at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:143)



        at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg

y.java:32)

        at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)

        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)

        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)

        at org.apache.axis.client.Call.invokeEngine(Call.java:2784)

        at org.apache.axis.client.Call.invoke(Call.java:2767)

        at org.apache.axis.client.Call.invoke(Call.java:2443)

        at org.apache.axis.client.Call.invoke(Call.java:2366)

        at org.apache.axis.client.Call.invoke(Call.java:1812)

        at org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub.q

uery(RepositoryServiceSoapBindingStub.java:753)

        at test.GetNodeUUID.getNodeUUID(GetNodeUUID.java:35)

        at test.TestAlfresco.main(TestAlfresco.java:23)



        {http://xml.apache.org/axis/}hostname:MRecordWeb



java.net.SocketTimeoutException: Read timed out

        at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)

        at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)



        at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg

y.java:32)

        at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)

        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)

        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)

        at org.apache.axis.client.Call.invokeEngine(Call.java:2784)

        at org.apache.axis.client.Call.invoke(Call.java:2767)

        at org.apache.axis.client.Call.invoke(Call.java:2443)

        at org.apache.axis.client.Call.invoke(Call.java:2366)

        at org.apache.axis.client.Call.invoke(Call.java:1812)

        at org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub.q

uery(RepositoryServiceSoapBindingStub.java:753)

        at test.GetNodeUUID.getNodeUUID(GetNodeUUID.java:35)

        at test.TestAlfresco.main(TestAlfresco.java:23)

Caused by: java.net.SocketTimeoutException: Read timed out

        at java.net.SocketInputStream.socketRead0(Native Method)

        at java.net.SocketInputStream.read(Unknown Source)

        at java.io.BufferedInputStream.fill(Unknown Source)

        at java.io.BufferedInputStream.read(Unknown Source)

        at org.apache.axis.transport.http.HTTPSender.readHeadersFromSocket(HTTPS

ender.java:583)

        at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:143)



        … 12 more

java.lang.NullPointerException

        at test.GetNodeUUID.getNodeUUID(GetNodeUUID.java:40)

        at test.TestAlfresco.main(TestAlfresco.java:23)

rootUUID=

End of session.



I created loadingTest2 manually in advance via the Web interface.  The program is to upload more than 6M documents into the space, loadingTest2.   

If you need more info, please feel free to let me know.


Thanks

bensonfungjava
Champ in-the-making
Champ in-the-making
Hi mrogers,

Do you have idea what happen to the Alfresco?

Please help


Thanks

mrogers
Star Contributor
Star Contributor
We would expect the NPE given the catch above it, you need to either remove the catch or check that you have a resultet before trying to use it.

I suspect something horrible is happening in the query and that its taking too long, possibly there are 6 million docs in a single folder or something?

I'm puzzled by the stack trace though since it is seems to be from test.GetNodeUUID.getNodeUUID(GetNodeUUID.java:35) so it does not match your description that the problem is comming from the query method.

bensonfungjava
Champ in-the-making
Champ in-the-making
So can you tell me what information you look for?

bensonfungjava
Champ in-the-making
Champ in-the-making
Hi mrogers,

Please find the entire code of GetNodeUUID below.

Please help


Thanks
Benson

[code
package test;



import org.alfresco.webservice.repository.QueryResult;

import org.alfresco.webservice.types.Query;

import org.alfresco.webservice.types.ResultSet;

import org.alfresco.webservice.types.ResultSetRow;

import org.alfresco.webservice.types.Store;

import org.alfresco.webservice.util.Constants;

import org.alfresco.webservice.util.WebServiceFactory;




public class GetNodeUUID{

   public static final Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");

   public static String getNodeUUID(String rootPath,String folderName){

      String uuid="";

            

      try {

         Query query = new Query(

               Constants.QUERY_LANG_LUCENE,

               "PATH :\"//"+rootPath+"//*\" "

                + " AND @cm\\:name:\""+escapeStr(folderName)+"\""

               +  " AND TYPE:\"cm:folder\""

         );            

         System.out.println(query.getStatement());

         QueryResult queryResult=null;



         queryResult =  WebServiceFactory.getRepositoryService().query(STORE, query, false);



         ResultSet resultSet = queryResult.getResultSet();

         ResultSetRow[] rows = resultSet.getRows();

         if(rows.length>0){

         System.out.println(" UUID ID :"+rows[0].getNode().getId());

         uuid= rows[0].getNode().getId();

         resultSet=null;

         rows=null;

         }

      } catch(Exception e) {

         e.printStackTrace();

      }



      

      return uuid;

   }

   

public static String escapeStr(String inStr){

      

      StringBuilder resultStr=new StringBuilder();

      for (int i=0;i<inStr.length();i++){

         char c=inStr.charAt(i);

         if(c=='('||c==')'){

            resultStr.append("\\");

         }

         resultStr.append©;

      }

    return resultStr.toString();

   }

}

]

bensonfungjava
Champ in-the-making
Champ in-the-making
Hi mrogers,

If the root cause is too many documents in a single folders, can you provide any alternatives how to deal with that?
Because this Alfresco will be used for healthcare industry, and it will store every patient's information.  We just created a space under Company home, underneath this space, it will be separate folder for different patient.  Does this file structure design make sense?

Please advise

Thanks

mrogers
Star Contributor
Star Contributor
I suspect that the query is doing something stupid like trying to step through all 6 million docs.   The name property has special processing, which is probably not helping in this case.

I'm not a query expert :mrgreen:

Your query will perform a lot better if you add your folder to the path rather than mixing path and property together.

e.g something like PATH://app:company_home/cmSmiley Tongueatients/cm:fred_x0020_blogs

bensonfungjava
Champ in-the-making
Champ in-the-making
Hi mrogers,

Thanks for your help.  Can I say 6M stored documents in Alfresco is the limitation?  Actually, the client is doing the loading test on the Alfresco to see how many documents Alfresco can store.  The target is 8M documents.  If the Alfresco doesn't work properly at the level of 6M storage, I afraid the client will give up Alfresco.   If 6M is not the limitation, can you give me any advise how we can continue to upload document into Alfresco on top of the 6M stored documents?

Please advise ASAP


Benson