cancel
Showing results for 
Search instead for 
Did you mean: 

java backed webscript not using FTL deployed via amp URGENT

renaissance
Champ in-the-making
Champ in-the-making
Hi,

I've been pondering on this error for a number of days now and it has become very counter productive. I am deploying a module via an amp file of my customisations for the webscripts and configurations. The structure of the amp file is as follows:

-config
   -alfresco
      -module
         -my-module
            -module-context.xml
            -application.properties
      -webscripts
         -packagename
            -MyJavaClass.post.desc.xml
-lib
   -ezmorph-1.0.5.jar
   -json-lib-2.3-jdk15.jar
   -my-module.jar
-module.properties

the descriptor file is as folloes:

<webscript>
  <shortname>My Module</shortname>
  <description>description</description>
  <url>/sampler/myjavaclass</url>
  <format default="">any</format>  
  <authentication>user</authentication>
</webscript>


Module-context.xml contains the bean definition for the MyJavaClass controller class. The definition is as follows:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans-2.0.dtd'>

<!– should contain module specific configurations required to be initialised during startup –>
<beans>
    <bean id="webscript.packagename.sampler.myjavaclass.post"
         class="packagename.sampler.myjavaclass"
         parent="webscript" >
      <property name="repository" ref="repositoryHelper"/>
      <property name="serviceRegistry" ref="ServiceRegistry"/>
    </bean>
</beans>

I had all sorts or errors on the configurations but had gotten over them at some point referencing the posts on this forum. The alfresco server is initialised properly allowing me to log in and to view the https://alfresco/service/ URL which displays my web script quite nicely together with all the other web scripts. The MyJavaClass extends AbstractWebScript so I can stream the response directly back to the client without using freemarker. For some reason I've stumbled upon this error: Web Script format '' is not registered. I've tried using "argument" instead of "any" in the descriptor file but I still get the same error.

At one point I got the "Does not support the method GET" error which does not make sense because I'm using a POST and to top it off the java dump shows the use of the DeclarativeWebScript whereas I'm using AbstractWebScript.

If anyone can shed some light on this in the soonest time possible, please reply.
cheers,
5 REPLIES 5

hyperation
Champ on-the-rise
Champ on-the-rise
In your desc.xml try take out the default="" attribute or put a format for the default, either json, or html, etc.

And as for the method not supported error, make sure your description/webscript file names are correct (.get. / .post.) and also goes the same for your bean definition.

Thanks
Smiley Happy

renaissance
Champ in-the-making
Champ in-the-making
thanks for the reply

my descriptor file is named sampler.post.desc.xml and the bean id is declared as webscript.packagename.sampler.myjavaclass.post.

and i've tried removing the format as well. I'm still interested in finding out why this is happening so any other suggestions would still be helpful.

on another note:
Now I tried it without the amp file and just deployed based on the alfresco war file. I updated the web-scripts-application-context.xml to include my bean, same bean as above, and placed my sampler.post.desc.xml in the repository via the add content in Company Home > Data Dictionary > Web Scripts Extensions

using https://myserver/alfresco/wcservice/sampler/myjavaclass and I get this error:

The method specified in the Request-Line is not allowed for the resource identified by the Request-URI.

org.alfresco.web.scripts.WebScriptException - Script url /sampler/myjavaclass does not support the method GET

org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:113)
org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:122)
…more
thanks

hyperation
Champ on-the-rise
Champ on-the-rise
On Firefox, download the add-on call Poster and use that to do a POST call to the webscript.  If that works, then there's nothing wrong with the web script.

Thanks
Smiley Happy

renaissance
Champ in-the-making
Champ in-the-making
I've got the solution to my post and for the benefit of those who might have the same problem here it goes.

1. First and foremost if your using a POST don't test the URL directly on a browser. The browser will use a GET hence the Not supported Method GET error.
2. Make sure that your bean is recognised in the context. If the bean is not correctly configured, calls to the module id will call the default Alfresco DeclarativeWebScript class. This was whats causing my confusion as to why I was getting a DeclarativeWebScript error dump while I had implemented the AbstractWebScript class on my controller. MAke sure that the bean ID matches the qualified name of the descriptor.


com
  something
       myDescriptor.get.desc.xml

bean should be
<bean id="webscript.com.something.myDescriptor.post" …/>

Now that thats resolved my next question is where should modlue specific property files be placed? In my amp file I've currently got it in
config/alfresco/module/module id/mypropertyfile.properties 

This gets extracted to WEB-INF/classes/alfresco/module/module id/mypropertyfile.properties

I assume that this is ok since it is inside the classpath. But my controller class is saying differently. It can't locate my property file.

Any ideas on where is should go?

And thanks Hyp… for the suggestions.

kbootz
Champ in-the-making
Champ in-the-making
I had seen a JIRA(# ?) dealing with the problem. It turns out that the ……resourceBundleBootstrap.class does not recognize a location other than either alfresco/messages or alfresco/extension for the path to your properties. I received a NullPointerException in the JSF until I restructured.

So, short story long, place them under alfresco/extension or alfresco/messages.  Kind of defeats the purpose for having a named module…