Can't reach my java code backend Webscript

cancel
Showing results for 
Search instead for 
Did you mean: 
4535992
Senior Member

Can't reach my java code backend Webscript

Jump to solution

Hi, i don't know why  this error keep return to me i just create a java class webscript,

repo-amp/src/main/java/my/stupid/alfresco/webscripts/GetPropertiesAlfrescoWebscript.java

****************************************************************************************************************

package my.stupid.alfresco.webscripts;

.....

public class GetPropertiesAlfrescoWebscript extends AbstractWebScript{
    
    
    private static Log logger = LogFactory.getLog(GetPropertiesAlfrescoWebscript.class);
    
    private AuthenticationService authenticationService;
    private SearchService searchService;
    private NodeService nodeService;
    private ContentService contentService;
    
    @Override
    public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
        logger.debug("START GetPropertiesAlfrescoWebscript");
        String PARAM_SEARCH_PARAMETER = req.getParameter("searchParameter");
        logger.debug("PARAMETER=["+PARAM_SEARCH_PARAMETER+"]");
        try{    
            if(post=="TICKET"){
                
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("ticket", authenticationService.getCurrentTicket());
                logger.debug("GET "+GET_METHOD.TICKET.name()+ "="+jsonObject.toString());
                res.getWriter().write(jsonObject.toString());                    
            }else{
                logger.warn("XXXXXXXXXXXXXXXXXXXX");
            }                
        }catch(Throwable ej){
            throw new IOException(ej);
        }
        logger.debug("END 2 PostPropertiesWebscript");
    }

    public void setAuthenticationService(AuthenticationService  authenticationService) {
        this.authenticationService =  authenticationService;
    }

    public void setSearchService(SearchService searchService) {
        this.searchService = searchService;
    }

    public void setNodeService(NodeService nodeService) {
        this.nodeService = nodeService;
    }

    public void setContentService(ContentService contentService) {
        this.contentService = contentService;
    }
}

*************************************************************************************************

So i build my bean on the service-context.xml file (or any <file>-context.xml) loaded from the module-context.xml of alfresco

repo-amp/src/main/amp/config/alfresco/module/repo-amp/context/service-context.xml

****************************************************************************************************************

<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

   

          <bean id="webscripts.my.stupid.signmultiselect.signMultiselect.get"                                                   
          class="my.stupid.alfresco.webscripts.GetPropertiesAlfrescoWebscript"
          parent="webscript">                  
            <property name="authenticationService">
                <ref bean="AuthenticationService" />
            </property>
            <property name="contentService">
                <ref bean="ContentService"/>
            </property>
            <property name="nodeService">
                <ref bean="NodeService"/>
            </property>
            <property name="searchService">
                <ref bean="SearchService"/>
            </property>
</bean>

</beans>

****************************************************************************************************************

/repo-amp/src/main/amp/config/alfresco/module/repo-amp/module-context.xml

****************************************************************************************************************

<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    <import resource="classpath:alfresco/module/${project.artifactId}/context/*-context.xml"/>
</beans>

****************************************************************************************************************

/repo-amp/src/main/amp/config/alfresco/extension/templates/webscripts/my/stupid/signmultiselect/signMultiselect.get.desc.xml

****************************************************************************************************************

<webscript>
    <shortname>ZZZZZ</shortname>
    <description>XXXXX</description>
    <url>/my/stupid/signMultiselect/repo/get</url>
    <format default="html">extension</format><!-- same error iif i use json or xml -->
    <authentication>user</authentication>
    <transaction>required</transaction>
</webscript>

So  for the repo amp seem all ok now i create a javascript on the share-amp, the javascript is called from a action on the multi-select of share , but i don't think that is the problem. Note i even tried to put the javascript under "/share-amp/src/main/amp/web/components/sign/sign-surf-multiselect-action.js" because i have seen someone do that:

****************************************************************************************************************

/share-amp/src/main/resources/META-INF/components/sign/sign-surf-multiselect-action.js

****************************************************************************************************************

..... SOME JAVASCRIPT ......

var urlRepoGet = encodeURI(Alfresco.constants.PROXY_URI+'my/stupid/signMultiselect/repo/get?searchParameter=TICKET');

//http://<MY_IP_ADDRESS>:8080/share/proxy/alfresco/my/stupid/signMultiselect/repo/get?searchParameter=...
 log('urlRepoGet string = ' + urlRepoGet);
//Alfresco.util.Ajax.jsonGet( //still the same error
Alfresco.util.Ajax.request(
 {
         method: Alfresco.util.Ajax.GET,
         responseContentType: Alfresco.util.Ajax.JSON,
         url: urlRepoGet,//Alfresco.constants.PROXY_URI+"/abd/signMultiselect/repo/get"
         successCallback:
          {
                fn: function handleSuccess(data)
                 {
                   log('Result Multiselect : ' + data.serverResponse.responseText);//

..... SOME JAVASCRIPT ......

THE ERROR IS GIVE ME NUTS

2017-11-16 13:50:49,451  ERROR [extensions.webscripts.AbstractRuntime] [http-apr-8080-exec-12] Exception from executeScript - redirecting to status template error: 10160004 Cannot locate template processor for template my/stupid/signmultiselect/signMultiselect.get.html
 org.springframework.extensions.webscripts.WebScriptException: 10160004 Cannot locate template processor for template my/stupid/signmultiselect/signMultiselect.get.html

When i reach the GET HTTP call the uri is good and the communication with the repo-amp webscript seem ok but , it's still ask me to put a "signMultiselect.get.html.ftl" file on the same directory of "signMultiselect.get.desc.xml".

FIRST QUESTION

Why? if i create a class java who extended the AbstractWebscript with the "execute" method ovverride, the template ftl is not a mandatory requirement, i know because i see on the same project a webscript equal to mine but  it's work fine without template.

SECOND QUESTION

If i create the template asked from alfresco is work fine but it's never call the java code of the webscript, i always get a empty value. And that is what i don't understand all the path seem be fine, and i have spent two days try to figure out by myself.

FULL DETAILED ERROR MESSAGE FROM SHARE WITH NO TEMPLATE SETTED

The Web Script /alfresco/s/my/stupid/signMultiselect/repo/get has responded with a status of 500 - Internal Error.

500 Description:    An error inside the HTTP server which prevented it from fulfilling the request.
 
Message:    10170006 Cannot locate template processor for template my/stupid/signmultiselect/signMultiselect.get.html
    
Exception:    org.springframework.extensions.webscripts.WebScriptException - 10170006 Cannot locate template processor for template my/stupid/signmultiselect/signMultiselect.get.html
    
    org.springframework.extensions.webscripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:975)
    org.springframework.extensions.webscripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:267)
    org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147)
    org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:512)
    org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:457)
    org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:580)
    org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:649)
    org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:421)
    org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:301)
    org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:378)
    org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
    org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:2403)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:745)
    
Server:    Community v5.1.0 (r122274-b3) schema 9.016
Time:    17-nov-2017 11.48.26
    
Diagnostics:    Inspect Web Script (my/stupid/signmultiselect/signMultiselect.get)

Note : i use SDK Api Alfresco 2.2 e alfresco-community 5.1

Ty in advance .

Greetings.

1 Solution

Accepted Solutions
krutik_jayswal
Senior Member II

Re: Can't reach my java code backend Webscript

Jump to solution

Simple mistake

There is problem in bean id.

webscripts.my.stupid.signmultiselect.signMultiselect.get

should be

webscript.my.stupid.signmultiselect.signMultiselect.get

Because bean is not injected correctly, its trying to find the html template.

View solution in original post

3 Replies
krutik_jayswal
Senior Member II

Re: Can't reach my java code backend Webscript

Jump to solution

Simple mistake

There is problem in bean id.

webscripts.my.stupid.signmultiselect.signMultiselect.get

should be

webscript.my.stupid.signmultiselect.signMultiselect.get

Because bean is not injected correctly, its trying to find the html template.

4535992
Senior Member

Re: Can't reach my java code backend Webscript

Jump to solution

i'm a idiot ty very much you are a life savior

rdsingh83
Member II

Re: Can't reach my java code backend Webscript

Jump to solution

Hi Krutik 

Can you please help me in this

issue -->   as I ask in community board but no one answer.

Thanks

Raman