cancel
Showing results for 
Search instead for 
Did you mean: 

Site not works, when it's created through web scripts

kalyan
Champ in-the-making
Champ in-the-making
Hi all,

I am currently using the latest version available on the site(3.3g).
I am creating a site through web scripts.

URL "http://localhost:8080/alfresco/service/api/sites?alf_ticket=" + authTicket";

These are parameters
JSONObject site = new JSONObject();
site.put("shortName", sitename);
site.put("sitePreset", "site_" + System.currentTimeMillis());
site.put("title", sitename);
site.put("description", "");
site.put("isPublic", true);

Site successfully created. Once i logged into alfresco share and click on that newly created site, it shows error, copying the log

Sep 10, 2010 6:16:53 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Spring Surf Dispatcher Servlet threw exception
javax.servlet.ServletException: Could not resolve view with name 'site/sample/dashboard' in servlet with name 'Spring Surf Dispatcher Servlet'
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1042)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:67)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)


FYI - Site creates from alfresco share, it works but not working when it's created through web scripts.


I look forward for ur reply.

Thanks,
Kalyan
6 REPLIES 6

afaust
Legendary Innovator
Legendary Innovator
Hello,

the problem in your case is that in order for Share to actually use the site you have created requires that your web script at creates the view/component description files for the site dashboard as well. These files consitute the Object Model for the sites dashboard and dashlets, as well as the definition, which pages are available within the site.

Please take a look at the Share web script in "share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/modules/create-site.post.json.js". Tis web script calls the create command as yours does, and then calls sitedata.newPreset() to create the SURF descriptor XML files using the preset definition found in "share/WEB-INF/classes/alfresco/site-data/presets/presets.xml". You have to either duplicate this approach in your own web script (if it runs within a SURF platform and has access to the same presets as your Share) or have your script create the files directly (either via Repository web script at URL "/avmstore/{method}/s/{store}/w/{webapp}/{path}" or SURF web script within Share at URL "/api/surf/object/{type}?id={id?}")

sans
Champ in-the-making
Champ in-the-making
Hi AFaust,
Can you please give sample code or steps to follow?
I did not understand this part.
'You have to either duplicate this approach in your own web script (if it runs within a SURF platform and has access to the same presets as your Share) or have your script create the files directly (either via Repository web script at URL "/avmstore/{method}/s/{store}/w/{webapp}/{path}" or SURF web script within Share at URL "/api/surf/object/{type}?id={id?}")'

Thanks
Sans

tb13
Champ in-the-making
Champ in-the-making
Hey Sans,

look at the file /webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/site/sites.post.json.js

There all the way on the bottom you see a funcion call like follows:


// Create the site
var site = siteService.createSite(sitePreset, shortName, title, description, visibility);

This is server site JS. You can also use this code in any of your WebScripts that you write on the Alfresco side. This would be Alfresco 3.4.

Another very helpful thing is the Sites JS API:

http://wiki.alfresco.com/wiki/3.4_JavaScript_Services_API#Site_service

jelena
Champ in-the-making
Champ in-the-making
Hi, I have a similar problem.

I'm creating site programicly through java webscript. In my java webscript I construct json object and then call create-siteCustom.post.json.js script (with only one modification of create-site.post.json.js - adding alf_ticket when calling api/sites).

When I test create-siteCustom through poster in mozilla firefox it works perfectly, i can access newly created site and after restart of tomcat everything is fine.

But when I call create-siteCustom through java webscript, site creates normally and I can access it, BUT after tomcat/alfressco restart I see created site but when I access it I get following error:
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Could not resolve view with name 'site/test15/dashboard' in servlet with name 'Spring Surf Dispatcher Servlet'
   org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1042)
   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
   org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   org.alfresco.web.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:67)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.26 logs.

Can anyone help please,

Tnx

sans
Champ in-the-making
Champ in-the-making
Hi jelena,
But when I call create-siteCustom through java webscript, site creates normally and I can access it, BUT after tomcat/alfressco restart I see created site but when I access it I get following error:

I am also facing similar problem.
Did you find the solution? I will let you know if I find anything on this.

Thanks
Sans!!!

joemc3
Champ in-the-making
Champ in-the-making
I had this same problem but recently found the solution.  Posted here.

https://forums.alfresco.com/en/viewtopic.php?f=48&t=46259&p=138469#p138469