Try compiling this class, running it and see what ports are conflicting:
import java.util.Properties;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.util.Vector;
import java.io.*;
/**
* JRunPR stands for "JRun Port Reporter"
* It is a class that can be run to check all the port
* settings in all the JRun servers in an installation.
* Some ideas for improvement include:
* - Process global.properties settings. Right now it is assumed
* that all the port settings that matter are in local.properties.
* I also didn't want to confuse anyone with weird properties like
* the sniffer service, which monitors port 80 by default and might
* mislead someone into thinking that was an issue.
* - Process only port settings for services that are enabled. Right
* now the only refinement in that area is for the ejb service.
* - Make it find port conflicts
* - Make it fix port conflicts it finds, optionally
* prompting the user interactively for new port
* settings.
* @author: Scott Stirling
* @version: 0.3
*/
public class JRunPR
{
/**
* Constructor takes a String representing the file path to the
* JRUN_HOME directory, also known as the jrun.rootdir.
*/
public JRunPR(String jrunrootdir) throws Exception
{
this.jrunrootdir = jrunrootdir;
try
{
this.servers = this.getServerList();
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
if (servers != null)
{
this.allServersProps = this.getAllServerProps(servers);
}
else
{
throw new Exception("Invalid or incorrect JRun rootdir passed to
constructor.");
}
}
/*
* A <code>String</code> representing the top level
* JRun installation directory. This is used to create
* <code>File</code> objects needed for execution and for
* navigating the standard JRun 3.x directory structure.
*/
private static String jrunrootdir = "";
private Properties servers;
private static Hashtable allServersProps;
public void setJrunrootdir(String s)
{
JRunPR.jrunrootdir = s;
}
public String getJrunrootdir()
{
return jrunrootdir;
}
/** Prints out a usage statement for the user. */
private static void usage()
{
System.out.println("Usage: java JRunPR [ $JRUN_HOME ]");
}
public static void main(String[] args) throws Exception
{
JRunPR jrunPR = null;
if (args.length != 1)
{
usage();
return;
}
else
{
jrunPR = new JRunPR(args[0]);
}
//usage example 1
jrunPR.printPropsWithPorts();
//usage example 2
Vector allUsedPorts = jrunPR.getAllUsedPorts();
Enumeration e = allUsedPorts.elements();
while (e.hasMoreElements())
{
System.out.println((String)e.nextElement());
}
}
/**
* Gets the list of servers from jvms.properties. Derives location of
* jvms.properties from static jrunrootdir. Returns a Properties object
* because each server name is mapped to a file directory in properties
* format (server=/path/to/serverHome).
*/
private static Properties getServerList() throws IOException
{
Properties listOfServers = new Properties();
File jvmsProps = null;
/* open jvms.properties */
try
{
jvmsProps = new File(jrunrootdir+File.separator+"lib"+
File.separator+"jvms.properties");
if (!jvmsProps.exists())
{
throw new IOException(jrunrootdir+File.separator+"lib"+
File.separator+"jvms.properties does not exist");
}
}
catch (SecurityException se)
{
throw new SecurityException("Permission to open "+jrunrootdir+
File.separator+"lib"+File.separator+"jvms.properties
denied.");
}
/* load jvms.properties into a Properties object */
try
{
FileInputStream fis = new FileInputStream(jvmsProps);
listOfServers = new Properties();
listOfServers.load(fis);
}
catch(IOException ioe)
{
throw new IOException("Problem loading jvms.properties.");
}
return listOfServers;
}
/**
* For each server in jvms.properties, loads that server's name and all
* its local.properties as a pair into a Hashtable and returns the
Hashtable.
*/
private static Hashtable getAllServerProps(Properties p)
{
Hashtable allServers = new Hashtable(31);
String serverName = "";
String localPropsPath = "";
File localPropsFile = null;
Properties localProps = null;
FileInputStream fis = null;
Enumeration en = p.propertyNames();
while(en.hasMoreElements())
{
serverName = (String)en.nextElement();
localPropsPath =
(String)p.getProperty(serverName)+File.separator+"local.properties";
try
{
localPropsFile = new File(localPropsPath);
fis = new FileInputStream(localPropsFile);
localProps = new Properties();
localProps.load(fis);
allServers.put(serverName,localProps);
}
catch(IOException ioe)
{
ioe.printStackTrace();
}
}
return allServers;
}
/**
* Print out names and values for properties having port settings.
*/
public void printPropsWithPorts()
{
String key = "";
String value = "";
String serverName = "";
Properties localProps = null;
Enumeration enum = allServersProps.keys();
while(enum.hasMoreElements())
{
serverName = (String)enum.nextElement();
localProps = (Properties)allServersProps.get(serverName);
Enumeration en = localProps.propertyNames();
/* Print out the server name */
System.out.println(serverName+" server");
/* Process the port settings in local.properties */
while(en.hasMoreElements())
{
key = (String)en.nextElement();
value = (String)localProps.get(key);
//remove case sensitivity to catch cases like "homePort."
String lc_key = key.toLowerCase();
if (lc_key.endsWith("port") && !(value.equals("")))
{
System.out.println(key+"="+value);
}
}
System.out.println();
}
}
/**
* Returns a Vector of port numbers (as Strings) that are currently in
use
* by any and all servers.
*/
public Vector getAllUsedPorts()
{
String key = "";
String value = "";
String serverName = "";
Properties localProps = null;
Vector ports = new Vector();
Enumeration enum = allServersProps.keys();
while(enum.hasMoreElements())
{
serverName = (String)enum.nextElement();
localProps = (Properties)allServersProps.get(serverName);
Enumeration en = localProps.propertyNames();
/* Process the port settings in local.properties */
while(en.hasMoreElements())
{
key = (String)en.nextElement();
value = (String)localProps.get(key);
//remove case sensitivity to catch cases like "homePort."
String lc_key = key.toLowerCase();
if (lc_key.endsWith("port") && !(value.equals("")))
{
ports.add(value);
}
}
}
return ports;
}
/**
* Returns all Properties having port settings.
*/
public Properties getPropsWithPorts(Hashtable serverProps)
{
String key = "";
String value = "";
String serverName = "";
Properties localProps = null;
Properties portProps = null;
Enumeration enum = serverProps.keys();
while(enum.hasMoreElements())
{
serverName = (String)enum.nextElement();
localProps = (Properties)serverProps.get(serverName);
Enumeration en = localProps.propertyNames();
/* Print out the server name */
System.out.print(serverName);
/* Process the port settings in local.properties */
while(en.hasMoreElements())
{
key = (String)en.nextElement();
value = (String)localProps.get(key);
//remove case sensitivity to catch cases like "homePort."
String lc_key = key.toLowerCase();
if (lc_key.endsWith("port") && !(value.equals("")))
{
portProps.put(key, value);
}
}
}
return portProps;
}
}
> -----Original Message-----
> From: JOGALEKAR,MAKARAND (HP-Boise,ex1)
> [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 04, 2001 7:26 PM
> To: JRun-Talk
> Subject: RE: Port Conflict
>
>
> Hello,
>
> I have the same problem with the ports. Here is what I am using:
>
> Web server: Netscape Eeterprise Server 3.6
>
> For Jrun Default Server :
> Web Server Port = 8100
> Listening Port = 51000
>
> For another utility server:
> Web Server Port = 8102
> Listening Port = 51002
>
> I tried changing the port numbers lot of times but no luck..
> Any clue...
>
> -Thanks,
> -Makarand
>
>
> I am using two servers
> and two separate port addresses for external web server ( NES 3.6 ).
> The numbers are 51000 and 51002 and
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists