Tag Archives: alfresco

Troubleshooting Alfresco’s JMX Console Connections

Most of the time, I can get jconsole to make a JMX connection to a running instance of Alfresco but there are times when I will run into issues or a customer simply can’t seem to make it work. Below are some troubleshooting steps to getting JMX working and make a connection to it.

Make sure that the Alfresco server does not have a NAT network connection. If you’re not sure what this is, you can ask your network administrator to check and tell you for sure. I realize I have this first in the list but usually this isn’t the cause. I would suspect this as the issue only if the following troubleshooting fails and you simply can’t get it working.

Make sure you have this somewhere in your java_opts:

-Dcom.sun.management.jmxremote

This tells the running JVM to start the jmx service.

Make sure you have this in your alfresco-global.properties:

alfresco.rmi.services.port=50500
alfresco.rmi.services.host=<hostname>

The <hostname> should be resolvable using ping from the workstation from where you are running jconsole.

Make sure you connect with the jconsole in the java/bin/ using the JDK you’re using to run Alfresco with. In other words, you may have another JDK installed elsewhere and jconsole from that JDK may be on your path. It’s a good idea to do a `whereis jconsole` to see which path it comes from. If nothing else, go directly to the java/bin directory in your Alfresco install and use the jconsole executable there. This is the standard url to use when connecting:

service:jmx:rmi:///jndi/rmi://<hostname>:50500/alfresco/jmxrmi

If you’re running this on the local server, you may want to try localhost for hostname. In any case, make sure that <hostname> is set to a reachable domain name on the network. IP Address might not be a bad idea either.

If you haven’t changed the username/password for JMX, the default is:

userid: controlRole
password: change_asap

The ‘change_asap’ password should be a hint to change it as soon as you can. If you simply can’t remember the username/password combo, they should be revealed in these files:

<configRoot>/alfresco/alfresco-jmxrmi.access
<configRoot>/alfresco/alfresco-jmxrmi.password

With all these things satisfied and Alfresco started, you can test on the Alfresco server to make sure the JMX rmi service is running by either issuing these from the command line:

# lsof -i :50500 (for Linux)
# netstat -an (for Windows)

With Windows you can probably use the /find switch to look for port 50500 in the listing specifically or you can scroll through the output to look for 50500.

Next, from the client workstation, you can test connectivity to the JMX rmi port by first pinging the server’s hostname. After this, check for port opening from your workstation by issuing:

# telnet <hostname> 50500

You’ll know this is open by getting a blank screen instead of the “unable to connect” message or something similar.

If none of these work, then have  your network admin see if your server is set up with NAT addressing. This can cause problems with any of the RMI services (of which JMX is related).

HTH,

H.S. :)

Javascript: Templating Folders when created by Share Rules

question

This one has had me perplexed for some time. We seem to get this question just a few times a year but it’s a really good one:

I’m creating a rule on a folder in Share. This rule will create 3 particular subfolders in the new folder that’s being created with a script. How do I accomplish this?

It made sense to me that your script should look like:

var subfolder1 = space.childByNamePath("subfolder1");
subfolder1 = space.createFolder("subfolder1");

As I’ve found out, the “space” counts as the root folder where this new folder is being placed. If this does anything, it will only create the folders in the same directory as your new folder. It took me a while of looking through blogs, articles and our own documentation to find out that this is the way to get it done:

var invoices = document.childByNamePath("Invoices");
invoices = document.createFolder("Invoices");

I tested this with a rule and it works like a champ. It didn’t dawn on me initially to use document to represent the node being created that triggers the rule. And from here we can then do things like copy, change/add aspects, create associations, and so on. 

Happy Scripting!

-H.S.

Alfresco Custom Data Lists

Summary

The data lists feature allows site members to create and manage lists of data relevant to the site. Users can work with their own lists and can also contribute to lists created by other site members. Out of the box there are many list templates provided such as: Contact list, Event list, Issue list, To-do list, Feedback list, etc.

Since there are a limited number of canned or out of the box data lists, you will likely need to create your own custom datalist.

To do this, you’ll need to create a custom model file that will define the data list essentially. You’ll also need a context file that references the custom model and finally, make modifications to share-config-custom.xml so that your data list will register and display in your Share site. Be aware that I was able to successfully create a custom data-list using these steps on Alfresco versions 3.4.x and 4.x. I did not test in 3.3, 3.2 or before.

Below are the steps to accomplish this.

Custom Model File

I have called this one slModel.xml to be placed in the extensions directory. This is usually in <alfresco_install_dir>/tomcat/shared/classes/alfresco/extension directory:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Definition of new Model -->
<model name="sl:slDatalist" xmlns="http://www.alfresco.org/model/dictionary/1.0">
 <!-- Optional meta-data about the model --> 
 <description>KB datalist</description>
 <author>Harlin Seritt</author>
 <version>1.0</version>
 <!-- Imports are required to allow references to definitions in other models --> 
 <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"/>
     <!-- Import Alfresco Data List Model Definitions -->
     <import uri="http://www.alfresco.org/model/datalist/1.0" prefix="dl"/>
 </imports>

<!-- Introduction of new namespaces defined by this model --> 
 <namespaces>
     <namespace uri="sl.customlists.com" prefix="sl"/>
 </namespaces>
 <types>
 <!-- Data list defintions For this model go here -->
     <type name="sl:slArticle">
         <title>SL Article</title>
         <description>Simple Article</description>
         <parent>dl:dataListItem</parent>

         <properties>
             <property name="sl:slTitle">
                 <title>Title</title>
                 <type>d:text</type>
                 <mandatory>true</mandatory>
             </property>

             <property name="sl:slContent">
                 <title>Content</title>
                 <type>d:text</type>
                 <mandatory>false</mandatory>
             </property>
         </properties> 

         <associations>
             <association name="sl:slAttachments">
                 <title>Attachements</title>
                 <source>
                     <mandatory>false</mandatory>
                     <many>true</many>
                 </source>
                 <target>
                     <class>cm:content</class>
                     <mandatory>false</mandatory>
                     <many>true</many>
                 </target>
             </association>
         </associations>
     </type>
 </types> 
</model>

Next, you’ll need to create a context file. This file (slModel-context.xml) needs to be placed in the extension directory :

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
    <!-- Registration of new models --> 
    <bean id="sl.extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
    <property name="models">
        <list>
            <value>alfresco/extension/slModel.xml</value>
        </list>
    </property>
 </bean>

<!-- Shows how to add an additional model if needed
<bean id="extension.mtg.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
 <property name="models">
     <list>
         <value>alfresco/extension/myOtherDatalistModel.xml</value>
     </list>
 </property>
</bean>
-->

</beans>

Last, add these configs to the share-config-custom.xml file (to be overwritten in the web-extensions directory usually in tomcat/shared/classes/web-extension):<config evaluator=”model-type” condition=”sl:slArticle”> <forms>

     <!-- Create item form -->
     <form>
         <field-visibility>
             <show id="sl:slTitle" /> 
             <show id="sl:slContent" /> 
             <show id="sl:slAttachments" /> 
         </field-visibility>
         <create-form template="/org/alfresco/components/data-lists/forms/dataitem.ftl" />
         <appearance>
             <field id="sl:slTitle">
                 <control template="/org/alfresco/components/form/controls/textarea.ftl" /> 
             </field>
             <field id="sl:slContent">
                 <control template="/org/alfresco/components/form/controls/textarea.ftl" /> 
             </field> 
             <field id="sl:slAttachments">
                 <control>
                     <control-param name="startLocation">{doclib}</control-param>
                 </control>
             </field>
         </appearance>
     </form>

 <!-- Data Grid view -->
 <form id="datagrid">
      <field-visibility> 
          <show id="sl:slTitle" /> 
          <show id="sl:slContent" /> 
          <show id="sl:slAttachments" /> 
      </field-visibility>
 </form>
</forms>
</config>

 <!-- Edit view -->
 <config evaluator="node-type" condition="sl:slArticle">
 <forms>
     <!-- Edit marketing item form -->
     <form>
          <field-visibility> 
              <show id="sl:slTitle" /> 
              <show id="sl:slContent" /> 
              <show id="sl:slAttachments" /> 
          </field-visibility>
          <create-form template="/org/alfresco/components/data-lists/forms/dataitem.ftl" />
          <appearance>
              <field id="sl:slTitle">
                 <control template="/org/alfresco/components/form/controls/textarea.ftl" /> 
              </field>
              <field id="sl:slContent">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" /> 
              </field> 
              <field id="sl:slAttachments">
                  <control>
                      <control-param name="startLocation">{doclib}</control-param>
                  </control>
              </field>
          </appearance>
     </form>
 </forms>
</config>

Add these in place and restart Alfresco. You can then go to any Share site and add this datalist:

<screenshot>

Choose the SL Article data list:

<screenshot>

Add data:

<screenshot>

Now, you have a custom data list!

Cheers! -H.S.

How To Install Alfresco Dashlets

Screen Shot 2013-02-05 at 2.20.30 PM

Summary

Alfresco Share Dashlets are mini applications (some may be tempted to say Applets but that is more of a Java term 😉 ) that are able to be added on the fly to add some very minor functionality to your Alfresco server. You can get Share dashlets here. In case you weren’t aware, you can pick up many new dashlets created by the community and even peek inside some sample ones to get an idea how to create your own.

Make sure you have a look at the individual page for each dashlet you’re interested. The dashlet’s page may tell you how to build them (usually with ant), deploy them, which Alfresco version is required, etc.

How To Deploy Dashlets to Alfresco

Which jar file to use for them may depend on the build method used.

Create a tomcat/shared/lib directory if you haven’t already:

# cd <alf_install>/tomcat
# mkdir -p shared/lib

Add the shared/lib/*.jar to shared.loader in tomcat/conf/catalina.properties:

shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar

Afterwards, copy the dashlet jars into tomcat/shared/classes and restart Alfresco.

Open your Share page and go to Customize Dashboard.

Screen Shot 2013-02-05 at 10.07.15 AM

When you click on Add Dashlets you should now see your dashlet added to the list. In my case this is the BBC Weather dashlet.

Screen Shot 2013-02-05 at 10.08.03 AM

Drag this one to your list and click Ok. I dragged mine from Add Dashlets to Column 1 in this case. This will bring you to your dashboard and the dashlet should be now showing. To configure this particular one to show the weather for a particular city, click on the pencil icon in the upper right corner of the dashboard (look on yours, in the screenshot below the pencil icon isn’t shown).

Screen Shot 2013-02-05 at 10.10.23 AM

Change the city to yours and click Ok.

Screen Shot 2013-02-05 at 10.10.47 AM

Voila! The BBC Weather Dashlet should be showing on your dashboard.

This method should work for most dashlets but keep in mind, some of them may take some additional steps to configure.

Happy Dashletting!

Cheers! -H.S.