J'ai des problèmes avec l'utilisation de Jolokia conjointement avec un service RMI. Dès que le service RMI est démarré, Jolokia n'est plus accessible via http.Utilisation de l'agent Jolokia avec un serveur RMI
J'ai créé une classe d'exemple pour reproduire le problème:
package com.example.rmi;
import java.net.InetAddress;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
public class RMITest {
private class RMIService extends UnicastRemoteObject {
private static final long serialVersionUID = 1L;
protected RMIService() throws RemoteException {
super();
}
public void doStuff() {
System.out.println("Processing...");
}
}
public static void main(String[] args) throws RemoteException {
RMITest rmiServer = new RMITest();
rmiServer.init();
}
private void init() throws RemoteException {
RMIService rmiService = new RMIService();
try {
System.out.println("Starting RMI-Service...");
String hostname = InetAddress.getLocalHost().getHostName();
System.setProperty("java.rmi.server.hostname", hostname);
int port = 2005;
LocateRegistry.createRegistry(port);
Naming.rebind("rmi://" + hostname + ":" + port
+ "/RMIService", rmiService);
System.out.println("RMI-Service started!");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Si je change la méthode principale pour ne pas démarrer le RMI-Service, Jolokia est accessible via l'URL http http://127.0.0.1:8778/jolokia/ nouveau:
public static void main(String[] args) throws RemoteException {
RMITest rmiServer = new RMITest();
//rmiServer.init();
while(true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Le service est un pot exécutable. Voici la commande que je utilise pour démarrer l'application:
java -javaagent:jolokia-jvm-1.3.7-agent.jar=port=8778,host=localhost -jar RMITest-0.0.1-SNAPSHOT.jar
J'ai téléchargé l'agent Jolokia sur le site officiel: Jolokia Agent Download