Friday, December 28, 2007

Alfresco Web Forms

Working on some XSL transformations today I ran into some trouble trying to get a document generated by a different WebForm. The logic is as follows:

Header WebForm --produced--> Header1.xml --under-->/ROOT/content
Main WebForm --looked for--> Header1.xml --produced--> Main.xml --under-->/ROOT

I keep running into the same exception below:

14:23:09,321 ERROR [org.alfresco.web.ui.common.Utils] Error generating rendition using main.xsl: javax.xml.transform.TransformerException: java.lang.NullPointerException
org.alfresco.web.forms.RenderingEngine$RenderingException: javax.xml.transform.TransformerException: java.lang.NullPointerException

caused by this line in my XSL file:

<xsl:variable name="header_file" select="alf:parseXMLDocument($header_location)"/>

So my guess was that it wasn't finding the file referenced by $header_location, which value was "Header1.xml" by the way.

After some debugging it worked when both Header WebForm and Main WebForm Output path pattern was the same. The Output path pattern is configured when you add and configure the Webform to the Web Project. So my guess is that when I was using parseXMLDocument($header_location) it look for a file with a path relative to the Output path pattern.

So for future reference the parameter to parseXMLDocument(location) shoul be relative to your ROOT web project folder. For example, suppose you have a Webform generate content to ROOT/content and you want to grab a file under that location (i.e. Header.xml) from a file generated under a diferent directory (i.e. ROOT) then you would get the file like this parseXMLDocument(content/Header.xml).

Hope you find this info useful. God knows I was searching for a post like this an hour ago :).

Happy Holidays!

Tuesday, December 18, 2007

Apache Roller on Jboss 4.2.2

Today I wanted to give it a shot with Apache Roller on Jboss 4.2.2. The thing is Apache Roller  works with Apache OpenJPA, which  offers Java EE persistence. Jboss works with Hibernate Entity Manager by default.

I’m trying to find a way to switch the persistence provider for roller on Jboss.  If you already know a way, let me know.

Monday, December 17, 2007

Alfresco's Deployment Module Cleanup

I've been playing a lot with the deployment module. Been reverting/promoting Web Project versions. Also created a custom java class implementing the org.alfresco.deployment.FSDeploymentRunnable interface. So it run after each successful deployment.

<entry key="runnable"><value>com.mycompany.alfresco.deployment.SampleDR</value></entry>


The issue was that whenever this class failed, it corrupted the metadata directory that the deployment module created (Excerpt of Stacktrace below).

...
org.alfresco.deployment.impl.DeploymentException: Recovery failed for afc9657c-ace2-11dc-a0c4-7b3d7cd0abf4
...
Caused by: java.io.FileNotFoundException: depmetadata\default.md\.md.clone (The system cannot find the file specified)
...

So my solution was:

  1. Comment the runnable line on application-context.xml

  2. Delete the depdata, depmetadata and deplog dirs from ALF_DEPLOYMENT_HOME dir

  3. Do a successful deployment from Alfrescos webclient. This will generate the missing ALF_DEPLOYMENT_HOME/depmetadata/default.md/.md file that is not created during failed deployments (when the runnable class throws a RuntimeException).

  4. Uncomment the runnable line on application-context.xml

  5. Restart the Alfresco Deployment Windows Service

  6. Do a redeploy. This time it will execute the runnable class and if it executed succesfully everything will work smoothly



If somebody out there found out a better solution please let me know.

Install Alfresco Deployment Module as a Windows Service

Having to deal with Windows, I naturally wanted to install the Alfresco Community Deployment Module as a windows service in the server hosting the standalone production HTTP server.

First thing first. Download the module from Alfresco Community Network go to Download Web Content Management extension and get the alfresco-community-deployment-2.1.0.zip file. Extract its contents to C:\ or whatever (This will be the ALF_DEPLOYMENT_HOME).

Now the Windows Service thing.

I came across a very useful library, which among many other things, runs Java applications as Windows Services or Unix Daemons. The library is Java Service Wrapper. Get the binary distribution an extract it to your preferred destination (WRAPPER_HOME).

I extracted, and in some cases renamed, the following files to the specified folder:

WRAPPER_HOME\bin\wrapper.exe -> ALF_DEPLOYMENT_HOME
WRAPPER_HOME\lib\wrapper.dll -> ALF_DEPLOYMENT_HOME\wrapper_lib
WRAPPER_HOME\lib\wrapper.jar -> ALF_DEPLOYMENT_HOME\wrapper\lib
WRAPPER_HOME\src\conf\wrapper.conf.ini -> ALF_DEPLOYMENT_HOME\conf\wrapper.conf
WRAPPER_HOME\srr\bin\InstallApp-NT.bat.in -> ALF_DEPLOYMENT_HOME\InstallAlfrescoDeployment-NT.bat
WRAPPER_HOME\src\bin\UninstallApp-NT.bat.in -> ALF_DEPLOYMENT_HOME\UninstallApp-NT.bat

Now configure ALF_DEPLOYMENT_HOME\conf\wrapper.conf to reflect the following values:

# Java Application
wrapper.java.command=C:\Program Files\Java\jdk1.6.0\bin\java

# Java Main class.
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp

# Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1
wrapper.java.classpath.1=alfresco-deployment.jar
wrapper.java.classpath.2=spring-2.0.2.jar
wrapper.java.classpath.3commons-logging-1.0.4.jar
wrapper.java.classpath.4=alfresco-core.jar;jug.jar
wrapper.java.classpath.5=./wrapper_lib/wrapper.jar
wrapper.java.classpath.6=.

# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=./wrapper_lib

# Java Additional Parameters
wrapper.java.additional.1=-server

# Application parameters. Add parameters as needed starting from 1
wrapper.app.parameter.1=org.alfresco.deployment.Main
wrapper.app.parameter.2=application-context.xml

# Name of the service
wrapper.ntservice.name=Alfresco Deployment

# Display name of the service
wrapper.ntservice.displayname=Alfresco Deployment

# Description of the service
wrapper.ntservice.description=Alfresco community Deployment Module

* I just included the properties I MODIFIED from wrapper.conf, keep in mind there are more properties in the file.

Now just modify InstallAlfrescoDeployment-NT.bat and UninstallAlfrescoDeployment-NT.bat. Look for the following line:
set _WRAPPER_CONF="%_REALPATH%..\conf\wrapper.conf"
and change it to:
set _WRAPPER_CONF="%_REALPATH%conf\wrapper.conf"

Now run InstallAlfrescoDeployment-NT.bat as a user with admin privileges and now you should have a new service named Alfresco Deployment in the windows service console.



That it! You know have a Alfresco Deployment Module installed as a windows service. Hope this post was helpful. See you in the next post!


TIP: Please make sure the values specified in ALFRESCO_WAR/WEB-INF/classes/alfresco/web-client-config-wcm.xml are correct. Specially the ones below, have to match the ones defined for the Alfresco Community Deployment Module (in ALF_DEPLOYMENT_HOME/application-context.xml):

<!-- username to login as on the remote machine >
<remote-username>XXX</remote-username>
<!-- password to use on remote machine -->
<remote-password>XXX</remote-password>
<!-- default RMI port to connect to Alfresco server on remote machine -->
<remote-rmi-port>XXXX</remote-rmi-port>

Saturday, December 15, 2007

Jboss and Alfresco Virtualization as Windows Service

So...Jboss as a windows service. First of all get JBoss Native 2.0.1. Extract it's contents to JBOSS_HOME and run:

C:\> cd c:\jboss-4.2.0\bin
C:\> service.bat install

That'll take care of starting Jboss as a windows service. I just had to make sure jboss would bind to all interfaces so I edited JBOSS_HOME/bin/run.bat and added the -b 0.0.0.0 to the following line:

"%JAVA%" %JAVA_OPTS% "-Djava.endorsed.dirs=%JBOSS_ENDORSED_DIRS%" -classpath "%JBOSS_CLASSPATH%" org.jboss.Main -b 0.0.0.0 %*

Now install Alfresco's Tomcat virtualization server. I installed the Alfrescos WCM extension to my ALFRESCO_HOME directory. So go to ALFRESCO_HOME/virtual-tomcat/bin and run:

Install the service named 'Tomcat5'
C:\> service.bat install

Now I only have to figure out how to bind the virtualization server to all interfaces since I want users outside my company's intranet to be able to acccess Alfresco's WCM preview feature. I know I have to modify:

ALFRESCO_HOME/virtual-tomcat/conf/alfresco-virtserver.properties

The instructions to configure this are in that file. I'll get into it and let you know.

If somebody has figured it out please leave me a comment!

See you on the next post....

Thursday, December 13, 2007

Deploying Alfresco + WCM on Jboss

As a rule of thumb RTFM first! This is something I cannot stress well enough. So, I first went to the official Alfresco Wiki/Alfresco Developers site. Go to Popular Documentation->Server Installation. Religiouslly followed the steps posted in the two links below:

Tip: By default jboss server is only bound to localhost or 127.0.0.1. This means that if you want to allow LAN/Internet access to alfresco you should bind network interfaces you want to provide access. To bind all interfaces, simple run jboss (JBOSS_HOME/bin/run.bat) with the "-b 0.0.0.0" option. Remember you have to secure your jboss server first (JMX Console, Web Console, etc). Refer to this link for more information.

The next step was installing the Web Content Management (WCM) extension. No problem there. Just had a minor change since I'm using virtualization to preview sandboxes. I had to tweak the configuration to allow LAN users to access the WCM preview website feature. Alfresco's virtual hyperlink format is like follows:

http://virtual-hostname.www--sandbox.127-0-0-1:8180/request-path

This link obviously only works accessing it from the Alfresco Server. Change:

$VIRTUAL_TOMCAT_HOME/conf/alfresco-virtserver.properties file.

Look for the following line:

http://virtual-hostname.www--sandbox.127-0-0-1:8180/request-path

and change it to:

alfresco.virtserver.domain=192-168-0-12.ip.alfrescodemo.net
* 192.168.0.12 is my LAN address, change accordingly.

That takes care of the Alfresco installation. One additional thing I must do since I'm installing on a windows environment :( I must run Jboss and the virtualization server as a windows service.

More on that.... on the next post!

Wednesday, December 12, 2007

Alfresco to manage my company's website content

So the story is as follows...

I was put in charge of setting an Enterprise Content Management (ECM) System with Web Content Management (WCM) capabilities to manage the content of my company's new website.

Initially, this release would be a 'brochure' (static content) website. In the future it may escalate to host dynamic content. Pretty simple and straightforward.

The catch? It had to be an Open Source solution.

Having played before with Alfresco it seems like a perfect fit. Once the HTML templates (developed by the Graphic Designer) are ready, they will be uploaded to Alfresco. Separation between content is a must, so Alfresco Web Forms will be used. This basically means well define an XML schema for content structure so Alfresco can render it as an HTML Form for user input, generating an XML file. Once the content is ready a transformation (XSL, FSLT) will be applied to produce HTML, Plain Text, etc. on the predefined folders of our website structure.

We'll take advantage of Alfresco's Sandboxed development. These means each of the users authoring content to the website will have their own sandbox to make and preview changes before submitting their modifications for review and later on, publish to the website.

Since my company's publishing work flow is simple, we'll used the predefined publishing work flows and roles Alfresco provides out of the box.

My company hosts it's website externally so we'll need to use Alfresco deployment capabilities. The problem is we cannot install this module in the hosting provider server, which by the way is only an HTTP server. WFTP access is our only way in, so I'll have to find a work around to solve these issue. More on this issue in the next posts.

I'm planning to give a more detailed overview of the tricky parts of the installation. I just wanted to give a brief overview of the latest task I have in my hands. Below is the software products I will be using. See you later!

Software Configuration:

  • alfresco-community-war-2.1.0

  • alfresco-community-wcm-2.1.0

  • alfresco-community-deployment-2.1.0

  • jboss-4.2.2.GA

  • jboss-native-2.0.1-windows-i686-ssl (to install jboss as a windows service)

  • MySQL 5.0

  • mysql-connector-java-5.1.5

  • OpenOffice.org 2.3.1 (for some transformations)

  • jdk-6u3-windows-i586-p

  • ImageMagick-6.3.7-3-Q16-windows-dll