In sdk-3 how to test a customized class

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

In sdk-3 how to test a customized class


I have a platform module,i try to update it to sdk-3 but can't test it on the maven build (only on maven), it work on "real" alfresco server.

i have a need to customise an existing alfresco java class (well i did'nt find any other way). On sdk-2 i could test it with the "virtualClasspath" and "searchVirtualFirst=true" but in sdk-3 it's said we don't need it, but i don't understand how to do it !

The module DO work, if i (simply) copy the jar file on an existing alfresco instance in a VM it work.On sdk-2 it work to.

But if i try it with sdk-3 the class used seem to be the original alfresco...

i try with hotswapagent (extraclasspath) and without but whatever is new class do work flawessly with a simple "mvn compile", but not the customized class. I did a lot "googleling" but find nothing.

Do someone know how to be sure a custom class can be read priorisise an existing class on maven sdk-3 ?

note: i too try to make it in amp and not an jar, same think...

8 Replies
Advanced II

Re: In sdk-3 how to test a customized class


You will have to share more information in order to get any useful response from the community.

What exactly are you trying to test?

Member II

Re: In sdk-3 how to test a customized class

i have an maven all in one project,

in this project i have a module with a modified class (alfresco java class).

if i run the project with the sdk-3 maven create a jar archive who is with the unpackaged platform war, so it is not compatible with the "true" jar of alfresco.

for exemple if i manualy rename the jar on aa-module it work (read before in linux). and in 'production' i can choose the tomcat classpath so it's okay.

on sdk-2 we could use the context-repo.xml of runner and change "virtualClasspath", on sdk-3 we can't.

hope it's clearer, i'm sorry i'm not fluent in english.

Advanced II

Re: In sdk-3 how to test a customized class

So, if I understood it well, what you have is a problem with the order the jar file is loaded?

But why does that import to you? If you are extending a OOTB class, then you should be using the extension mechanism to "replace" the implementation class for you, and not try to ovewrite the jar file.

I am just trying to give you some idea, but I am afraid I could not understand your problem exactly.

Member II

Re: In sdk-3 how to test a customized class

Well i'm not sure what you call "extension mechanism", may be i don't do it correctly ?

For this module i change the bean who do the labelpolicy , i have this :

<bean id="serialVersionLabelPolicy" class="xx.xx.xx.updated.UpdatedVersionLabelPolicy"  />

is that what you implit ?

What i do is extend the update mecanisme of the node with a public ScriptNode checkin(String history, boolean majorVersion, String customLabel) function.

basicly what i shoud do is to say 'don't use scriptnode use MY scriptnode implementation' but i don't know how to

thank for the help

Advanced II

Re: In sdk-3 how to test a customized class

Ok, that is exactly what I wanted to understand.

Please, share here the name of the context.xml file you are using to define that bean, the path you are using, and also, the full bean configuration.

Member II

Re: In sdk-3 how to test a customized class

well... there is no context bean for ScriptNode and that what not working...


<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns=""

<!-- import du modèle pour l'envoi de message -->
<bean id="${project.artifactId}_dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
<property name="models">
<!-- <property name="labels">
</property> -->

<!-- remplace la classe par defaut de la gestion des versions -->
<!-- apparement il ne peut y avoir qu'un seul "versionLabel" donc on le change -->
<bean id="serialVersionLabelPolicy" class="fr.gouv.dgfip.venezia.updated.UpdatedVersionLabelPolicy" />


and webscript-context.xml

<?xml version='1.0' encoding='UTF-8'?>
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.
<beans xmlns=""

<bean id="updated-utils" parent="baseJavaScriptExtension" class="fr.gouv.dgfip.venezia.updated.UpdatedUtils">
<property name="extensionName" value="updatedUtils" />
<property name="behaviourFilter" ref="policyBehaviourFilter" />
<property name="nodeService" ref="nodeService" />
<property name="permissionService" ref="permissionService" />

<!-- script downloadSite -->
<bean id="webscript.updated.downloadFile.get"
<property name="repository" ref="repositoryHelper" />
<property name="serviceRegistry" ref="ServiceRegistry" />
<property name="contentService" ref="contentService" />


if i use the "normal" api/upload i see that the serialVersion do work :

[renaud] $ curl --noproxy renoven2 -k -u admin:admin -X POST -F filedata=@a -F "overwrite=true" -F "uploaddirectory=/" -F "siteId=topinenbourg" -F "containerid=documentLibrary" "http://localhost:8080/alfresco/service/api/upload"
"nodeRef": "workspace://SpacesStore/7a2d1bf3-57bb-44bc-9d1a-478ddf835ebf",
"fileName": "a",
"code": 200,
"name": "OK",
"description": "File uploaded successfully"

and in the log :

2017-09-07 10:25:09,831 DEBUG [venezia.updated.UpdatedVersionLabelPolicy] [http-bio-8080-exec-9] * updated version label policy : action *
2017-09-07 10:25:09,831 DEBUG [venezia.updated.UpdatedVersionLabelPolicy] [http-bio-8080-exec-9] * updated version label policy : valeur du custom label = null *
2017-09-07 10:25:09,832 DEBUG [venezia.updated.UpdatedVersionLabelPolicy] [http-bio-8080-exec-9] * updated version label policy : ancien version label *
2017-09-07 10:25:09,832 DEBUG [venezia.updated.UpdatedVersionLabelPolicy] [http-bio-8080-exec-9] * updated version label policy : application du mineur *
2017-09-07 10:25:09,832 DEBUG [venezia.updated.UpdatedVersionLabelPolicy] [http-bio-8080-exec-9] * updated version label policy : valeur résultante 1.1 *

so the serialVersion do work

if i use my update it fail :

[renaud] $ curl --noproxy renoven2 -k -u admin:admin -X POST -F filedata=@a -F "overwrite=true" -F "uploaddirectory=/" -F "siteId=topinenbourg" -F "containerid=documentLibrary" -F "author=rl" -F "customLabel=3.2" "http://localhost:8080/alfresco/service/updated/upload"
"status" :
"code" : 500,
"name" : "Internal Error",
"description" : "An error inside the HTTP server which prevented it from fulfilling the request."

"message" : "08070003 Unexpected error occurred during upload of new content.",
"exception" : "",

"callstack" :


"server" : "Community v5.2.0 (re21f2be5-b22) schema 10 057",
"time" : "7 sept. 2017 10:35:48"

and the log said

2017-09-07 10:35:48,138 DEBUG [venezia.updated.UpdatedUtils] [http-bio-8080-exec-8] *** : authoring, disabled behaviour
2017-09-07 10:35:48,171 DEBUG [venezia.updated.UpdatedUtils] [http-bio-8080-exec-8] ** : checkout file
2017-09-07 10:35:48,178 DEBUG [venezia.updated.UpdatedUtils] [http-bio-8080-exec-8] ** : write content

2017-09-07 10:35:48,179 DEBUG [venezia.updated.UpdatedUtils] [http-bio-8080-exec-8] ** : metadata extracted
2017-09-07 10:35:48,179 DEBUG [venezia.updated.UpdatedUtils] [http-bio-8080-exec-8] ** : checkin of file

2017-09-07 10:35:48,185 ERROR [extensions.webscripts.AbstractRuntime] [http-bio-8080-exec-8] Exception from executeScript: 08070003 Unexpected error occurred during upload of new content.
org.springframework.extensions.webscripts.WebScriptException: 08070003 Unexpected error occurred during upload of new content.
at org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(
at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(
at org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(
at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(
at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(
at org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(
at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(
at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(
at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(
at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.tomcat.websocket.server.WsFilter.doFilter(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.valves.AccessLogValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.AbstractHttp11Processor.process(
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$
Caused by: org.mozilla.javascript.JavaScriptException: InternalError: Unexpected error occurred during upload of new content. (classpath*:alfresco/extension/templates/webscripts/updated/
at org.mozilla.javascript.gen.classpath__alfresco_extension_templates_webscripts_updated_upload_post_js_5._c_main_4(classpath*:alfresco/extension/templates/webscripts/updated/
at org.mozilla.javascript.optimizer.OptRuntime.callName0(
at org.mozilla.javascript.gen.classpath__alfresco_extension_templates_webscripts_updated_upload_post_js_5._c_script_0(classpath*:alfresco/extension/templates/webscripts/updated/
at org.mozilla.javascript.ContextFactory.doTopCall(
at org.mozilla.javascript.ScriptRuntime.doTopCall(
at org.mozilla.javascript.gen.classpath__alfresco_extension_templates_webscripts_updated_upload_post_js_5.exec(classpath*:alfresco/extension/templates/webscripts/updated/
at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(
at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(
at org.alfresco.repo.processor.ScriptServiceImpl.execute(
at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(
at org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(
at org.springframework.extensions.webscripts.AbstractWebScript.executeScript(
at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(
... 32 more

the line here "*** : authoring, disabled behaviour" mean it do this function :

updatedUtils.log("*** : authoring, set properties on file and disable behaviour");

so my "updatedUtils" function do work, but not the checkin wich is :

updatedUtils.log("** : checkin of file");
existingFile = existingFile.checkin(description, majorVersion, customLabel); <- this fails

wich is defined in ScriptNode

if i do rename the jar (and mvn alfresco:run) :

[renaud] $ cp target/tomcat/webapps/plugins-alfresco-platform/WEB-INF/lib/updated-platform-jar-1.1-SNAPSHOT.jar target/tomcat/webapps/plugins-alfresco-platform/WEB-INF/lib/aa-updated-platform-jar-1.1-SNAPSHOT.jar

i don't have the problems :

[renaud] $ curl --noproxy renoven2 -k -u admin:admin -X POST -F filedata=@a -F "overwrite=true" -F "uploaddirectory=/" -F "siteId=topinenbourg" -F "containerid=documentLibrary" -F "author=rl" -F "customLabel=3.2" "http://localhost:8080/alfresco/service/updated/upload"
"nodeRef": "workspace://SpacesStore/7a2d1bf3-57bb-44bc-9d1a-478ddf835ebf",
"fileName": "a",
"code": 200,
"name": "OK",
"description": "File uploaded successfully"

basicly the problem is i need to surcharge the org.alfresco.repo.jscript.ScriptNode and i have no way to override it "easyly"

well, the sdk-3 is probably  to new for now and none has this problems for now.

I use a awfuly wrong to resolve, i use a fake plugin juste for renaming the jar (worst solution ever, lol)

part of local-share-jar/pom.xml

<!-- test pour ajout dans le rep -->
<mkdir dir="${targetPlatform}"/>
<copy file="${pluginRep}/oic-platform-jar/target/oic-platform-jar-1.1-SNAPSHOT.jar" tofile="${targetPlatform}/aa1-oic-platform-jar-1.1-SNAPSHOT.jar"/>
<copy file="${pluginRep}/updated-platform-jar/target/updated-platform-jar-1.1-SNAPSHOT.jar" tofile="${targetPlatform}/aa2-updated-platform-jar-1.1-SNAPSHOT.jar"/>
<mkdir dir="${targetShare}"/>
<copy file="${pluginRep}/oic-share-jar/target/oic-share-jar-1.1-SNAPSHOT.jar" tofile="${targetShare}/aa1-oic-share-jar-1.1-SNAPSHOT.jar"/>
<copy file="${pluginRep}/updated-share-jar/target/updated-share-jar-1.1-SNAPSHOT.jar" tofile="${targetShare}/aa2-updated-share-jar-1.1-SNAPSHOT.jar"/>
<copy file="${pluginRep}/venezia-share-jar/target/venezia-share-jar-1.1-SNAPSHOT.jar" tofile="${targetShare}/aa0-venezia-share-jar-1.1-SNAPSHOT.jar"/>

thank for the help, i will do this for now until i found a better way...

Advanced II

Re: In sdk-3 how to test a customized class

What do you have in the line 917 in the file alfresco/extension/templates/webscripts/updated/ ?

Member II

Re: In sdk-3 how to test a customized class

just the catch of the try :

} catch (e) {
// NOTE: Do not clean formdata temp files to allow for retries. It's possible for a temp file
// to remain if max retry attempts are made, but this is rare, so leave to usual temp
// file cleanup.

// capture exception, annotate it accordingly and re-throw
if (e.message && e.message.indexOf("AccessDeniedException") != -1) {
e.code = 403;
else if (e.message && e.message.indexOf("org.alfresco.service.cmr.usage.ContentQuotaException") == 0) {
e.code = 413;
} else if (e.message && e.message.indexOf("org.alfresco.repo.content.ContentLimitViolationException") == 0) {
e.code = 409;
} else {
e.code = 500;
e.message = "Unexpected error occurred during upload of new content.";
throw e;
} <-------- ligne 917