cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Share - Develop a webscript in JAVA

allen87
Champ in-the-making
Champ in-the-making
Hi everybody,

I would try to create a new webscript in JAVA not in Javascript only in Alfreso Share.
I try to refer to the link below :
http://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples

and especially about the locations files in Share :
.jar file in <tomcat>/webapps/share/WEB-INF/lib or .class files in <Alfresco>/tomcat/webapps/alfresco/WEB-INF/classes/<class folder structure>
web-scripts-application-context.xml - <tomcat>/webapps/share/WEB-INF/classes/org/springframework/extensions/webscripts
simple.get.desc.xml - <tomcat>/webapps/share/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/demo

I realize that when I connect to the URL http://localhost:8080/share/service/index , I can't find again a new webscript in the list.

Could someone give me more informations ?

Thanks so much for your help.
25 REPLIES 25

allen87
Champ in-the-making
Champ in-the-making
Is anyone there to develop a webscript in Alfresco Share ?

allen87
Champ in-the-making
Champ in-the-making
Hi,

I have a jar file SimpleWebScript.jar in the folder "tomcat/webapps/share/WEB-INF/lib" where there's the JAVA class org.alfresco.module.demoscripts.SimpleWebScript.java with the following code :
    public class SimpleWebScript extends DeclarativeWebScript {       public SimpleWebScript() {                 }              protected Map<String, Object> executeImpl(WebScriptRequest req,             Status status) {          Map<String, Object> model = new HashMap<String, Object>();          model.put("hello", "Hello World");          return model;       }    }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

and then a file "simple.get.desc.xml" (in the folder tomcat/webapps/share/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/demo) :
    <webscript>      <shortname>The World's Simplest Webscript</shortname>      <description>Hands back a little bit of JSON</description>      <url>/demo/simple</url>      <authentication>none</authentication>      <format default="">argument</format>    </webscript>‍‍‍‍‍‍‍‍‍

and to finish, the file "simple.get.html.ftl" (in the folder tomcat/webapps/share/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/demo) :
    <html>       <head>          <title>Hello World</title>       </head>       <body>          ${hello}       </body>    </html>‍‍‍‍‍‍‍‍‍‍

Thanks for your help.

allen87
Champ in-the-making
Champ in-the-making
And i created a new file web-scripts-application-context.xml in the folder tomcat/webapps/share/WEB-INF/classes/org/springframework/extensions/webscripts :
<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN 2.0//EN' 'http://www.springframework.org/dtd/spring-beans-2.0.dtd'><beans>      <bean id="webscript.org.alfresco.demo.simple.get" class="org.alfresco.module.demoscripts.SimpleWebScript" parent="webscript" /></beans>‍‍‍‍‍‍‍‍

Thanks you.

need
Champ in-the-making
Champ in-the-making
Hi,

i have the same problem, the documentation is not very clear by this argument.

In my tomcat log say Class java.lang.ClassNotFoundException: org.alfresco.module.demoscripts.SimpleWebScript. Don't found class. Where i registering the bean?

you work?

Thanks.

allen87
Champ in-the-making
Champ in-the-making
Try to put your jar in the folder tomcat/webapps/share/WEB-INF/lib.

Have you ever developed a webscript in JAVA ?

Thanks.

need
Champ in-the-making
Champ in-the-making
Hi, thanks for the reply.

Yes the jar file called JavaBeckedWebScript.jar is in tomcat/webapps/share/WEB-INF/lib, but not foundclass.

Thanks.

allen87
Champ in-the-making
Champ in-the-making
If you followed what i wrote in my last messages, you don't get a classnotfound.

need
Champ in-the-making
Champ in-the-making
Hi,

you can show me your build.xml file?

Thanks.

allen87
Champ in-the-making
Champ in-the-making
Build.xml

<?xml version="1.0"?><project name="Sample Module" default="package-amp" basedir=".">   <property name="project.dir" value="." />   <property file="${project.dir}/build.properties" />   <property name="build.dir" value="${project.dir}/build" />   <property name="config.dir" value="${project.dir}/config" />   <property name="jar.file" value="${build.dir}/lib/SimpleWebScript.jar" />   <target name="mkdirs">      <mkdir dir="${build.dir}/dist" />      <mkdir dir="${build.dir}/lib" />      <mkdir dir="${build.dir}/classes" />   </target>   <path id="class.path">      <dirset dir="${build.dir}" />      <fileset dir="${project.dir}/lib" includes="**/*.jar" />   </path>   <target name="clean">      <delete dir="${build.dir}" />   </target>   <target name="compile" depends="mkdirs">      <javac classpathref="class.path" debug="${debug}" srcdir="${project.dir}/src/org/alfresco/module/demoscripts" destdir="${build.dir}/classes" target="1.5" encoding="UTF-8" />      <copy todir="${build.dir}/classes">         <fileset dir="${project.dir}/src/org/alfresco/module/demoscripts" defaultexcludes="false">            <exclude name="**/*.java" />            <exclude name="**/.svn/**" />            <exclude name="**/CVS/**" />         </fileset>         <fileset dir="${project.dir}/src/org/alfresco/module/demoscripts" defaultexcludes="false">                     <exclude name="**/*.java" />                     <exclude name="**/.svn/**" />                     <exclude name="**/CVS/**" />         </fileset>      </copy>   </target>   <target name="package-jar" depends="compile">      <jar destfile="${jar.file}" encoding="UTF-8">         <fileset dir="${build.dir}/classes" excludes="**/custom*,**/*Test*" defaultexcludes="false" />      </jar>   </target>   <target name="package-amp" depends="package-jar" description="Package the Module">   </target></project>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

This code create a jar called /build/lib/SimpleWebScript.jar
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.