custom connector : LinkageError BonitaClassLoader (v.7.6)

He,

I have created a custom connector for uploading file trought WS using httpclient.
I don’t impart external jar in my connector, I use only defaut jar like httpclient-4.3.6 and httpcore-4.3.3.
Thoses jar is used by default Rest POST and GET connector.

When i’m runing a process with my custom connector, i get this error:

org.bonitasoft.engine.core.connector.exception.SConnectorException: PROCESS_DEFINITION_ID=5810112512257646492 | PROCESS_NAME=C-ProcessQuality | PROCESS_VERSION=1.3 | PROCESS_INSTANCE_ID=42050 | ROOT_PROCESS_INSTANCE_ID=42050 | FLOW_NODE_DEFINITION_ID=7977920864858041647 | FLOW_NODE_INSTANCE_ID=860723 | FLOW_NODE_NAME=Update document Word dans DS | CONNECTOR_IMPLEMENTATION_CLASS_NAME=updateWordDocumentToDS | CONNECTOR_INSTANCE_ID=840130 | org.bonitasoft.engine.connector.exception.SConnectorException: java.util.concurrent.ExecutionException: java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.http.entity.mime.MultipartEntityBuilder.addBinaryBody(Ljava/lang/String;Ljava/io/File;Lorg/apache/http/entity/ContentType;Ljava/lang/String;)Lorg/apache/http/entity/mime/MultipartEntityBuilder;" the class loader (instance of org/bonitasoft/engine/classloader/BonitaClassLoader) of the current class, com/ecervo/connector/RestuploadImpl, and the class loader (instance of org/apache/catalina/loader/ParallelWebappClassLoader) for the method's defining class, org/apache/http/entity/mime/MultipartEntityBuilder, have different Class objects for the type org/apache/http/entity/ContentType used in the signature
	at org.bonitasoft.engine.core.connector.impl.ConnectorServiceImpl.executeConnectorInClassloader(ConnectorServiceImpl.java:285)
	at org.bonitasoft.engine.core.connector.impl.ConnectorServiceImpl.executeConnector(ConnectorServiceImpl.java:158)
	at org.bonitasoft.engine.connector.ConnectorServiceDecorator.executeConnector(ConnectorServiceDecorator.java:114)
	at org.bonitasoft.engine.execution.work.ExecuteConnectorWork.work(ExecuteConnectorWork.java:138)
	at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:42)
	at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:42)
	at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:42)
	at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:42)
	at org.bonitasoft.engine.execution.work.InSessionBonitaWork.work(InSessionBonitaWork.java:58)
	at org.bonitasoft.engine.work.BonitaThreadPoolExecutor.lambda$submit$0(BonitaThreadPoolExecutor.java:90)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.bonitasoft.engine.connector.exception.SConnectorException: java.util.concurrent.ExecutionException: java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.http.entity.mime.MultipartEntityBuilder.addBinaryBody(Ljava/lang/String;Ljava/io/File;Lorg/apache/http/entity/ContentType;Ljava/lang/String;)Lorg/apache/http/entity/mime/MultipartEntityBuilder;" the class loader (instance of org/bonitasoft/engine/classloader/BonitaClassLoader) of the current class, com/ecervo/connector/RestuploadImpl, and the class loader (instance of org/apache/catalina/loader/ParallelWebappClassLoader) for the method's defining class, org/apache/http/entity/mime/MultipartEntityBuilder, have different Class objects for the type org/apache/http/entity/ContentType used in the signature
	at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.execute(ConnectorExecutorImpl.java:125)
	at org.bonitasoft.engine.core.connector.impl.ConnectorServiceImpl.executeConnectorInClassloader(ConnectorServiceImpl.java:279)
	... 12 more
Caused by: java.util.concurrent.ExecutionException: java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.http.entity.mime.MultipartEntityBuilder.addBinaryBody(Ljava/lang/String;Ljava/io/File;Lorg/apache/http/entity/ContentType;Ljava/lang/String;)Lorg/apache/http/entity/mime/MultipartEntityBuilder;" the class loader (instance of org/bonitasoft/engine/classloader/BonitaClassLoader) of the current class, com/ecervo/connector/RestuploadImpl, and the class loader (instance of org/apache/catalina/loader/ParallelWebappClassLoader) for the method's defining class, org/apache/http/entity/mime/MultipartEntityBuilder, have different Class objects for the type org/apache/http/entity/ContentType used in the signature
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.getValue(ConnectorExecutorImpl.java:149)
	at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl.execute(ConnectorExecutorImpl.java:122)
	... 13 more
Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.http.entity.mime.MultipartEntityBuilder.addBinaryBody(Ljava/lang/String;Ljava/io/File;Lorg/apache/http/entity/ContentType;Ljava/lang/String;)Lorg/apache/http/entity/mime/MultipartEntityBuilder;" the class loader (instance of org/bonitasoft/engine/classloader/BonitaClassLoader) of the current class, com/ecervo/connector/RestuploadImpl, and the class loader (instance of org/apache/catalina/loader/ParallelWebappClassLoader) for the method's defining class, org/apache/http/entity/mime/MultipartEntityBuilder, have different Class objects for the type org/apache/http/entity/ContentType used in the signature
	at com.ecervo.connector.RestuploadImpl.executeBusinessLogic(RestuploadImpl.java:62)
	at org.bonitasoft.engine.connector.AbstractConnector.execute(AbstractConnector.java:77)
	at org.bonitasoft.engine.core.connector.impl.SConnectorAdapter.execute(SConnectorAdapter.java:73)
	at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl$ExecuteConnectorCallable.call(ConnectorExecutorImpl.java:206)
	at org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl$ExecuteConnectorCallable.call(ConnectorExecutorImpl.java:176)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	... 3 more

I allready look in my tomcat server, but no httpclient or httcore are present in the lib directory.

Do you know how to solve this problem?

Hello,

actually, the file bonita.war that is located in the web folder contains some of the jars you are using that create the conflict:

  • httpclient-4.5.2.jar
  • httpcore-4.4.4.jar

The best is to make sure your connector is compliant with the already provided jar files I have listed above.

Hope this helps,
Charles

Hello,

I understand you have removed the libs so that they are not deployed anymore but have you made sure they have been compiled with the right version?

Thanks,
Charles

Hi, and thanks for this reply
The probel is, that the default ‘Rest Get/Post connector’ used httpclient:4.3.6 and core:4.3.3.
So i think that bonita load those version before the real version ‘4.5.2 and 4.4.4’ …
I will try to export and import default connector for changing that libs, and try again.

I had remove old version of httclient and httpcore. But it’s not working…

Yes,
I have take a look at my connector jar, and it’s ok.
I think that Bonita avoid to use it ( in my version 7.6.3 ). So, i have make a work around.