import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import org.json.simple.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import com.thed.je.zbot.ZbotProperties;
import com.thed.je.zbot.util.Messages;
@Component
public class AgentServiceImpl {
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<JSONObject> result = restTemplate.postForEntity(URL, requestEntity, JSONObject.class);
}
Below are the values while debugging
When I am trying to run above code, I am getting following error
500 error-> “Unable to start the agent. The port is in use by some other process.”
But same code when i run with Jira9, it is working.
Can anyone help me with this
Below is code for Server Start
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.Scanner;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.json.simple.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ExitCodeGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.embedded.tomcat.ConnectorStartFailedException;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestTemplate;
import com.thed.je.zbot.service.impl.AgentServiceImpl;
import com.thed.je.zbot.util.Messages;
import com.thed.je.zbot.util.PropertyUtils;
import com.thed.je.zbot.util.ZbotConstants;
import com.thed.je.zbot.util.Zbotutils;
public class ServerStartApplication {
public void run() {
try {
AgentServiceImpl agentServiceImpl = new AgentServiceImpl();
agentServiceImpl.registerAgent(zbotProperties);
else if(e instanceof ResourceAccessException) {
logger.error("Unable to connect to server, check configuration url from \"zbot.properties\" file");
appendToConsoleNL("Unable to connect to server, check configuration url from \"zbot.properties\" file");
stopSpringApp();
agentRegistered = false;
return;
}else if(e instanceof ConnectorStartFailedException){
logger.error("Cant start agent either already running or port is in use", e);
appendToConsoleNL("Unable to start the agent. The port is in use by some other process.");
appStarted = false;
agentRegistered = false;
return;
}else {
logger.error("Cant start agent either already running or port is in use", e);
appendToConsoleNL("Unable to start the agent. The port is in use by some other process.");
agentRegistered = false;
return;