cancel
Showing results for 
Search instead for 
Did you mean: 

Problems when integrating Alfresco within my Web application

nrk
Champ in-the-making
Champ in-the-making
Hi,
I have 3 queries…tried reading lots of forum posts but unable to get any idea on solving them Smiley Sad

1) I have included the Alfresco environment within my web application and everything starts fine when Alfresco connects to a db already init'd by the Alfresco Web app.
Now, after I cleanup the db and delete the lucene indexes and restart my web app it hangs after the open office connection error.
The Java (jboss) process shoots to 100% and remains there till I kill it.

I'm running my web app on JBoss 4.0.2 and my DB is Mysql 5. OS is Windows XP Prof.

It looks like I need to modify some config files as I feel that Alfresco checks for something in the DB or Lucene index and locks up. Can you please help me out with this issue.

2) I'm planning to use the JCR XPath search rather than Lucene currently. Is there some way that I can disable Lucene completely?

3) Alfresco seems to create some entries in the file system which seem to be some kind of unique IDs. Is there any way to store this in the DB via config file changes?

4) This is a request wrt the Lucene version. Though the Lucene version says 1.4.3 for the Alfresco 1.2 release the actual version seems to be 1.5.x I'm using 1.4.3 for my own app and the jar file contents are different. I've now switched to the Alfresco version.
I'm now planning to switch to the 1.9 release and use the DB Directory code in the compass framework to store the index in the DB.
Will Alfresco move to Lucene 1.9 anytime soon? and if possible provide for an option to store the index in the DB Smiley Happy

Eliminating the file system makes it easier to move my application to a clustered environment Smiley Happy

thanks!
12 REPLIES 12

nrk
Champ in-the-making
Champ in-the-making
Listing my web apps configuration below. Before that I want to mention that I have disabled JVM optimizations that are default in JBoss 4.0.2. Not sure if they impact anything though.

1) ear-deployer.xml (server/<server>/deploy folder) :
    - Set ?Isolated? to true.
    - Set ?CallByValue? to true.

2) jboss-service.xml (server/<server>/conf folder) :
    - Set ?CallByValue? to true in ?NamingService? mbean.

My web app configuration:
1) web.xml



<context-param>
   <description>Spring config file locations</description>
   <param-name>contextConfigLocation</param-name>
   <param-value>
      classpath:alfresco/web-client-application-context.xml
         classpath:alfresco/jcr-context.xml
   </param-value>
</context-param>

<listener>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
   <listener-class>org.alfresco.web.app.ContextListener</listener-class>
</listener>  


I'm not planning to use JSF and therefore eliminated all references to JSF.

2) From the 1.2 source I created each of the jars and then bundled the respective config files into these jars: core.jar, jcr.jar, repository.jar, webclient.jar

3) created the package alfresco.extension in my code's source and placed the following files into it.
      a) custom-context.xml



<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

    <bean id="repository-properties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="ignoreUnresolvablePlaceholders">
            <value>true</value>
        </property>
        <property name="locations">
            <list>
                <value>classpath:alfresco/repository.properties</value>
                <value>classpath:alfresco/version.properties</value>
                <value>classpath:alfresco/domain/transaction.properties</value>
                <!– override default core properties –>
                <value>classpath:alfresco/extension/custom.properties</value>
            </list>
        </property>
    </bean>
   
    <bean id="hibernateConfigProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="locations">
            <list>
                <value>classpath:alfresco/domain/hibernate-cfg.properties</value>
                <!– override default hibernate properties –>
                <value>classpath:alfresco/extension/custom.properties</value>
            </list>
        </property>
    </bean>
   
    <bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/customModel.xml</value>
            </list>
        </property>
    </bean>   
   
</beans>

Alfresco looks for any *-context.xml files within the alfresco.extension package.

    b) custom.properties



# Folder where Alfresco stores lucene indexes and some store metadata
dir.root=C:/Alfresco_datastore

#DB settings
db.driver=com.mysql.jdbc.Driver
db.name=alfresco
db.url=jdbc:mysql://localhost:3306/${db.name}
db.username=alfresco
db.password=alfresco

# hibernate settings
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=false


though I use the same properties file for every overridden bean, I figured I dont have too many properties to be worrying about hashmaps containing unrequired properties for each bean! This way I have all my custom properties in one file.

   c) customModel.xml



<?xml version="1.0" encoding="UTF-8"?>

<!– Custom Model –>

<!– Note: This model is pre-configured to load at startup of the Repository.  So, all custom –>
<!–       types and aspects added here will automatically be registered –>

<model name="cust:customModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>  
   <description>Custom Model</description>
   <author></author>
   <version>1.0</version>

   <imports>
        <!– Import Alfresco Dictionary Definitions –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <!– Import Alfresco Content Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <!– NOTE: The following namespace custom.model should be changed to reflect your own namespace –>
   <namespaces>
      <namespace uri="custom.model" prefix="cust"/>
   </namespaces>
     
</model>


This is empty currently but I'll fill it as I proceed.

   d) I've written a Util class that provides the ServiceRegistry and JCRRepository.




public class AlfrescoUtils
{
   private static ServletContext context=null;
   private static WebApplicationContext webAppCtx = null;
  

   public static ServiceRegistry getServiceRegistry()
   {
      assert (getServletContext()!=null) : "The ServletContext is not available in Utils. Please set this during Application startup.";
      return (ServiceRegistry) webAppCtx.getBean(ServiceRegistry.SERVICE_REGISTRY);
   }

   public static Repository getJCRRepository()
   {
      assert (getServletContext()!=null) : "The ServletContext is not available in Utils. Please set this during Application startup.";
      return (Repository) webAppCtx.getBean(RepositoryFactory.REPOSITORY_BEAN);
   }

   /**
    * @return Returns the context.
    */
   public static ServletContext getServletContext() {
      return context;
   }

   /**
    * @param context The context to set.
    */
   public static void setServletContext(ServletContext context) {
      AlfrescoUtils.context = context;
      webAppCtx = WebApplicationContextUtils.getRequiredWebApplicationContext(context);
   }

   public static Object getAlfrescoBean(String beanName) {
      assert (getServletContext()!=null) : "The ServletContext is not available in Utils. Please set this during Application startup.";
      return webAppCtx.getBean(beanName);
   }
  
  
}


The Repository startup seems to create the companyHome store. The bootstrap config file mentions creating a new bean overriding ApplicationListener for any custom startup processing.
Since my app does not use Spring I've decided to create any required stores within my existing ServletContext Listener class, since having all the startup code in one format is easier on the mind Smiley Happy

hope this post helps others.

If I come across anything interesting I'll continue adding more posts to this thread.

nrk
Champ in-the-making
Champ in-the-making
Listing my web apps configuration below. Before that I want to mention that I have disabled JVM optimizations that are default in JBoss 4.0.2. Not sure if they impact anything though.

1) ear-deployer.xml (server/<server>/deploy folder) :
    - Set ?Isolated? to true.
    - Set ?CallByValue? to true.

2) jboss-service.xml (server/<server>/conf folder) :
    - Set ?CallByValue? to true in ?NamingService? mbean.

My web app configuration:
1) web.xml



<context-param>
   <description>Spring config file locations</description>
   <param-name>contextConfigLocation</param-name>
   <param-value>
      classpath:alfresco/web-client-application-context.xml
         classpath:alfresco/jcr-context.xml
   </param-value>
</context-param>

<listener>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
   <listener-class>org.alfresco.web.app.ContextListener</listener-class>
</listener>  


I'm not planning to use JSF and therefore eliminated all references to JSF.

2) From the 1.2 source I created each of the jars and then bundled the respective config files into these jars: core.jar, jcr.jar, repository.jar, webclient.jar

3) created the package alfresco.extension in my code's source and placed the following files into it.
      a) custom-context.xml



<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

    <bean id="repository-properties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="ignoreUnresolvablePlaceholders">
            <value>true</value>
        </property>
        <property name="locations">
            <list>
                <value>classpath:alfresco/repository.properties</value>
                <value>classpath:alfresco/version.properties</value>
                <value>classpath:alfresco/domain/transaction.properties</value>
                <!– override default core properties –>
                <value>classpath:alfresco/extension/custom.properties</value>
            </list>
        </property>
    </bean>
   
    <bean id="hibernateConfigProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="locations">
            <list>
                <value>classpath:alfresco/domain/hibernate-cfg.properties</value>
                <!– override default hibernate properties –>
                <value>classpath:alfresco/extension/custom.properties</value>
            </list>
        </property>
    </bean>
   
    <bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/customModel.xml</value>
            </list>
        </property>
    </bean>   
   
</beans>

Alfresco looks for any *-context.xml files within the alfresco.extension package.

    b) custom.properties



# Folder where Alfresco stores lucene indexes and some store metadata
dir.root=C:/Alfresco_datastore

#DB settings
db.driver=com.mysql.jdbc.Driver
db.name=alfresco
db.url=jdbc:mysql://localhost:3306/${db.name}
db.username=alfresco
db.password=alfresco

# hibernate settings
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=false


though I use the same properties file for every overridden bean, I figured I dont have too many properties to be worrying about hashmaps containing unrequired properties for each bean! This way I have all my custom properties in one file.

   c) customModel.xml



<?xml version="1.0" encoding="UTF-8"?>

<!– Custom Model –>

<!– Note: This model is pre-configured to load at startup of the Repository.  So, all custom –>
<!–       types and aspects added here will automatically be registered –>

<model name="cust:customModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>  
   <description>Custom Model</description>
   <author></author>
   <version>1.0</version>

   <imports>
        <!– Import Alfresco Dictionary Definitions –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <!– Import Alfresco Content Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <!– NOTE: The following namespace custom.model should be changed to reflect your own namespace –>
   <namespaces>
      <namespace uri="custom.model" prefix="cust"/>
   </namespaces>
     
</model>


This is empty currently but I'll fill it as I proceed.

   d) I've written a Util class that provides the ServiceRegistry and JCRRepository.




public class AlfrescoUtils
{
   private static ServletContext context=null;
   private static WebApplicationContext webAppCtx = null;
  

   public static ServiceRegistry getServiceRegistry()
   {
      assert (getServletContext()!=null) : "The ServletContext is not available in Utils. Please set this during Application startup.";
      return (ServiceRegistry) webAppCtx.getBean(ServiceRegistry.SERVICE_REGISTRY);
   }

   public static Repository getJCRRepository()
   {
      assert (getServletContext()!=null) : "The ServletContext is not available in Utils. Please set this during Application startup.";
      return (Repository) webAppCtx.getBean(RepositoryFactory.REPOSITORY_BEAN);
   }

   /**
    * @return Returns the context.
    */
   public static ServletContext getServletContext() {
      return context;
   }

   /**
    * @param context The context to set.
    */
   public static void setServletContext(ServletContext context) {
      AlfrescoUtils.context = context;
      webAppCtx = WebApplicationContextUtils.getRequiredWebApplicationContext(context);
   }

   public static Object getAlfrescoBean(String beanName) {
      assert (getServletContext()!=null) : "The ServletContext is not available in Utils. Please set this during Application startup.";
      return webAppCtx.getBean(beanName);
   }
  
  
}


The Repository startup seems to create the companyHome store. The bootstrap config file mentions creating a new bean overriding ApplicationListener for any custom startup processing.
Since my app does not use Spring I've decided to create any required stores within my existing ServletContext Listener class, since having all the startup code in one format is easier on the mind Smiley Happy

hope this post helps others.

If I come across anything interesting I'll continue adding more posts to this thread.

nrk
Champ in-the-making
Champ in-the-making
oops!

I'm not sure what I'm doing wrong but was getting an error dump when submitting my post and therefore retried and now I see that the post has been added twice and all my config info is missing!

posting the file snippets again as plain text which seems to work fine.

1) web.xml
—————————————————
<context-param>
   <description>Spring config file locations</description>
   <param-name>contextConfigLocation</param-name>
   <param-value>
      classpath:alfresco/web-client-application-context.xml
         classpath:alfresco/jcr-context.xml
   </param-value>
</context-param>

<listener>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
   <listener-class>org.alfresco.web.app.ContextListener</listener-class>
</listener> 
——————————————————

2) custom-context.xml
——————————————————

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

    <bean id="repository-properties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="ignoreUnresolvablePlaceholders">
            <value>true</value>
        </property>
        <property name="locations">
            <list>
                <value>classpath:alfresco/repository.properties</value>
                <value>classpath:alfresco/version.properties</value>
                <value>classpath:alfresco/domain/transaction.properties</value>
                <!– override default core properties –>
                <value>classpath:alfresco/extension/custom.properties</value>
            </list>
        </property>
    </bean>
   
    <bean id="hibernateConfigProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="locations">
            <list>
                <value>classpath:alfresco/domain/hibernate-cfg.properties</value>
                <!– override default hibernate properties –>
                <value>classpath:alfresco/extension/custom.properties</value>
            </list>
        </property>
    </bean>
   
    <bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/customModel.xml</value>
            </list>
        </property>
    </bean>   
   
</beans>
———————————————-

3) custom.properties
———————————————-
# Folder where Alfresco stores lucene indexes and some store metadata
dir.root=C:/Alfresco_datastore

#DB settings
db.driver=com.mysql.jdbc.Driver
db.name=alfresco
db.url=jdbc:mysql://localhost:3306/${db.name}
db.username=alfresco
db.password=alfresco

# hibernate settings
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=false
————————————————-

4) customModel.xml
————————————————–
<?xml version="1.0" encoding="UTF-8"?>

<!– Custom Model –>

<!– Note: This model is pre-configured to load at startup of the Repository.  So, all custom –>
<!–       types and aspects added here will automatically be registered –>

<model name="cust:customModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>   
   <description>Custom Model</description>
   <author></author>
   <version>1.0</version>

   <imports>
        <!– Import Alfresco Dictionary Definitions –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <!– Import Alfresco Content Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <!– NOTE: The following namespace custom.model should be changed to reflect your own namespace –>
   <namespaces>
      <namespace uri="custom.model" prefix="cust"/>
   </namespaces>
     
</model>
————————————————–

5) AlfrescoUtils.java
————————————————–
public class AlfrescoUtils
{
   private static ServletContext context=null;
   private static WebApplicationContext webAppCtx = null;
   

   public static ServiceRegistry getServiceRegistry()
   {
      assert (getServletContext()!=null) : "The ServletContext is not available in Utils. Please set this during Application startup.";
      return (ServiceRegistry) webAppCtx.getBean(ServiceRegistry.SERVICE_REGISTRY);
   }

   public static Repository getJCRRepository()
   {
      assert (getServletContext()!=null) : "The ServletContext is not available in Utils. Please set this during Application startup.";
      return (Repository) webAppCtx.getBean(RepositoryFactory.REPOSITORY_BEAN);
   }

   /**
    * @return Returns the context.
    */
   public static ServletContext getServletContext() {
      return context;
   }

   /**
    * @param context The context to set.
    */
   public static void setServletContext(ServletContext context) {
      AlfrescoUtils.context = context;
      webAppCtx = WebApplicationContextUtils.getRequiredWebApplicationContext(context);
   }

   public static Object getAlfrescoBean(String beanName) {
      assert (getServletContext()!=null) : "The ServletContext is not available in Utils. Please set this during Application startup.";
      return webAppCtx.getBean(beanName);
   }
   
   
}
——————————————