cancel
Showing results for 
Search instead for 
Did you mean: 

WebSiteService returning null website

mangar
Star Contributor
Star Contributor
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?
2 REPLIES 2

mangar
Star Contributor
Star Contributor
As a quick follow up, I have also tried this:

       CmisSessionPool sessionPool = (CmisSessionPool)appContext.getBean("sessionPool");
       Session session = sessionPool.getGuestSession();

and I get this error:

exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.alfresco.wcm.client.exception.RepositoryUnavailableException
   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

org.alfresco.wcm.client.exception.RepositoryUnavailableException
   org.alfresco.wcm.client.util.impl.GuestSessionFactoryImpl.makeObject(GuestSessionFactoryImpl.java:212)
   org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1158)
   org.alfresco.wcm.client.util.impl.CmisSessionPoolImpl.getGuestSession(CmisSessionPoolImpl.java:72)
   com.sammysblog.web.controller.HelloController.handleRequest(HelloController.java:41)
   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)

Im clearly not connecting in any way…. Smiley Sad

mangar
Star Contributor
Star Contributor
It was 2 things (or I think it was, I did both and it now works). 

1. configuration issue.  make sure that you change your folder type in share to ws:website and set you host and port correctly, and remove the http:// from your url if you do it this way:
   
   ApplicationContext appContext = new ClassPathXmlApplicationContext("alfresco/wcmqs-api-context.xml");
       websiteService = (WebSiteService)appContext.getBean("webSiteService");
       WebSite website = websiteService.getWebSite("myec2.amazonaws.com", 8080, "wcmqs");

2. Mas sure your class is imbedded into the spring framework so you can have access to all the WCMQS stuff. see this post: https://forums.alfresco.com/en/viewtopic.php?f=52&t=47449
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.