cancel
Showing results for 
Search instead for 
Did you mean: 

FSR Prepare Callback feature not working correctly

rockycres
Champ in-the-making
Champ in-the-making
Hi all,

I am using FSR to deploy from files from alfresco.So when i deploy the files, I have written prepare callback hook which will validae the files and if validation fails I want to throw an exception and rollback the transaction.Prepare callback feature is suppose to this.But even when I throw deployment exception,it shows Deployment Successful message in Alfresco UI.
throw new DeploymentException(errorMsg);
Can anybody help me out on this..?
12 REPLIES 12

mrogers
Star Contributor
Star Contributor
Which service pack of 2.2 are you using?

rockycres
Champ in-the-making
Champ in-the-making
Hi rogers,

I am currently using Alfresco 3c stable version ..Any idea where it is getting wrong..?..If it got something do with the version,can u suggest which version Of Alfresco & FSR, I need to use to get this to work..

Thanks..

mrogers
Star Contributor
Star Contributor
The "official line" is that you need to match the versions of Alfresco with the deployment servers.    (Unofficially you may be able to get away with mix and match - but its not tested and may not work.)

There's no such release as "Alfresco 3C Stable"  Smiley Surprised

If you are using Labs 3 C then you need to get a newer version.
http://forums.alfresco.com/en/viewtopic.php?f=30&t=16281&p=53378

If you are using Labs 3 Stable.
I'm fairly confident that the prepare callback works correctly with regards to passing exceptions back.    In fact this is part of the unit tests.

Can you get the log output from the FSR which should tell us what is going on.   Even better if you can turn on debug logging for the FSR.

rockycres
Champ in-the-making
Champ in-the-making
Hi ,

Like u said I have downloaded the Alfresco (alfresco-labs-tomcat-3Stable.tar.gz ,alfresco-labs-wcm-3Stable.zip) && FSR (AlfrescoDeployLabs-3Stable-Linux-x86-Install)..

I have tried throwing the exception from prepare callback hook…and  still not able to  rollback the transaction..This s the log i m getting in FSR..but still getting deployment successful message in FSR..Eventhough the exceptions are thrown from callback,it continues to commit the transaction..u can clearly see from this log..


19:05:28,552 DEBUG [impl.server.DeploymentReceiverServiceImpl] begin of target:default
19:05:28,561 DEBUG [impl.server.DeploymentReceiverServiceImpl] begin deploy, target:default, ticket:c0d7f70a-da3e-44be-952f-1998f2cb1ed9
19:05:31,515 DEBUG [impl.server.DeploymentReceiverServiceImpl] commit ticket:c0d7f70a-da3e-44be-952f-1998f2cb1ed9
19:05:31,518 DEBUG [impl.server.DeploymentReceiverServiceImpl] starting deployment.
In PrepareCallback Hook:
org.alfresco.deployment.impl.DeploymentException
        at PrepareCallback.run(PrepareCallback.java:223)
        at org.alfresco.deployment.impl.server.Target.runPrepare(Target.java:620)
        at org.alfresco.deployment.impl.server.Deployment.prepare(Deployment.java:196)
        at org.alfresco.deployment.impl.server.DeploymentReceiverServiceImpl$CommitMetaClonerThread.run(DeploymentReceiverServiceImpl.java:930)
19:05:31,528 DEBUG [impl.server.DeploymentReceiverServiceImpl] metadata cloned and prepared
19:05:34,533 DEBUG [impl.server.DeploymentReceiverServiceImpl] committer thread finished normally
19:05:34,533 DEBUG [impl.server.DeploymentReceiverServiceImpl] committer thread finished normally
19:05:34,533 DEBUG [impl.server.DeploymentReceiverServiceImpl] committer thread finished normally
19:05:34,533 DEBUG [impl.server.DeploymentReceiverServiceImpl] committed - clean up
19:05:34,534 DEBUG [impl.server.DeploymentReceiverServiceImpl] commited successfully ticket:c0d7f70a-da3e-44be-952f-1998f2cb1ed9

mrogers
Star Contributor
Star Contributor
Thanks for the stack trace.   I've reviewed the Alfresco code and can't see an error.

Can you step through your FSR code with a debugger?     If not then raise an issue in JIRA.

rockycres
Champ in-the-making
Champ in-the-making
Hi mrogers,

I have tried also with Alfresco 3.1 trial version also,facing the same issue again,,
This is my jira ticket..
https://issues.alfresco.com/jira/browse/ALFCOM-2929..

Thanks,,,

rockycres
Champ in-the-making
Champ in-the-making
Hi rogers,

I have tried with Alfresco preview version,it is atleast rollback the transaction when the exception is thrown from callbacks but still custom error messages are not displayed.As u said in the below link,it may be working well in Alfresco 3.2,but we need this in 3.1 enterprise.Thanks..

https://issues.alfresco.com/jira/browse/ALFCOM-2929

rockycres
Champ in-the-making
Champ in-the-making
Hi rogers,

With the alfresco-deployment.jar,when we throw the deployment exception from callbacks,transaction is getting rollbacked,but still the error message we were sending is not displayed on the web-client.

Suppose,if we throw something like this from the prepare callback ,
  throw new DeploymentException("Custom error Message");
On the web-client ,instead of printing the custom error message, it is printing the default failure message like this,
"Failure during commit phase; rolled back."
Expected :Custom error Message
Actual:Failure during commit phase; rolled back.

In DeploymentReceiverServiceImpl.java,if u see  the method  commit(String ticket)

The catch block where exception thrown from prepare callback get caught,if we change the line from
throw new DeploymentException("Failure during commit phase; rolled back.", e);
to
throw new DeploymentException(e.getCause().getMessage());
it works perfectly & the error message we thrown from prepare callback hooks are displayed in the web-client.

The intention of having prepare callbacks is to rollback the transaction when something [custom code in prepare callbacks} goes wrong ,at the same time it makes sense when the user who deploys from the other side needs to be notified of the cause of the error.So plz consider this as a change & give us a patch for the community.Thanks.

catch (Exception e)
        {
            if (!recover(ticket, deployment))
            {
                logger.error("Failure during commit phase; rolled back.", e);
                throw new DeploymentException("Failure during commit phase; rolled back.", e);
            }
        }


catch (Exception e)
        {
            if (!recover(ticket, deployment))
            {
               logger.error("Failure during commit phase; rolled back.", e);
                throw new DeploymentException(e.getCause().getMessage());
            }
        }

mrogers
Star Contributor
Star Contributor
Thanks for your confirmation that the roll-back happens in 3.2 community.  That confirms what I saw myself.

I also tested this on 3.1 E and it rolled back.   Can you confirm whether the rollback occurs on your version of  3.1.   It may be that you need a service pack or there may be some subtle problem that we have yet to home in on.

But so far I've never been able to reproduce the problem first posted in the JIRA ticket. 

I'll treat the UI message message as a separate issue.