fetchAndLock error

Does anyone have a solution for this error ?

org.camunda.bpm.client.impl.EngineClientException: TASK/CLIENT-02002 Exception while establishing connection for request ‘POST http://localhost:8090/rest/deployment/external-task/fetchAndLock HTTP/1.1’

Could you please refer the below link. Hope this helps you.

Thanks.

Thank you, but I’ve already checked it and tried it out. It still won’t work…

More log output and information about your configuration may help us to help you

org.camunda.bpm.client.impl.EngineClientException: TASK/CLIENT-02002 Exception while establishing connection for request ‘POST http://localhost:8090/rest/deployment/external-task/fetchAndLock HTTP/1.1’
at org.camunda.bpm.client.impl.EngineClientLogger.exceptionWhileEstablishingConnection(EngineClientLogger.java:36)
at org.camunda.bpm.client.impl.RequestExecutor.executeRequest(RequestExecutor.java:101)
at org.camunda.bpm.client.impl.RequestExecutor.postRequest(RequestExecutor.java:74)
at org.camunda.bpm.client.impl.EngineClient.fetchAndLock(EngineClient.java:78)
at org.camunda.bpm.client.topic.impl.TopicSubscriptionManager.fetchAndLock(TopicSubscriptionManager.java:135)
at org.camunda.bpm.client.topic.impl.TopicSubscriptionManager.acquire(TopicSubscriptionManager.java:101)
at org.camunda.bpm.client.topic.impl.TopicSubscriptionManager.run(TopicSubscriptionManager.java:87)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8090 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:374)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:221)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140)
at org.camunda.bpm.client.impl.RequestExecutor.executeRequest(RequestExecutor.java:88)
… 6 common frames omitted
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
… 18 common frames omitted

this is a part of the output when I run this code ( I found it in the documentation : https://docs.camunda.org/get-started/quick-start/service-task/#add-the-java-class )

public class DecisionMaker {

	private final static Logger LOGGER = Logger.getLogger(DecisionMaker.class.getName());
	
	public static void main(String[] args) {
		ExternalTaskClient client = ExternalTaskClient.create()
		        .baseUrl("http://localhost:8090/rest/deployment")
		        .backoffStrategy(new ExponentialBackoffStrategy(500L, 2, 30000L))
		        .asyncResponseTimeout(10000) // long polling timeout
		        .build();

		    // subscribe to an external task topic as specified in the process
		    client.subscribe("Make-decision")
		        .lockDuration(1000) // the default lock duration is 20 seconds, but you can override this
		        .handler((externalTask, externalTaskService) -> {
		          // Put your business logic here

		          // Get a process variable
//		          String item = (String) externalTask.getVariable("item");
//		          Long amount = (Long) externalTask.getVariable("amount");
//		          LOGGER.info("Charging credit card with an amount of '" + amount + "'€ for the item '" + item + "'...");

		          // Complete the task
		          externalTaskService.complete(externalTask);
		        })
		        .open();

	}

What does the server look like? Spring Boot setup? downloaded tomcat? changed port configuration to 8090? Process model, topics configured in it?

This base url http://localhost:8090/rest/deployment looks wrong.
Standard for a Spring boot setup would be: http://localhost:8080/rest

I had a problem with port 8080 :frowning:
I always get an error that it’s being used by another process even though I killed all processes that run on it… so I had to change it …

You are likely already running another sever / tomcat on 8080.
Which server config are you using? Wildfly, preconfigured tomcat, spring boot,…?

The /deployment part in the url is most likely the issue. Try http://localhost:8090/rest

Working example: https://github.com/rob2universe/externalWorkers

alright, I killed the processes running on 8080 as an admin and removed the 8090 one…
I still get the same error though http://localhost:8080/rest returns

{"type":"NotFoundException","message":"HTTP 404 Not Found"}

I’m still a beginner at this… I’m just trynig to develop a simple spring boot application with a simple process and see it running… so I thought following the documentation step by step would be a good idea… I’ll try a little more and see how it works … thank you so much for your help :relaxed:

First, ensure you can reach the rest api under the given port. You ca use https://start.camunda.com/ to generate a plan vanilla Spring boot server project including the REST API. You current setup may be missing

<dependency>
  <groupId>org.camunda.bpm.springboot</groupId>
  <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
  <version>3.4.1</version>
</dependency>
1 Like

Yes I’ve already done that…

Any updates on either front?