Wednesday, January 27, 2010

Alfresco FirstFoundationClient (How to setup and Run)

With this blog you will be able to setup and Run FirstFoundationClient sample of Alfresco.

1. Import FirstFoundationClient Project in eclipse (Assuming you are using eclipse).
2. Specify repository properties with “source/alfresco/extension/custom-repository.properties”.


#
# Sample custom content and index data location
#

dir.root=D:/javatools/alfrescorepo/alf_data
dir.indexes=D:/javatools/alfrescorepo/alf_data/lucene-indexes

#
# Sample database connection properties
#
db.name=alfrescorepodb
db.username=workalfresco
db.password=workalfresco
db.driver=org.postgresql.Driver
db.url=jdbc:postgresql://localhost:5432/alfrescorepodb


3. Create New file “custom-hibernate-dialect.properties” under “source/alfresco/extension”.
#
# Sample Hibernate configuration for changing Database dialect
# For a full list: http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#configuration-optional-dialects
#


#
# PostgreSQL dialect
#
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
hibernate.query.substitutions=true TRUE, false FALSE


4. Create new bean definition “hibernateConfigProperties” in “source/alfresco/extension/custom-repository-context.xml”.

<bean id="hibernateConfigProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:alfresco/domain/hibernate-cfg.properties</value>

<!-- Override hibernate dialect -->
<value>classpath:alfresco/extension/custom-hibernate-dialect.properties</value>
</list>
</property>
</bean>


5. Run FirstFoundationClient.java with main method.

Note:
1. If you are using PostgreSQL or any other database please provide driver classpath or add additional jar to your project.
2. If your alfresco tomcat server is already Running Please try to change avm.jmxrmi.port from 50500 to 50502 and avm.remote.port from 1313 to 1315 in “/source/alfresco/extension/custom-alfresco-shared.properties”.

2 comments:

  1. Hi, I have ran this example and managed to do some basic things i wanted to try.
    It is all fine but when I restarted my alfresco server then i came across a stackTrace which told me that it was unable to load the application context ...
    I fixed this by dropping my database and alf_data directory.
    Re-started, all fine, shut down and re-re-started again to make sure it works fine.
    Then I tried the very example that I found in the SDK "untouched" which ran fine but when I tried to re-re-re-start my server :"Ka-Boom" it was crashed again ...
    Tried with the "Daguerre method" by removing examples code line one by one, always the same, fianlly seems like it is "ApplicationContextHelper.getApplicationContext();" that causes the crash.

    If you have any idea of what the cause could be ?

    I work on Ubuntu [9.10 Karmic Koala]
    I have an official [jdk1.6.0_14] (not the openJdk)
    My server is on [Alfresco Enterprise Edition 3.2r]
    My SDK is [alfresco-community-sdk-3.3]
    (please let me know if you want more informations like the stacktrace I get or anything else)

    ReplyDelete
  2. Ok I figured out where this problem came from (sdk and server version mismatch ... stupid me ... bad me) ...

    But now I have both on the same version (3.2r enterprise)

    I still get problems but it is a horrible stacktrace that I wont post here, if you feel like you want to help some poor lost student please go there : http://forums.alfresco.com/en/viewtopic.php?f=4&t=26268

    Thanks in advance :D

    ReplyDelete