AnsweredAssumed Answered

HTTP 500 error using CMIS

Question asked by henkdevries on May 19, 2013
Hi everyone,

I need to use alfresco for a college project. I wrote a test CMIS query, but when I try to execute it on the server it pauses for a moment, then returns a HTTP 500 error. Without any hints as to what might be going wrong whatsoever. Am I missing something obvious?
I'm calling it from GWT. This is the exception I get:
com.google.gwt.user.client.rpc.StatusCodeException: 500 The call failed on the server; see server log for details
   at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:209)
   at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
   at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
   at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
   at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
   at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
   at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
   at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
   at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
   at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
   at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
   at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
   at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
   at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
   at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
   at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
   at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
   at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
   at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
   at java.lang.Thread.run(Thread.java:722)
   [WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.util.ArrayList com.hu.handhavingGWT.client.AlfrescoSessionService.getNameArray()' threw an unexpected exception: org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: Internal Server Error
   at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:389)
   at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:579)
   at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
   at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
   at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
   at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
   at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
   at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
   at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
   at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
   at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
   at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
   at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
   at org.mortbay.jetty.Server.handle(Server.java:324)
   at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
   at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
   at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
   at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
   at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
   at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
   at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
Caused by: org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: Internal Server Error
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:452)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:570)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.DiscoveryServiceImpl.query(DiscoveryServiceImpl.java:142)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl$3.fetchPage(SessionImpl.java:567)
   at org.apache.chemistry.opencmis.client.runtime.util.AbstractIterator.incrementPage(AbstractIterator.java:147)
   at org.apache.chemistry.opencmis.client.runtime.util.CollectionIterator.next(CollectionIterator.java:88)
   at com.hu.handhavingGWT.server.AlfrescoSession.getDocList(AlfrescoSession.java:72)
   at com.hu.handhavingGWT.server.AlfrescoSessionServiceImpl.getNameArray(AlfrescoSessionServiceImpl.java:20)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
   … 22 more
[ERROR] 500 - POST /HandhavingGWT/AlfrescoSessionService (127.0.0.1) 57 bytes
   Request headers
      Host: 127.0.0.1:8888
      Connection: keep-alive
      Accept: */*
      DNT: 1
      User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
      Accept-Encoding: gzip,deflate,sdch
      Accept-Language: nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4
      Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
      Content-Length: 150
      X-GWT-Module-Base: http://127.0.0.1:8888/HandhavingGWT/
      X-GWT-Permutation: HostedMode
      Origin: http://127.0.0.1:8888
      Content-Type: text/x-gwt-rpc; charset=UTF-8
      Referer: http://127.0.0.1:8888/index.html?gwt.codesvr=127.0.0.1:9997
   Response headers
      Content-Type: text/plain
com.google.gwt.user.client.rpc.StatusCodeException: 500 The call failed on the server; see server log for details
   at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:209)
   at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
   at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
   at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
   at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
   at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
   at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
   at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
   at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
   at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
   at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
   at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
   at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
   at sun.reflect.GeneratedMethodAccessor53.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
   at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
   at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
   at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
   at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
   at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
   at java.lang.Thread.run(Thread.java:722)


The code where it's called:
package com.hu.handhavingGWT.server;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.chemistry.opencmis.client.api.ItemIterable;
import org.apache.chemistry.opencmis.client.api.QueryResult;
import org.apache.chemistry.opencmis.client.api.Repository;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.data.PropertyData;
import org.apache.chemistry.opencmis.commons.enums.BindingType;


public class AlfrescoSession implements Serializable
{
   /**
    *
    */
   private static final long serialVersionUID = -1158440943505923661L;
   
   private String baseURLCMIS = "http://localhost:8080/alfresco/service/cmis";
   public Session session;
   private String username;
   private String password;


   /**
    * Constructor. Create a zaak CMIS session object using the specified user
    * and password. The opIntakePath is used to retreive new mail.
    */
   public AlfrescoSession(String baseURL, String username, String password) {
      this.baseURLCMIS = baseURL;
      this.username = username;
      this.password = password;
   }
   public void Start() {
      Map<String, String> parameter = new HashMap<String, String>();

      // Set the user credentials
      parameter.put(SessionParameter.USER, username);
      parameter.put(SessionParameter.PASSWORD, password);

      // Specify the connection settings
      // Via AtomPub REST interface:
      parameter.put(SessionParameter.ATOMPUB_URL, baseURLCMIS);
      parameter.put(SessionParameter.BINDING_TYPE,
            BindingType.ATOMPUB.value());

      // Set the alfresco object factory
      parameter.put(SessionParameter.OBJECT_FACTORY_CLASS,
            "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");

      // Create a session for the first repository
      // This might need to be changed for other Alfresco configurations.
      SessionFactory factory = SessionFactoryImpl.newInstance();
      List<Repository> repositories = factory.getRepositories(parameter);
      session = repositories.get(0).createSession();
   }
   
   public ArrayList<String> getDocList()
   {
      Start();
      String query = "SELECT cmis:name FROM cmis:document";
      ItemIterable<QueryResult> result = session.query(query, false);
      ArrayList<String> array = new ArrayList<String>();
      for(QueryResult i : result)
      {
         for(PropertyData p : i.getProperties())
         {
            array.add(p.getDisplayName());
         }
      }
      
      return array;
   }
   
}

Outcomes