It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do you find port number where JIRA/apache is on?

Danny Hendargo Jun 20, 2013

Using scriptrunner, code below seems to find Catalina server and the port number (8080). However, if run from within a plugin on the same JIRA instance, Catalina is not found and service is null.

Any insight is appreciated. Thank you in advance.

import org.apache.catalina.Server;
import org.apache.catalina.ServerFactory;
import org.apache.catalina.Service;
import org.apache.catalina.connector.Connector;

int portNumber = 0;
Server server = ServerFactory.getServer();
try {
    Service service = server.findService("Catalina");
    // service is null if this were run from within a plugin. 
    Connector[] conn = service.findConnectors();
    portNumber = conn[0].getPort();
}
catch (NullPointerException e) {
    System.out.println(e.toString()); 
    // java.lang.NullPointerException: Cannot invoke method findConnectors() on null object
}
System.out.println(portNumber);
// 0 when run from within plugin. 8080 when run from scriptRunner.

1 answer

0 votes
Rodrigo Adami Atlassian Team Aug 18, 2013

Hi Danny,

I'm not very keen in the plugin coding, however if you can get the port from the file Catalina_home/conf/server.xml that should also work. The port is located inside that file and if you can reach that file then you might be able to fetch the port number from the file.

Just an idea. :)

Regards,

Rodrigo

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Webinar alert! An IT Admin's Guide to Securing Collaboration at Scale

Hello, Atlassian Community! My name is Dave Meyer and I'm a Principal Product Manager at Atlassian. I wanted to give this community a heads up about an upcoming Webinar that might be of interest...

175 views 2 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you