Hi.
I need to add access from JIRA plugin to external MYSQL DB trough SSH.
I try to create connection via SSH using JSCH library.
public class ExternalData{
private static final Logger log = Logger.getLogger(DataExtract.class);
private Session doSshTunnel(String strSshUser, String strSshPassword, String strSshHost, int nSshPort,
String strRemoteHost, int nLocalPort, int nRemotePort) throws JSchException {
final JSch jsch = new JSch();
Session session = jsch.getSession(strSshUser, strSshHost, 22);
session.setPassword(strSshPassword);
final Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.setTimeout(300);
session.connect();
session.setPortForwardingL(nLocalPort, strRemoteHost, nRemotePort);
return session;
}
public void main() {
try {
String strSshUser = "XXX"; // SSH loging username
String strSshPassword = "XXX"; // SSH login password
String strSshHost = "192.168.88.11"; // hostname or ip or SSH server
int nSshPort = 22; // remote SSH host port number
String strRemoteHost = "127.0.0.1"; // hostname or ip of your database server
int nLocalPort = 3366; // local port number use to bind SSH tunnel
int nRemotePort = 3306; // remote port number of your database
String strDbUser = "XXX"; // database loging username
String strDbPassword = "XXX"; // database login password
Session sshSession = doSshTunnel(strSshUser, strSshPassword, strSshHost, nSshPort, strRemoteHost, nLocalPort,
nRemotePort);
sshSession.disconnect();
} catch (Exception e) {
e.printStackTrace();
} finally {
System.exit(0);
}
}
}
This code stopping JIRA instanse.
17-Jul-2020 09:53:25.689 INFO [Thread-4] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]
17-Jul-2020 09:53:25.691 INFO [Thread-4] org.apache.catalina.core.StandardService.stopInternal Stopping service Catalina
2020-07-17 09:53:27,857 localhost-startStop-2 INFO [c.a.jira.startup.DefaultJiraLauncher] Stopping launchers
2020-07-17 09:53:28,168 localhost-startStop-2 INFO [c.a.plugin.manager.DefaultPluginManager] Preparing to shut down the plugin system
2020-07-17 09:53:29,039 localhost-startStop-2 INFO [c.a.plugin.manager.DefaultPluginManager] Shutting down the plugin system
2020-07-17 09:53:29,381 Gemini Blueprint context shutdown thread1 INFO averzakov 590x89x1 1uzi5ic 192.168.90.10 /rest/plugins/1.0/ [c.a.jira.plugin.JiraCacheResetter] Start resetting caches triggered by: onPluginModuleDisabled, jiraIsShuttingDown: true
2020-07-17 09:53:29,381 Gemini Blueprint context shutdown thread1 INFO averzakov 590x89x1 1uzi5ic 192.168.90.10 /rest/plugins/1.0/ [c.a.jira.plugin.JiraCacheResetter] Done resetting caches triggered by: onPluginModuleDisabled, timeMillis: 0, jiraIsShuttingDown: true
2020-07-17 09:53:29,382 Gemini Blueprint context shutdown thread1 INFO averzakov 590x89x1 1uzi5ic 192.168.90.10 /rest/plugins/1.0/ [c.a.jira.plugin.JiraCacheResetter] Start resetting caches triggered by: onPluginModuleDisabled, jiraIsShuttingDown: true
2020-07-17 09:53:29,382 Gemini Blueprint context shutdown thread1 INFO averzakov 590x89x1 1uzi5ic 192.168.90.10 /rest/plugins/1.0/ [c.a.jira.plugin.JiraCacheResetter] Done resetting caches triggered by: onPluginModuleDisabled, timeMillis: 0, jiraIsShuttingDown: true
2020-07-17 09:53:29,383 Gemini Blueprint context shutdown thread1 INFO averzakov 590x89x1 1uzi5ic 192.168.90.10 /rest/plugins/1.0/ [c.a.jira.plugin.JiraCacheResetter] Start resetting caches triggered by: onPluginModuleDisabled, jiraIsShuttingDown: true
2020-07-17 09:53:29,383 Gemini Blueprint context shutdown thread1 INFO averzakov 590x89x1 1uzi5ic 192.168.90.10 /rest/plugins/1.0/ [c.a.jira.plugin.JiraCacheResetter] Done resetting caches triggered by: onPluginModuleDisabled, timeMillis: 0, jiraIsShuttingDown: true
2020-07-17 09:53:29,383 Gemini Blueprint context shutdown thread1 INFO averzakov 590x89x1 1uzi5ic 192.168.90.10 /rest/plugins/1.0/ [c.a.jira.plugin.JiraCacheResetter] Start resetting caches triggered by: onPluginModuleDisabled, jiraIsShuttingDown: true...
and in end of log
17-Jul-2020 09:54:01.696 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [JonasBatch] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:502)
org.objectweb.jonas_timer.TimerManager.batch(TimerManager.java:193)
org.objectweb.jonas_timer.Batch.run(TimerManager.java:65)
17-Jul-2020 09:54:01.697 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [JonasClock] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Thread.sleep(Native Method)
org.objectweb.jonas_timer.TimerManager.clock(TimerManager.java:142)
org.objectweb.jonas_timer.Clock.run(TimerManager.java:46)
17-Jul-2020 09:54:01.701 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. Stack trace of request processing thread:
java.lang.Object.wait(Native Method)
java.lang.Thread.join(Thread.java:1249)
java.lang.Thread.join(Thread.java:1323)
...
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
17-Jul-2020 09:54:01.705 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [java.lang.ThreadLocal.SuppliedThreadLocal] (value [java.lang.ThreadLocal$SuppliedThreadLocal@38a5b6a]) and a value of type [com.atlassian.jira.servermetrics.NestedRequestsMetricsCollector] (value [com.atlassian.jira.servermetrics.NestedRequestsMetricsCollector@5b20ea73]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
17-Jul-2020 09:54:01.705 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [java.lang.ThreadLocal.SuppliedThreadLocal] (value [java.lang.ThreadLocal$SuppliedThreadLocal@92f8481]) and a value of type [com.atlassian.jira.servermetrics.NestedRequestKeyResolver] (value [com.atlassian.jira.servermetrics.NestedRequestKeyResolver@166e47a]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
17-Jul-2020 09:54:01.706 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [java.lang.ThreadLocal.SuppliedThreadLocal] (value [java.lang.ThreadLocal$SuppliedThreadLocal@38a5b6a]) and a value of type [com.atlassian.jira.servermetrics.NestedRequestsMetricsCollector] (value [com.atlassian.jira.servermetrics.NestedRequestsMetricsCollector@236bbd55]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
17-Jul-2020 09:54:01.706 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [java.lang.ThreadLocal.SuppliedThreadLocal] (value [java.lang.ThreadLocal$SuppliedThreadLocal@38a5b6a]) and a value of type [com.atlassian.jira.servermetrics.NestedRequestsMetricsCollector] (value [com.atlassian.jira.servermetrics.NestedRequestsMetricsCollector@21eacf64]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
17-Jul-2020 09:54:01.724 INFO [Thread-4] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]
Can you please tell me what to do with this?
The logs you have given us are typical of an ordered shutdown, there's nothing there that tells us that there is something wrong.
But the culprit is quite obvious in your code - you are saying "terminate the current Java Virtual Machine", so the Jira and Tomcat get shut down as the JVM stops.
Remove the System.exit() line, it's killing your Jira.
Yeap my fault, i did not notice this.
Thank you for your reply.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.