I would like to implement a JettyServerCustomizer (or some other similar interface) to customize the management server (running on port 8081). The method customize(Server server) of the classes I implemented so far is called only for the main Jetty server (running on port 8080), when the application starts. How can I make it be called for the management server?
Enable JMX and/or JMX remote modules on standalone Jetty.
All of the various ThreadPools, along with many other components, will be available in JMX for you to access.
For embedded-jetty, do this ...
Server server = newServer();
MBeanContainer mbContainer = new MBeanContainer(
ManagementFactory.getPlatformMBeanServer());
server.addBean(mbContainer);
ConnectorServer jmx = new ConnectorServer(
new JMXServiceURL(
"rmi",
null,
1999,
"/jndi/rmi://localhost:1999/jmxrmi"),
"org.eclipse.jetty.jmx:name=rmiconnectorserver");
server.addBean(jmx);
Related
We have system tests and when they start an Embedded Jetty boots via the setup. The Embedded Jetty includes a JMX server, too. Then we have tests which must connect to the JMX Server via:
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:<JMX_PORT>/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
The problem is we cannot connect from the tests to the JMX server when we do not know the JMX port up front. Has anybody a clue how to specify the JMX port up front when the Embedded Jetty is built within the source code? The system property stuff is of no help here.
For monitoring WebSphere application server via Perf Mbean
I have choose the either RMI or SOAP connector port to get connection from Adminclient. As following code describes,
Properties localProperties = new Properties();
localProperties.put("type", "RMI");// RMI or SOAP
localProperties.put("host", localhost);
localProperties.put("port", 2809);// connector port
AdminClient client = AdminClientFactory.createAdminClient(props);
So I need same for WebSphere Liberty profile 8.5. There is no detailed about admin console i cannot find the connector port details RMI or SOAP. How to configure or choose connector port and connect to adminclient as above code. what i do in server.xml to enable the RMI or SOAP port.
Liberty doesn't have an admin client like you're using with traditional WAS. You can use JMX to connect to and manage Liberty as explained in the IBM KnowledgeCenter topic. The list of available mbeans for Liberty can be found here.
I am trying to workout a JMX Java client for Zookeeper instance for a custom monitoring web app. As provided in document, Zookeeper provides various statistics through JMX MBeans.
For the excercise, I am running Zookeeper intance locally in standalone mode on Windows 7 Enterprise using following arguments:-
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=10010
-Dzookeeper.jmx.log4j.disable=false
After running my zookeeper intance, I am able to connect to JMX beans using JConsole that correctly shows all the statistics :-
PROBLEM
While trying to connect using my own code I am getting java.net.ConnectException: Connection refused: connect error. Code that I am trying :-
public static void main(String[] args) throws Exception {
// service:jmx:rmi:///jndi/rmi://#{host}:#{port}/jmxrmi
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:10010/jmxrmi");
// This throws java.net.ConnectException !!!
JMXConnector jmxConnector = JMXConnectorFactory.connect(url);
MBeanServerConnection mbeanServerConnection = jmxConnector.getMBeanServerConnection();
ObjectName mbeanName = new ObjectName("org.apache.ZooKeeperService:name0=StandaloneServer_port2181");
ZooKeeperServerMXBean newProxyInstance = MBeanServerInvocationHandler.newProxyInstance(mbeanServerConnection,
mbeanName, ZooKeeperServerMXBean.class, true);
System.out.println("Created zoo mbean proxy");
System.out.println(newProxyInstance.getAvgRequestLatency());
}
Facing same problem while trying to connect using Java Visual VM.
What is the correct way to connect to Zookeeper MBean using Java code ?
UPDATE 1
There is 4 years old unresolved JIRA ticket that seems to be saying that there are two kind of ports that comes into play - jmx port & rmi port. The rmi port is generated randomly & I guess that is what needed while creating connection.
But then how JConsole is able to connect ?
UPDATE 2
This blog says that talking to remote JMX server over RMI protocol might be problem and suggests using JMXMP (JMX-Messaging Protocol) instead.
Now how do I exactly do I do that ?
At startup we need to get the server address and the http port of the running application. Until now we made it like this:
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName socketBindingMBean = new ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
String host = (String) mBeanServer.getAttribute(socketBindingMBean, "boundAddress"),
Integer port = (Integer) mBeanServer.getAttribute(socketBindingMBean, "boundPort"));
Everything was fine but after migration from jBoss 7.1.1.Final to 7.1.3.Final we got the problem that the MBean isn't defined at server startup. That means everything is fine if I deploy the application on an already running jboss server, but if I start the server and the application is loaded up during server start MBeans are not there.
I don't know why but I have the feeling that jBoss makes sure, that out application is started/loaded before most of the MBeans. I had a small look and found out that following Mbeans are loaded after our application:
jboss.as:interface=..
jboss.as:socket-binding-group=..
jboss.as:subsystem=..
jboss.as:core-service=management.. (some)
So,
how can I force jBoss to load MBeans before my application?
is there another way/mbean where I can get my information?
I got the same issue in JBOSS Wildfly 8.1 . I solved the problem with the code below that worked for me to get server address and http port:
//http port
ManagementFactory.getPlatformMBeanServer().getAttribute(new ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http"), "port");
//http adress
ManagementFactory.getPlatformMBeanServer().getAttribute(new ObjectName("jboss.as:interface=public"), "inet-address");
We are implementing an application with a webservice as component and decided to use the Glassfish 3.0 embedded distri to provide the webservice. And it works.
We need a SSL(HTTPS) connection to the webservice, but we didn't find any documentation or hint how to activate it programmatically via the embedded API.
Thus we tried to configure the embedded Glassfish via domain.xml, what has a listener configured with SSL. And the port is reachable but only without SSL. The embedded Glassfish seem to ignore the configuration to activate SSL for the port.
Has anyone experience in configuring embedded Glassfish with SSL?
Ok,
sorry that it took so much time for my answer.
The programmatical embedded API seems not to porvide a way to do this task.
Except to run an asadmin command:
logger.debug("Configure port for SSL");
String command = "create-http-listener";
ParameterMap params = new ParameterMap();
params.add("listeneraddress", "0.0.0.0");
params.add("listenerport", "443");
params.add("defaultvs", "server");
params.add("securityenabled", "true");
params.add("enabled", "true");
params.add("DEFAULT", "http-listener2");
CommandRunner runner = server.getHabitat().getComponent(CommandRunner.class);
ActionReport report = server.getHabitat().getComponent(ActionReport.class);
runner.getCommandInvocation(command, report).parameters(params).execute();
Running this code is simmlar to execute:
asadmin create-http-listener --listeneraddress 0.0.0.0 --listenerport 443 --defaultvs server securityenabled=true --enabled=true http-listener2
But this solution creates a new port with SSL. Reconfigure the already started port would be a nice option.