cancel
Showing results for 
Search instead for 
Did you mean: 

Use of Repository service APIs

abhicog123
Champ in-the-making
Champ in-the-making
Hello,

I was planning to do simple application that will have my own UI page. At the backend servlet I want to use the Alfresco repository content management API. I was researching and found that there is one such class AvmRepository available in sdk..it has apis such as create-file() ..etc.. Is there any SDK example as to how exactly we should use class.

thanks,
Abhijit
13 REPLIES 13

abhicog123
Champ in-the-making
Champ in-the-making
I have not done anychanges to the SDK sample FirstFoundationClient that I downloaded from alfreso.com So to answer your question I am not sure what it does - uses or does not use alddata-directory or database without the other one.

there are 3 files in alfresco.extension folder in the FirstFoundationClient project that I imported in eclipse.

custom-alfresco-shared.properties
custom-repository-context.xml
custom-repository.properties.

I have kept the values/setting in them as it is.because I dont know what changes should be made to those.

I had shut down the Alfresco server when I got the second error. When I looked at the code FirstFoundationClient.java I found that it is trying to get the ApplicationContext.

ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();


This is the line that throws error in both cases (Alfresco ON and OFF).ApplicationContext in facts tried to load the Alfresco's Spring alfresco/application-context.xml.
Now I am puzzled. Since I am running the FirstFoundationClient from within eclipse, and Alfresco is shut down, then it is not possible to load the application-context.xml. 

The documentation says that it in-process API. So does this mean that FirstFoundationClient should be run from within the Alfresco Webapp?? I am guessing it should be. But even if it is deployed in the same alfresco.war then how am I going to run the FirstFoundationClient.java. In eclipse I am just invoking the main()  method. Again I am guessing, I should write a simple html page and on a button click I could invoke this method from the backend servlet.

But if there is a simple procedure to invoke the FirstFoundationClient from within eclipse , please let me know.

thanks for all your replies guys.

pmonks
Star Contributor
Star Contributor
The following line of code "boots" an embedded Alfresco instance within FirstFoundationClient (ie. creates a new, independent Alfresco application context within the FirstFoundationClient JVM):

ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
Any exceptions that occur anywhere in the Alfresco bootstrap process will be thrown out of this method - it indirectly does a lot of stuff.  :wink:

The reason you saw those exceptions when you had Alfresco running is that you effectively ended up with two independent Alfresco instances running at the same time (one being the standalone Alfresco server and the other being the embedded Alfresco within FirstFoundationClient).  Given that Alfresco (by default) listens on quite a few ports (FTP port 21, CIFS ports 137-139 & 445, NFS ports 111 & 2049 I think?, RMI port 50500), whichever instance you start second will get a lot bind exceptions (since the first instance is already listening on those ports).  This is one of the reasons it's best to not to run a standalone Alfresco server at the same time as FirstFoundationClient - changing all of those ports to ensure there are no conflicts is rather tedious, but not changing the ports will prevent the second Alfresco instance from starting (some, but not all, of those ports are required, so bind exceptions are often fatal).

Like Jan I'm not sure what would cause the second exception you're seeing ("java.lang.IllegalStateException: No user transaction is active").  Have you tried clearing out the repository (alf_data and database) that FirstFoundationClient is writing to and running it again?  By default this is ./alf_data within the FirstFoundationClient project directory, and (assuming you haven't reconfigured it) uses an HSQLDB database located underneath that directory (in ./alf_data/hsql_data).  If you're using those defaults, deleting the alf_data directory will fully reset the repository and should allow for a clean run of the FirstFoundationClient.

Cheers,
Peter

abhicog123
Champ in-the-making
Champ in-the-making
Hi All,

sorry for replying late. i finally got the FirstFoundationclient running. I had not setup the DB and not configured custom-repository.properties file. Hence the problems.

thanks for all the pointers and tips.

amit_wmw
Champ in-the-making
Champ in-the-making
Hello Abhi & all,

During the time of installation I had opted for "Derby". Can you please specify step by step what exactly 
I have to setup with respect to DB and in custom-repository.properties file?

I am still struggling, will be very kind of you.

Thanks n reg-
Amit