Hello
I am running a community edition All-In-One (AIO) project for SDK 4.0 (alfresco.platform.version: 6.2.0-ea).
I have a webscript that calls for a new dependency to deserialize LocalDateTime - jackson-datatype-jsr310.
I have added it to the platform project pom.xml initially:
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.7</version>
</dependency>
</dependencies>
This worked locally on my machine where the JAR is downloaded to the .m2 folder. However, when I later build the project Docker image in teamcity and run it in another environment, I get a ClassNotFoundException: com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in the webscript class that uses the jar. This leads to the conclusion that the JAR is not included in the docker image.
I get the sense that I need to create an AMP for this to happen and have tried to follow along with official tutorials, but attempts have been futile and for some reason Maven attempts to retrieve the jar from https://artifacts.alfresco.com/nexus/content/groups/private.
Which steps do I need to take? Please explain precisely which modifications I must make which files for this particular jar. It's a bit confusing to me that there's multiple POM files involved.
@jecbm wrote:
Hello
I am running a community edition All-In-One (AIO) project for SDK 4.0 (alfresco.platform.version: 6.2.0-ea).
I have a webscript that calls for a new dependency to deserialize LocalDateTime - jackson-datatype-jsr310.
I have added it to the platform project pom.xml initially:<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.7</version>
</dependency>
</dependencies>
This worked locally on my machine where the JAR is downloaded to the .m2 folder. However, when I later build the project Docker image in teamcity and run it in another environment, I get a ClassNotFoundException: com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in the webscript class that uses the jar. This leads to the conclusion that the JAR is not included in the docker image.I get the sense that I need to create an AMP for this to happen and have tried to follow along with official tutorials, but attempts have been futile and for some reason Maven attempts to retrieve the jar from https://artifacts.alfresco.com/nexus/content/groups/private.
Which steps do I need to take? Please explain precisely which modifications I must make which files for this particular jar. It's a bit confusing to me that there's multiple POM files involved.
You can copy a jar file into $TOMCAT_HOME/webapps/alfresco/WEB-INF/lib using docker exec tool. However, it is not the correct approach, as if you terminate the containers the changes will be lost. However here is the step to do it fyi:
docker exec -it <nameOrIdOfContainer> /bin/bash example: docker exec -it alfresco_1 /bin/bash or docker exec -it 028 /bin/bash Where name of the container is: alfresco and container id: 0282bf706a57
docker cp C:\jackson-datatype-jsr310-2.9.7.jar 0282bf706a57:/usr/local/tomcat/webapps/alfresco/WEB-INF/lib
The right way is to use. DockerFile and docker-compose.yml to build custom image will all the changes and launch the custom image.
You can find the steps here on how to deploy third party jars/amps etc here: https://github.com/Alfresco/acs-community-deployment/issues/131#issuecomment-691300550
Your DockerFile would look something like, highlighted the lines which will deploy jars and amps to repo:
FROM alfresco/alfresco-content-repository-community:6.2.1-A8 #Change to root USER root # Copy extensions jar module if there are any COPY Dockerfile extensions/*.jar $TOMCAT_DIR/webapps/alfresco/WEB-INF/lib/ # Copy and apply amp extensions COPY Dockerfile extensions/*.amp $TOMCAT_DIR/amps/ RUN java -jar $TOMCAT_DIR/alfresco-mmt/alfresco-mmt*.jar install \ $TOMCAT_DIR/amps $TOMCAT_DIR/webapps/alfresco -directory -nobackup -force #Change back to alfresco USER alfresco
Example of docker-compose.yml:
alfresco: build: dockerfile: ./Dockerfile context: ./build-config/alfresco mem_limit: 1500m environment: JAVA_OPTS: " -Ddb.driver=org.postgresql.Driver -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.url=jdbc:postgresql://postgres:5432/alfresco -Dsolr.host=solr6 -Dsolr.port=8983 -Dsolr.secureComms=none -Dsolr.base.url=/solr -Dindex.subsystem.name=solr6 -Dshare.host=127.0.0.1 -Dshare.port=8080 -Dalfresco.host=localhost -Dalfresco.port=8080 -Daos.baseUrlOverwrite=http://localhost:8080/alfresco/aos -Dmessaging.broker.url=\"failover:(nio://activemq:61616)?timeout=3000&jms.useCompression=true\" -Ddeployment.method=DOCKER_COMPOSE -DlocalTransform.core-aio.url=http://transform-core-aio:8090/ -Dalfresco-pdf-renderer.url=http://transform-core-aio:8090/ -Djodconverter.url=http://transform-core-aio:8090/ -Dimg.url=http://transform-core-aio:8090/ -Dtika.url=http://transform-core-aio:8090/ -Dtransform.misc.url=http://transform-core-aio:8090/ -Dcsrf.filter.enabled=false -Xms1500m -Xmx1500m "
You third party jars will reside in this directory named: "extensions" (see the steps above)
You can follow same approach for share as well.
You can find an example here: https://github.com/abhinavmishra14/enable-cors-acs-demo
https://github.com/abhinavmishra14/enable-cors-acs-demo/blob/master/build-config/alfresco/Dockerfile
https://github.com/abhinavmishra14/enable-cors-acs-demo/blob/master/docker-compose.yml
Thank you for the detailed answer. So you'd have to manually download the jar and place them it the /extension folder? I would have assumed Maven+AMP could do this for me?
yes if you are using sdk to build your custom amps you could add the dependency in the pom file and just deploy the amps. Add the dependency in <customModule>-platform-docker/pom.xml and build. Post build check if you see the jar under: "<customModule>-platform-docker\target\extensions" directory. if you see then that is first level of verification that jar is available in your custom image. If you still see the error, try looking for the jar under the alfresco container $TOMCAT_HOME/webapps/WEB-INF/lib
If you are trying to deploy the jar individually to the alfresco repo war then you would have to download and copy it.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.