Error Create Session CMIS

1
0
-1

I tried to create a cmis connector in pretty soft version 5.9.1 and when I try to create a session it returns the following error.
java.lang.NoClassDefFoundError: org/apache/chemistry/opencmis/client/runtime/SessionFactoryImpl
java.lang.ClassNotFoundException: org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl in classloader MyExtensionsClassLoader

I use de next code

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

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.enums.BindingType;
import org.ow2.bonita.connector.core.ConnectorError;
import org.ow2.bonita.connector.core.ProcessConnector;

public class CMISTESTE extends ProcessConnector {

// DO NOT REMOVE NOR RENAME THIS FIELD
public String password;
// DO NOT REMOVE NOR RENAME THIS FIELD
public String username;
public String resultado;

private static Map<String, Session> connections = new ConcurrentHashMap<String, Session>();


@Override
protected void executeConnector() throws Exception {
    // TODO Auto-generated method stub
    getSession( username, password);
}

    public String getSession(String username, String password) {

        System.out.println("Metodo CreateSession");

        // Ver se existe uma sessão existente para o utilizador
        Session session = connections.get(username);

        // Criar uma nova sessão no Alfresco
        if (session == null) {
            System.out.println("Not connected, creating new connection to" + " Alfresco with the connection id (" + username
                    + ")");

            // Implementação da fabrica padrão
            SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
            Map<String, String> parameters = new HashMap<String, String>();

            // Parametros para a conecção
            parameters.put(SessionParameter.USER, username);
            parameters.put(SessionParameter.PASSWORD, password);
            parameters.put(SessionParameter.ATOMPUB_URL,"http://localhost:8089/alfresco/cmisatom");
            parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
            //parameters.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");         

            // Recebe a lista de repositorios fornecidos pelo endpoint
            List<Repository> repositories = sessionFactory.getRepositories(parameters);

            // Como só é devolvido um repositorio, irá estar na posição 0
            Repository alfrescoRepository = null;
            alfrescoRepository = repositories.get(0);

            // Criar conecção com o repositorio
            session = alfrescoRepository.createSession();

            // Salvar coneção
            connections.put(username, session);

        } else {
            System.out.println("Already connected to Alfresco with the " + "connection id (" + username + ")");
        }
        resultado="OK";
        return resultado;
    }

@Override
protected List<ConnectorError> validateValues() {
    // TODO Auto-generated method stub
    return null;
}

/**
 * Setter for input argument 'password'
 * DO NOT REMOVE NOR RENAME THIS SETTER, unless you also change the related entry in the XML descriptor file
 */
public void setPassword(java.lang.String password) {
    this.password = password;
}

/**
 * Setter for input argument 'username'
 * DO NOT REMOVE NOR RENAME THIS SETTER, unless you also change the related entry in the XML descriptor file
 */
public void setUsername(java.lang.String username) {
    this.username = username;
}

/**
 * Getter for output argument 'resultado'
 * DO NOT REMOVE NOR RENAME THIS GETTER, unless you also change the related entry in the XML descriptor file
 */
public java.lang.String getResultado() {
    // TODO Add return value for the output here
    return this.resultado;
}

}

How should I correct?

1 answer

1
0
-1

Hi,

When you create a connector, you have to provide the dependencies, in your case jar files.

You usually define the list of dependencies with the Studio when you implement your connector. Did you provide all the jars?

Cheers

Comments

Submitted by patricia.lopes_... on Wed, 01/31/2018 - 13:25

Yes

I provide all the jars

Submitted by antoine.mottier on Wed, 01/31/2018 - 13:35

Can you share your process with the connector?

Submitted by patricia.lopes_... on Wed, 01/31/2018 - 15:10

public class CreateSubfolder extends AbstractCmisConnector {

private String parentFolderPath;
private String subfolderName;
private String title;

@Override
public void executeConnector() throws Exception {
createSubFolderByPath(username, password, url, binding_type, repositoryName, parentFolderPath, subfolderName,
title);
}

@Override
protected List<ConnectorError> validateValues() {
return null;
}

public void setParentFolderPath(final String parentFolderPath) {
this.parentFolderPath = parentFolderPath;
}

public void setSubfolderName(final String subfolderName) {
this.subfolderName = subfolderName;
}

public void setTitle(final String title) {
this.title = title;
}

/**
*
* @param username
* @param password
* @param url
* @param binding
* @param repositoryName
* @param path
* @param folderName
* @param folderTitle
*/
public void createSubFolderByPath(final String username, final String password, final String url,
final String binding, final String repositoryName, final String path, final String folderName,
final String folderTitle) {

final Session s = createSessionByName(username, password, url, binding, repositoryName);
final Folder folder = (Folder) s.getObjectByPath(path);

final HashMap<String, Object> properties = new HashMap<String, Object>();

properties.put(PropertyIds.NAME, folderName);
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder, P:cm:titled");
properties.put("cm:title", folderTitle);
properties.put(PropertyIds.DESCRIPTION, "Contablidade");
folder.createFolder(properties, null, null, null, s.getDefaultContext());

}
}

public abstract class AbstractCmisConnector extends ProcessConnector {

protected String username;
protected String binding_type;
protected String repositoryName;
protected String password;
protected String url;
protected Session session;

public AbstractCmisConnector() {
session = null;
}

public void setUsername(final String username) {
this.username = username;
}

public void setBinding_type(final String binding_type) {
this.binding_type = binding_type;
}

public void setRepositoryName(final String repositoryName) {
this.repositoryName = repositoryName;
}

public void setPassword(final String password) {
this.password = password;
}

public void setUrl(final String url) {
this.url = url;
}

/**
*
* @param username
* @param password
* @param url
* @param bindingType
* @return
*/
protected ArrayList<Repository> getRepositories(final String username, final String password, final String url,
final String bindingType) {

final SessionFactory f = SessionFactoryImpl.newInstance();
final Map<String, String> parameter = fixParameters(username, password, url, bindingType);
final ArrayList<Repository> repositories = new ArrayList<Repository>(f.getRepositories(parameter));

return repositories;
}

/**
*
* @param username
* @param password
* @param url
* @param bindingType
* @return
*/
private Map<String, String> fixParameters(final String username, final String password, final String url,
String bindingType) {
final Map<String, String> parameter = new HashMap<String, String>();

if ("ATOM".equals(bindingType)) {
bindingType = BindingType.ATOMPUB.value();
} else if ("WebService".equals(bindingType)) {
bindingType = BindingType.WEBSERVICES.value();
parameter.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url + "/ACLService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url + "/DiscoveryService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url + "/MultiFilingService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url + "/NavigationService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url + "/ObjectService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url + "/PolicyService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url + "/RelationshipService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url + "/RepositoryService?wsdl");
parameter.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url + "/VersioningService?wsdl");
}

parameter.put(SessionParameter.ATOMPUB_URL, url);
parameter.put(SessionParameter.USER, username);
parameter.put(SessionParameter.PASSWORD, password);
parameter.put(SessionParameter.BINDING_TYPE, bindingType);

return parameter;
}

/**
*
* @param username
* @param password
* @param url
* @param bindingType
* @param repositoryId
* @return
*/
protected Session createSessionById(final String username, final String password, final String url,
final String bindingType, final String repositoryId) {

final SessionFactory f = SessionFactoryImpl.newInstance();
final Map<String, String> parameter = fixParameters(username, password, url, bindingType);
parameter.put(SessionParameter.REPOSITORY_ID, repositoryId);
session = f.createSession(parameter);

return session;
}

/**
*
* @param username
* @param password
* @param url
* @param bindingType
* @param repositoryName
* @return
*/
protected Session createSessionByName(final String username, final String password, final String url,
final String bindingType, final String repositoryName) {

final String repositoryId = getRepositoryIdByName(username, password, url, bindingType, repositoryName);
session = createSessionById(username, password, url, bindingType, repositoryId);
return session;
}

/**
*
* @param username
* @param password
* @param url
* @param binding
* @param repositoryName
* @param path
* @return
*/
protected Folder getFolderByPath(final String username, final String password, final String url,
final String binding, final String repositoryName, final String path) {
final Session s = createSessionByName(username, password, url, binding, repositoryName);
return (Folder) s.getObjectByPath(path);
}

/**
*
* @param username
* @param password
* @param url
* @param binding
* @param repositoryName
* @param path
* @return
*/
protected CmisObject getObjectByPath(final String username, final String password, final String url,
final String binding, final String repositoryName, final String path) {
final Session s = createSessionByName(username, password, url, binding, repositoryName);
return s.getObjectByPath(path);
}

/**
*
* @param username
* @param password
* @param url
* @param binding
* @param repositoryName
* @return
*/
protected String getRepositoryIdByName(final String username, final String password, final String url,
final String binding, final String repositoryName) {
final List<Repository> repositories = getRepositories(username, password, url, binding);
Integer index = 0;

while (index < repositories.size() && !repositories.get(index).getName().equals(repositoryName)) {
index++;
}

if (index == repositories.size())
return repositories.get(0).getId();
else
return repositories.get(index).getId();
}

/**
*
* @return
*/
public Session getSession() {
return session;
}

}

Submitted by antoine.mottier on Wed, 01/31/2018 - 16:10

What I need is actually the process export from the Studio. If I remember correctly in version 5 you can export the process as a .bar file.

Also please post comments instead of answers. Only use "answer" when actually answering a question. Thanks.

Submitted by patricia.lopes_... on Wed, 01/31/2018 - 16:57

At this point in the eclipse everything is working on creating folder and document with the description property, however when I step into the beautiful the ZIP file gives the following error:
org.bonitasoft.forms.server.FormsServlet executeActions
SEVERE: Error while executing Actions
java.lang.Exception: org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.newInstance()Lorg/apache/chemistry/opencmis/client/runtime/SessionFactoryImpl;
at org.bonitasoft.forms.server.provider.impl.FormServiceProviderImpl.executeActions(FormServiceProviderImpl.java:710)
at org.bonitasoft.forms.server.FormsServlet.executeActions(FormsServlet.java:1078)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at org.bonitasoft.forms.server.FormsServlet.processCall(FormsServlet.java:123)
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:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:534)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1352)
at org.bonitasoft.forms.server.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:122)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1323)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:474)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:517)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:935)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:404)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:184)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:870)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:247)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:151)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:346)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:596)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1068)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:807)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:220)
at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:426)
at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:241)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:528)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoSuchMethodError: org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.newInstance()Lorg/apache/chemistry/opencmis/client/runtime/SessionFactoryImpl;
at AbstractCmisConnector.getRepositories(AbstractCmisConnector.java:68)
at AbstractCmisConnector.getRepositoryIdByName(AbstractCmisConnector.java:190)
at AbstractCmisConnector.createSessionByName(AbstractCmisConnector.java:142)
at CreateSubfolder.createSubFolderByPath(CreateSubfolder.java:58)
at CreateSubfolder.executeConnector(CreateSubfolder.java:22)
at org.ow2.bonita.connector.core.Connector.execute(Connector.java:233)
at org.ow2.bonita.connector.core.Connector.execute(Connector.java:377)
at org.ow2.bonita.definition.activity.ConnectorExecutor.executeConnector(ConnectorExecutor.java:163)
at org.ow2.bonita.definition.activity.ConnectorExecutor.executeConnector(ConnectorExecutor.java:544)
at org.ow2.bonita.definition.activity.ConnectorExecutor.executeConnectors(ConnectorExecutor.java:645)
at org.ow2.bonita.definition.activity.ConnectorExecutor.executeConnectors(ConnectorExecutor.java:737)
at org.ow2.bonita.runtime.TaskManager.finish(TaskManager.java:216)
at org.ow2.bonita.facade.impl.RuntimeAPIImpl.finishTask(RuntimeAPIImpl.java:405)
at sun.reflect.GeneratedMethodAccessor159.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.ow2.bonita.facade.APIInterceptor$APIInterceptorCommand.execute(APIInterceptor.java:115)
at org.ow2.bonita.facade.APIInterceptor.invoke(APIInterceptor.java:183)
at com.sun.proxy.$Proxy20.finishTask(Unknown Source)
at org.ow2.bonita.facade.runtime.command.ServerWebExecuteTask.execute(ServerWebExecuteTask.java:114)
at org.ow2.bonita.facade.runtime.command.ServerWebExecuteTask.execute(ServerWebExecuteTask.java:45)
at org.ow2.bonita.facade.runtime.command.WebExecuteTask.execute(WebExecuteTask.java:64)
at org.ow2.bonita.facade.runtime.command.WebExecuteTask.execute(WebExecuteTask.java:31)
at org.ow2.bonita.facade.impl.CommandAPIImpl.executeCommand(CommandAPIImpl.java:78)
at org.ow2.bonita.facade.impl.CommandAPIImpl.execute(CommandAPIImpl.java:34)
at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.ow2.bonita.facade.APIInterceptor$APIInterceptorCommand.execute(APIInterceptor.java:115)
at org.ow2.bonita.services.impl.DefaultCommandService.execute(DefaultCommandService.java:44)
at org.ow2.bonita.runtime.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:45)
at org.ow2.bonita.services.impl.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
at org.ow2.bonita.services.impl.RetryInterceptor.execute(RetryInterceptor.java:59)
at org.ow2.bonita.facade.APIInterceptor.invoke(APIInterceptor.java:187)
at com.sun.proxy.$Proxy18.execute(Unknown Source)
at org.bonitasoft.forms.server.api.impl.FormWorkflowAPIImpl.executeActionsAndTerminate(FormWorkflowAPIImpl.java:289)
at org.bonitasoft.forms.server.provider.impl.FormServiceProviderImpl.executeActions(FormServiceProviderImpl.java:658)
... 37 more

Submitted by antoine.mottier on Thu, 02/01/2018 - 10:52

Please share your process file and also the full log file.

Submitted by patricia.lopes_... on Thu, 02/01/2018 - 11:59
Notifications