AnsweredAssumed Answered

WebSiteService returning null website

Question asked by mangar on Dec 16, 2012
Latest reply on Dec 18, 2012 by mangar
I am trying to create a simple jsp that gets content out of alfresco. I have copied most of the files from wcmqs (except the Surf stuff)

I have the web.xml with my servlet def:
  <servlet>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/classes/web-application-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>  
 
  <servlet>
    <servlet-name>sammyapp</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>sammyapp</servlet-name>
    <url-pattern>*.htm</url-pattern>
  </servlet-mapping>

in my WEB-INF/classes i have copied everything exactly as it is in wcmqs, and everything war's up and deploys just fine, no errors.

here is my relevant controller class handleRequest method:

      ApplicationContext appContext = new ClassPathXmlApplicationContext("alfresco/wcmqs-api-context.xml");
       String names[] = appContext.getBeanDefinitionNames();
       for(String name : names) {
          System.out.println(name);
       }
       websiteService = (WebSiteService)appContext.getBean("webSiteService");
       System.out.println("WSSwervice:"+websiteService);
       WebSite website = websiteService.getWebSite("localhost", 8080, "sammy");

when I run this I get a NullPointerException on the last line. The websiteService itself is not null, but I get this stack trace in the browser:

type Exception report

message Request processing failed; nested exception is java.lang.NullPointerException

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

exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
   org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

java.lang.NullPointerException
   org.alfresco.wcm.client.impl.WebSiteServiceImpl.refreshWebsiteCache(WebSiteServiceImpl.java:166)
   org.alfresco.wcm.client.impl.WebSiteServiceImpl.getWebSiteCache(WebSiteServiceImpl.java:150)
   org.alfresco.wcm.client.impl.WebSiteServiceImpl.getWebSite(WebSiteServiceImpl.java:117)
   com.sammysblog.web.controller.HelloController.handleRequest(HelloController.java:37)
   org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
   org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


How do I get this service?

Or more importantly,  how do I get a simple text file out of alfresco?

Outcomes