cancel
Showing results for 
Search instead for 
Did you mean: 

Create Java back webscript in share extesion project

djaweid_
Champ in-the-making
Champ in-the-making
Hi All,

I am new with alfresco. I have created a share extension where I want to create a Java backed webscript.

I used https://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples to create Java backed webscript.


Add the following bean in custom-slingshot-application-context.xml

<bean id="webframework.store.webscripts.custom" class="org.alfresco.web.scripts.ClassPathStore">

      <property name="mustExist"><value>true</value></property>

      <property name="classPath"><value>config/alfresco/web-extension/site-webscripts</value></property>

</bean>


http://127.0.0.1:8081/share/service/com/retreive-data/simple


I get the following error:

retreive-data-share/target/amp-war/WEB-INF/lib/retreive-data-share-1.0-SNAPSHOT.jar!/alfresco/web-extension/custom-slingshot-application-context.xml]; nested exception is java.lang.ClassNotFoundException: org.alfresco.web.scripts.ClassPathStore

Caused by: java.lang.ClassNotFoundException: org.alfresco.web.scripts.ClassPathStore

/src/main/amp/config/alfresco/web-extension/site-webscripts/com/retreive-data/simple.get.desc.xml

<webscript>
  <shortname>The World's Simplest Webscript</shortname>
  <description>Hands back a little bit of JSON</description>
  <url>/com/tenthline/retreive-data/simple</url>
  <authentication>none</authentication>
  <format default="">argument</format>
  <family>Alfresco Java-Backed WebScripts Demo</family>
</webscript>


/src/main/amp/config/alfresco/web-extension/site-webscripts/com/retreive-data/simple.get.json.ftl

<#escape x as jsonUtils.encodeJSONString(x)>

{

   "field1": "${field1}"

}

</#escape>



And also the there are xml files, I dont know where could I use them for Java Backed webscript

/src/main/amp/config/alfresco/web-extension/monitor-websites-share-slingshot-application-context.xml

/src/main/resources/alfresco/web-extension/custom-slingshot-application-context.xml

/src/main/resources/alfresco/web-extension/share-config-custom.xml.sample

/src/main/resources/META-INF/share-config-custom.xml.sample

Thanks advance for your help

dj

1 ACCEPTED ANSWER

jpotts
World-Class Innovator
World-Class Innovator

Your class looks fine, so it must be the Spring context file that is not correct.

I suspect it is your bean ID. As it says in my tutorial, the syntax for the bean ID is:

webscript.package.service-id.method

But yours is "webscript.sudo". Alfresco has no way of knowing which web script you intend to use that class with unless that ID follows the convention. You need to change it to:

webscript.sudo.sudorename.get

Be sure to restart Alfresco after that change.

View answer in original post

10 REPLIES 10

Hi mit patoliya​,

Yes that I understand and have since put a freemarker check on the ftl. No the issue is getting the java class called. What could be the cause of the class not to be called?