Deploying JAR to alfresco server

cancel
Showing results for 
Search instead for 
Did you mean: 
user44m
Member II

Deploying JAR to alfresco server

Hi,

I followed this guide: https://ecmarchitect.com/alfresco-developer-series-tutorials/maven-sdk/tutorial/tutorial.html to successfully create a maven project to run it on Docker. I created a simple worklflow that checks if a documentation is valid. 

Now I wanted to create a Listener which will trigger after some step is completed I added this code to my process.bpmn20.xml:

<activiti:taskListener event="complete" class="com.someco.platformsample.CompleteListener"></activiti:taskListener>

Then i created a CompleteListener class:

Logger logger = Logger.getLogger(CompleteListener.class);
@override
public void notify(DelegateTask delegateTask){
// TODO Auto-generated method stub
System.out.println(delegateTask.getId());
System.out.println(delegateTask.getEventName());
System.out.println(delegateTask.getOwner());
System.out.println(delegateTask.getDescription());
logger.info(delegateTask.getId());
LocalDateTime myDateObj = LocalDateTime.now();
System.out.println("Before formatting: " + myDateObj);
DateTimeFormatter myFormatObj = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");

String formattedDate = myDateObj.format(myFormatObj);
System.out.println("After formatting: " + formattedDate);
System.out.println(formattedDate);

try {
callApi();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

When i redeployed the project and tried it out it didn't work - nothing happened. I then read somewhere you need to export the listener class (in this case CompleteListener.java) as a JAR and deploy it in /usr/local/tomcat/webapps/alfresco/WEB-INF/lib/. 

Now I have a running docker container which has two images: alfresco-content-services-maven-sdk-tutorial and alfresco-share-sdk-tutorial. To be honest I didn't use Docker before and i am pretty lost. However i inspected both images and saw that alfresco-content-services-maven-sdk-tutorial has the /usr/local/tomcat/webapps/alfresco/WEB-INF/lib/ folder so I guess I have to deploy the JAR here. Can someone explain to me how this can be done? Once again the end result should be that the CompleteListener is deployed on the server and that the workflow will recognize it and trigger the code I have in the class - which will Log something to me.

2 Replies
user44m
Member II

Re: Deploying JAR to alfresco server

To add on top of this I found a similar question asked here: https://stackoverflow.com/questions/15896416/alfresco-activiti-new-workflow-add.  Hower i don't seem to understand, do i need to get the whole jar of the whole project (with platform, share and both dockers) or only that one class. And when I use command : 

docker build -t alfresco-content-services-maven-sdk-tutorial -f AddListener.DockerFile . --no-cache

Where alfresco-content-services-maven-sdk-tutorial is an Image and AddListener.DockerFile is a dockerFile which contains code to COPY file to /usr/local/tomcat/webapps/alfresco/WEB-INF/lib/ . All that does is it builds me another image, but it seems its not used when i redeploy the project... So what am I doing wrong here.. ?

abhinavmishra14
Advanced

Re: Deploying JAR to alfresco server

Are you using sdk for your development ? if yes which version of SDK ?

For docker based deployment you should be using SDK4.1 and if you are already using it, you don't have to do all these steps that you are trying. 

Check this project here from the same tutorial: https://github.com/jpotts/alfresco-developer-series/tree/master/workflow/workflow-tutorial

Suppose you are creating your workflow in platform project e.g. https://github.com/jpotts/alfresco-developer-series/tree/master/workflow/workflow-tutorial/workflow-... ,

All you need to do is that execute run.bat/run.sh script. 

e.g.

run.bat build_start
or
run.sh build_start

It will launch all the containers with updated extensions locally on your docker desktop environment.

 

If you have a server setup that is not based on docker deployments, then you have to copy your platform-extensions (amps, jars)  to the server under $TOMCAT_HOME/webapps/alfresco/WEB-INF/lib and share-extensions (amps, jars) under $TOMCAT_HOME/webapps/share/WEB-INF/lib

Note, that with this approach all your copied extensions will be lost if you terminate your containers.

These threads may also be helpful:

https://hub.alfresco.com/t5/alfresco-content-services-forum/deploy-amp-or-jar-into-dockerized-alfres...

https://hub.alfresco.com/t5/alfresco-content-services-forum/alfresco-6-deploy-jar/m-p/154184#M8812

If your server is docker containers based, then i would suggest to make use of DockerFile and docker-compose.yml in combination and launch your server. It will build the updated images with your custom extensions and launch all the services as configured in docker-compose.yml.

 

Check the steps here if you want to persue DockerFile and docker-compose based approach:

https://github.com/Alfresco/acs-community-deployment/issues/131#issuecomment-691300550

 

 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)