Wednesday, January 2, 2013

Monitoring Alfresco through JMX

Back in some days we were facing thread locking issue on Alfresco. Got a good chance to enable JMX and see what is happening inside.

How to enable JMX extension with Tomcat (OS Solaris)?
1.Set the property -Dcom.sun.management.jmxremote in alfresco.sh file
JAVA_OPTS=" -server -d64 -Xms10g -Xmx55g -XX:MaxNewSize=10g -XX:MaxPermSize=30g -Dcom.sun.management.jmxremote “ and export JAVA_OPTS
2.Check in file \classes\alfresco\core-services-context.xml bean section “RMIRegistryFactoryBean” should not be commented.
3.For Security purpose change default passwords in below files,
/alfresco/alfresco-jmxrmi.access
/alfresco/alfresco-jmxrmi.password

How to connect JMX client to Remote Alfresco (OS Windows)?
1.Go to your installed Java directory and execute jconsole.exe
D:\cci\javatools\Java\jdk1.6.0_31\bin>jconsole.exe
2.Once jconsole is launched select “Remote Process” radio box and add URL to connect service:jmx:rmi:///jndi/rmi://:50500/alfresco/jmxrmi
3.Input username and password if you have changed. Default username/password is controlRole/change_asap





Once you are connected to remote process you can see below tabs
1.Overview- which shows Heap Memory Usage, Thread, Class and CPU Usages,
2.Memory- Detailed view of Heap Memory and Non Heap Memory Usage,
3.Thread – Detailed of individual threads
4.Classes- Number of Class loaded
5.VM summary- Detailed view of VM summary
6.MBeans- All Mbeans which are exposed either readonly or configurable.

How to user topthread.jar with JConsole?
topthread.jar will allow you to see usage history of threads, CPU usage and state of thread; you can download topthread.jar from here…
1.Go to your installed Java directory and execute jconsole.exe
jconsole.exe -pluginpath D:\cci\javatools\Java\jdk1.6.0_31\lib\topthreads.jar

2.You will be able to see extra tab “Top thread” once jconsole is connected with server.


Top Thread Analysis

Sometimes system becomes unresponsive if any thread got stuck of having more CPU usage even if application seems not to be busy. We can locate such a thread from topthreads and can kill it to get system responsive. We can adjust the refresh interval and max displayed threads to limit our analysis data instead of having much frequent refresh and hundreds of thread being displayed on one small screen.


Monday, April 12, 2010

Alfresco Search Customization

As per Alfresco documentation default search uses a Boolean "Implied AND" as like Google, Yahoo or any major search engine works. But the behavior of alfresco is seems to be using Boolean “Implied OR”.
But Customization of such kind of search is made easy by Alfresco when it comes to customize Alfresco Web Client.
Let’s go by example.
We have few resume stored as word document in our repository if we do search on Alfresco repository using keywords (java alfresco) it gives all the documents which has meta data(or Full text search) either as Java or as alfresco. But we are intended to search all those documents which have Java and alfresco both skill sets. It is the situation where alfresco default search is based on “Implied OR”.
We can configure this on Alfresco web-client customization if we are using SearchContext . We need to add the configuration in web-client-config-custom.xml as below

<alfresco-config>
   <config>
      <client>
        <!-- set this value to true to enable AND text terms for simple/advanced search by default -->
        <search-and-terms>true</search-and-terms>
      </client>
   </config>
</alfresco-config>

If you are using Search Service (Search using API) then you can set SearchParameter default operator as “implied AND” as below

SearchParameters sp = new SearchParameters();
sp.addStore(Repository.getStoreRef());
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery(query);
sp.setDefaultOperator(SearchParameters.AND);
ResultSet nodeRefs = searchService.query(sp);

With this kind of customization we are sure that we can use exact search as like Google in our Alfresco repository.

Monday, March 29, 2010

Custom Content Transformer

Alfresco has content transformer for most of mime type we are using day to day. But We wanted to have Custom Content Transformer,to show preview of .xfdl file.

.xfdl is extension for electronic form provided by Lotus Forms. This blog is more of creating a Custom Content Transformer for xfdl mime type.

1.How to register new Content Type i.e. “.xfdl”
Create new file “mimetype-custom-extensions.xml” at level “alfresco/mimetype” parallel level to “alfresco/extension” it should not go under “alfresco/extension” e.g. say mimetype-custom-extensions.xml
In this file we configure alfresco-config for area mimetype-map. Define correct mimetype for your extension here.


2.How to register new Custom Content Transformer
Create new file custom-services-context.xml under “alfresco/extension” folder e.g. custom-services-context.xml

In this file we need to define bean for "mimetypeConfigService" and new bean "transformer.xfdlToText" for Transformer "XFDLContentTransformer".


3. Create Custom Content Transformer “XFDLContentTransformer.java”
This is class where Transformation will take place for you extension mimetype. This class will extends the functionality from "AbstractContentTransformer" . This class uses a "transformText" method to transform it. You have different for you different extension and mimetype.


You can download the code from here ...
http://docs.google.com/leaf?id=0B2GTDzbcX3UsYjliNTAxMjYtNTkwMi00YmI4LTkyODgtZTA3OGQwNjQyN2Qw&hl=en

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”.

Tuesday, December 1, 2009

Dynamic deployment of Alfresco Custom Workflow

This feature is available from Alfreso 3.0 and above.

Alfresco 3 has given the facility of Dynamic Deployment for
1.New content/Workflow model.
2.Message Resource Bundle.
3.Alfresco Explorer configuration (Web-client-config.xml).
4.Workflow Process Definition.

Please download this pdf file for working example.

http://docs.google.com/fileview?id=0B2GTDzbcX3UsMWE2NTRmNGYtNDhhNC00NTIyLTllZjYtOTNmMmZlMjc2OWNl&hl=en

Friday, November 27, 2009

Alfresco CIFS on Windows XP

Below steps will enable to Configure Alfresco CIFS on Windows Platform

1. Create file-server-custom.xml in alfresco/extension package

<alfresco-config area="file-servers">

<!-- To override the default Alfresco filesystem use replace="true", to -->
<!-- add additional filesystems remove the replace="true" attribute -->

<config evaluator="string-compare" condition="Filesystems" replace="true">
<filesystems>

<filesystem name="Alfresco">
<store>workspace://SpacesStore</store>
<rootPath>/app:company_home</rootPath>
<disableChangeNotification/>
<!-- Add a URL file to each folder that links back to the web client -->
<urlFile>
<filename>__Alfresco.url</filename>
<webpath>http://${localname}A:8080/alfresco/</webpath>
</urlFile>

<!-- Mark locked files as offline -->
<offlineFiles/>

<!-- Desktop actions -->

<desktopActions>
<global>
<path>alfresco/desktop/Alfresco.exe</path>
<webpath>http://${localname}A:8080/alfresco/</webpath>
</global>
<action>
<class>org.alfresco.filesys.smb.server.repo.desk.CheckInOutDesktopAction</class>
<name>CheckInOut</name>
<filename>__CheckInOut.exe</filename>
</action>
<action>
<class>org.alfresco.filesys.smb.server.repo.desk.JavaScriptDesktopAction</class>
<name>JavaScriptURL</name>
<filename>__ShowDetails.exe</filename>
<script>alfresco/desktop/showDetails.js</script>
<attributes>anyFiles</attributes>
<preprocess>copyToTarget</preprocess>
</action>

</desktopActions>

<!--
<accessControl default="Write">
<user name="admin" access="Write"/>
<address subnet="90.1.0.0" mask="255.255.0.0" access="Write"/>
</accessControl>
-->
</filesystem>

<!-- AVM virtualization view of all stores/versions for WCM -->
<avmfilesystem name="AVM">
<virtualView/>
</avmfilesystem>

</filesystems>
</config>

</alfresco-config>


2. Enable Debug setting for CIFS server (so that you can see successful execution on CIFS @ tomcat\webapps\alfresco\WEB-INF\classes\log4j.properties)
log4j.logger.org.alfresco.smb.protocol=debug
log4j.logger.org.alfresco.smb.protocol.auth=debug
log4j.logger.org.alfresco.acegi=debug
3. Restart Tomcat and Map Drive with \\alfresco109A\Alfresco


Troubleshooting
If your are still unable to get CIFS server up...
Please be sure

1. Your custom-configuration is deployed on tomcat server (see in "tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension" or in jar if you are using jar for your application module).
2. Your computer name should be less than 15 character.


Please post a comment if you found this blog useful to you :)

Tuesday, August 18, 2009

WSSecurityEngine: Invalid timestamp The security semantics of message have expired

Each message sent by the client contains a time-stamp. The server refuses messages sent more than five minutes ago. This is to prevent replay attacks (where an attacker gets hold of a valid message and then sends it again later).

Handler definition:

<handler name="WSSecurity" type="java:org.apache.ws.axis.security.WSDoAllReceiver">
<parameter name="action" value="UsernameToken Timestamp"/>
</handler>


How Timestamp handling in WSS4J
WSS4J supports several time features and options. If you just use the action Timestamp without any further configuration WSS4J uses the following defaults :

•All timestaps use millisecond precision
•The default time difference between Created and Expires is set to 300 seconds (5 minutes).
•The handler performs strict timestamp handling, i.e. throws an exception if verification of the timestamp fails.
Use the following handler parameters to change these settings:
timeToLive to specify another time difference between Created and Expires. The value of this parameter is an integer that defines the time difference in seconds.
precisionInMilliseconds to switch off the millisecond time precision. Set the value to false or 0 to generate timestamps without milliseconds.
timestampStrict to switch off strict timestamp handling. Set the value to false or 0 to switch off strict handling. According to WSS specfications it is optional to report a fault if timestamp verification fails.

Check the system clock on your server and make sure it's set to the same time as the client machine.

If both client and server reside in US then we need to set timezone like

For Window Sever – (GMT – 05:00) Eastern Time (US & Canada)
Go to Start-->Control Panel-->Date and Time and change time zone

Changing time zone in Solaris 10 - x86
Create new file /etc/TIMEZONE
vi /etc/TIMEZONE

Change the value for TZ to the zone I want
E.g. TZ=US/Eastern

For full list, refer /usr/share/lib/zoneinfo

Run below command
#rtc –z US/Eastern
#rtc –c

Reboot you system to get date and time zone changed effect.

You can verify your ) Eastern Time (US & Canada) with
http://www.timeanddate.com/library/abbreviations/timezones/na/edt.html