cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco share java backed webscript not working.

dynamolalit
Champ on-the-rise
Champ on-the-rise
Hi,

I have created a webscript for share which is javascript based as attached @ https://issues.alfresco.com/jira/browse/ALF-20915 & it is working fine as expected.I can call it @ http://localhost:8080/share/page/com/acc/search/fed/iwFedSearch?keyword={keyword} & it works fine providing me siteId variable i set in controller.

Next i planned to use java controller instead of javascript where in java business logic, i am calling solr for search. I have created custom-slingshot-context.xml for same along with all other files(also attached @ https://issues.alfresco.com/jira/browse/ALF-20915).

While i am trying to invoke java backed webscript using  same url @ http://localhost:8080/share/page/com/acc/search/fed/iwFedSearch?keyword={keyword}, i am getting below error in browser.

<blockquote>
{
    "status" :
  {
    "code" : 500,
    "name" : "Internal Error",
    "description" : "An error inside the HTTP server which prevented it from fulfilling the request."
  }, 
 
  "message" : "03080023 Failed to process template ie\/iw\/components\/search\/fed\/iwFedSearch.get.json.ftl", 
  "exception" : "org.springframework.extensions.webscripts.WebScriptException - 03080023 Failed to process template ie\/iw\/components\/search\/fed\/iwFedSearch.get.json.ftl",
 
  "callstack" :
  [
       ""      ,"freemarker.core.InvalidReferenceException: Expression siteId is undefined on line 1, column 30 in ie\/iw\/components\/search\/fed\/iwFedSearch.get.json.ftl."
      ,"freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125)"

</blockquote>


After much of head scratching, concluded that it is not able to call java controller where i am using declarative webscript to set model variable where i am setting siteId. As it is not able to invoke java controller, it regards siteId as undefined.

Can anybody help?
7 REPLIES 7

kaynezhang
World-Class Innovator
World-Class Innovator
In order for java controller to be called ,you must follow naming convention for the bean id attribute of the Spring bean ,you can refer to http://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples

dynamolalit
Champ on-the-rise
Champ on-the-rise
Thanks Kay,

I went thru url you referred but it is a bit outdated. Also i got to know that my share webscript is not able to call java controller creating the issue.

Any idea?

Regards.

I observed that alfresco does not support this kind of architecture in regards of share/alfresco communication. For such communication, share needs to have javascript based webscript controller calling alfresco repository using either remote.connect(…) or alfresco.util.ajax(…) methods returning json response. Currently it does not support java backed webscript controller in share for webscripts.

Bottom line is - for every call, share depends on alfresco repo using javascript backed webscript.

jpotts
World-Class Innovator
World-Class Innovator
This is not accurate. Share is full of Java-backed web scripts. I have personally written Java-backed web scripts on the Share tier so I know it is possible. You probably have a problem in your context file as was suggested earlier.

Jeff

g_rathod
Star Contributor
Star Contributor
Hi dynamolalit,

Can you post your code as well file name you have used? that will help us to clear the issue.

hemant1147
Champ in-the-making
Champ in-the-making
Hi Jeff,

I am facing problem while calling java backed web script for share.
my custom-slingshot-application-context file contains


<bean id="webscript.com.example.pages.javadir.get"
      class="org.example.JavaDir" parent="webscript">   
  <property name="repository">
            <ref bean="repositoryHelper"/>
            </property>       
        </bean>


Its showing exception that NoSuchBeanDefinitionException: No bean named 'repositoryHelper' is defined.
I don't know this is valid way to call java backed web script or not.
If this is not valid can you please suggest some post or link for java backed web script for share.

jpotts
World-Class Innovator
World-Class Innovator
That bean, repositoryHelper, is in the alfresco.war, not the share.war file. You cannot have a context file in share that references a bean in a completely different web application.

Other than that, your bean declaration for your Java-backed web script looks fine.

Jeff
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.