JMX RMI Plugin
Hi All,
I have a login application using JSP Struts and Spring. XML is used in the backend to validate the username/password.This is working fine.
Now I need to change the backend from xml to RMI object that should be able to set the value on an JMX MBean deployed on a separate JBOSS server.
Any help would be very much useful.
Thanks in Advance.
Hi,
I am not sure which kind of help you're asking for.
If what you need is to learn a bit about JMX and JMX Remote API, then
here is where to start from:
http://java.sun.com/docs/books/tutorial/jmx/
Additional links to JMX docs & tutorial can be found here:
http://blogs.sun.com/jmxetc/entry/looking_for_jmx_overview_examples
If your main concern is about security issues then here is where to look
for:
http://blogs.sun.com/lmalventosa/entry/jmx_authentication_authorization
hope this helps,
-- daniel
http://blogs.sun.com/jmxetc
Similar Messages
-
In the JMX example, it starts a Server application.
Basically it initiates the MBeanServer, creates the RMI ConnectorServer
and then starts the connector and that is it as far as the code goes.
Why does the server application not exit but continue to run? Is that because the RMI connector server is listening for incoming connections?
Is another thread created to do this?
// Create an RMI connector server
System.out.println("\nCreate an RMI connector server");
JMXServiceURL url = new JMXServiceURL(
"service:jmx:rmi:///jndi/rmi://localhost:9999/server");
JMXConnectorServer cs =
JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
// Start the RMI connector server
System.out.println("\nStart the RMI connector server");
cs.start();
System.out.println("\nRMI connector server successfully started");
System.out.println("\nWaiting for incoming connections...");Hi DongWoo,
Very nice diagram, thanks for posting this! I envy your drawing skills :-)
Do you mind if I update my blog posts:
JMX: Connecting Through Firewalls Using RMI Over SSL And a Single Port (Part III)
http://blogs.sun.com/jmxetc/entry/jmx_connecting_through_firewalls_using
and
Troubleshooting connection problems in JConsole
http://blogs.sun.com/jmxetc/entry/troubleshooting_connection_problems_in_jconsole
to link to it?
Best regards,
-- daniel
http://blogs.sun.com/jmxetc -
Shutting down default JMX RMI port
I am starting up my JMX agent for remote access and it opens 2 ports, one which is set by the -Dcom.sun.management.jmxremote.port=XXXX and one randomly assigned port.
I know I can install a custom JMX agent to specify another RMI port that I can control, but what I really want to do is shut down the randomly assigned one. The problem is that weve a port monitoring app, so I can't open any ports open that I cannot control with causing IT to complain. Is there any way to disable this connector?
Thanks,
MarkHi,
Please have a look at these articles:
[http://blogs.sun.com/jmxetc/tags/firewall|http://blogs.sun.com/jmxetc/tags/firewall]
they should answer your questions.
Best regards,
-- daniel
JMX, SNMP, Java, etc...
[http://blogs.sun.com/jmxetc|http://blogs.sun.com/jmxetc] -
32-bit JMX/RMI Remote Connection to 64-bit
I am trying to connect to the standard JDK5 JMX server running on RedHat 64-bit Linux from a 32-bit Windows box and continually get Connection refused. Both are running JDK 1.5.0_05, 64-bit version on Linux, 32-bit version on Windows.
Is there a problem connecting between 64-bit and 32-bit OSes? I don't understand "connection refused" if that is the problem.
There is no NAT and no firewall. I am able to connect to other Java services on that box, just not the JMX server. I can browse the RMI Registry on that machine (using the RMI Explorer plug-in from IDEA) but when I try to execute any of the methods I get Connection refused: connect at java.net.PlainSocketImpl.socketConnect. I know I'm connecting to the standard JMX registry because I can see the jmxrmi registry object with methods getVersion() and newClient(). I get the exception when I try to execute, say, the getVersion() method.
JConsole is also not able to connect remotely.
I am, however, able to connect from code running locally on the Linux box. But I am not able to connect from code running on the Windows client through an SSH tunnel.
It appears that 64-bit and 32-bit JVMs cannot communicate over RMI, but is there another explanation?
RobertI have the same problem using jmx through a ssh-tunnel.
Neither programmatically by JMXConnector nor with jconsole it is possible to connect. It seems that the initial request works but then some kind of redirect forces a connect to the endpoint which is not possible at the other side of the tunnel. Instead it should use the local tunnel-port.
So I get "connection refused" for an ip-address that is surely not available from my desktop.
I found several similar problem-descriptions in different newsgroups but no answers how to solve it. -
JMX/RMI and Automatic Code Downloading
There is a brief discussion of automatic code downloading in the JMX Best Practices document (http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/best-practices.jsp#mozTocId348704), but not enough to actually implement it.
Would someone be kind enough to point me to some documentation on the subject, and/or maybe provide a few pointers?
Thanks!
SteveHi Steve,
If you want to know more about RMI dynamic code downloading have a look at the following link:
http://download.java.net/jdk6/docs/technotes/guides/rmi/codebase.html
You should also know that you can supply a ClassLoader to both the JMXConnectorServer and JMXConnector at instantiation time in the environment map. This ClassLoader will be used by the JMX connectors to serialize/deserialize the method parameters and return values when getting and setting attributes, or invoking operations on a given MBean.
If you want to know more about how classloading works within the JMX connectors have a look at Chapter 13 "Connectors" in the JMX 1.4 specification:
http://download.java.net/jdk6/docs/technotes/guides/jmx/JMX_1_4_specification.pdf
Regards,
Luis-Miguel Alventosa
JMX Java SE development team
Sun Microsystems, Inc. -
Memory leak with t3 jmx connection
Hello all,
I've created a monitoring plugin for WebLogic 9.x / 10.x servers which polls a target server at regular interval. Each time the plugin needs the performance data, it creates a new JMXConnector and get the associated MBeanServerConnection. Everything works fine, but after a significant number of requests, the client process runs out of memory. When analayzing the client heapdump, I can see there is a lot of instances of the following classes:
weblogic.corba.client.security.ClientSecurityContext
javax.security.auth.Subject
All these instances are retained in a unique HashMap. It doesn't look like there is a problem in my code as all the objects I'm creating are well garbage collected (no JMXConnector or MBeanServerConnection instances).
I've tried almost everything to get rid off this issue (using t3, using iiop, changing the parameters used to create the connector), I tried to set the jmx.remote.x.client.connection.check.period to 0 but nothing changes. The current workaround is to cache the JMXConnector instances for each server, but this is not fully satisfying (connection loss if target server restarts, etc...).
Did someone experiment the same kind of issue ? I provide below a code snippet of the connection factory I'm using (I put both wljmxclient.jar and wlclient.jar in the client classpath):
private static final String JNDI_NAME = "/jndi/weblogic.management.mbeanservers.runtime";
public static MBeanServerConnection getInstance(Map<String,String> params) {
Map<String,String> map = new HashMap<String,String>();
JMXServiceURL url = null;
JMXConnector connector = null;
MBeanServerConnection connection = null;
map.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote");
map.put("java.naming.security.principal", params.get("username"));
map.put("java.naming.security.credentials", params.get("password"));
try {
url = new JMXServiceURL("service:jmx:t3://" + params.get("hostname") + ":" + params.get("port") + JNDI_NAME);
connector = JMXConnectorFactory.connect(url, map);
connection = connector.getMBeanServerConnection();
} catch (Exception e) {
throw new RuntimeException("Unable to get MBeanServerConnection for JMXServiceURL " + url.toString());
return connection;
}Thanks for helping.
YannHello KK, thanks for your answer.
I also thought to the cache possibility, but it's not as straightforward to manage (target server restart, keepalive, etc...). A call to connector.close() does not change anything, the objects I'm creating are well garbage collected. The only solution I've found to get rid of this memory leak is to perform an anonymous iiop lookup, i.e. creating first a iiop user (group Monitors), set default iiop user and password for each target server, and changing the factory code to:
private static final String JNDI_NAME = "/weblogic.management.mbeanservers.runtime";
public static MBeanServerConnection getInstance(Map<String,String> params) {
Map<String,String> map = new HashMap<String,String>();
JMXServiceURL url = null;
JMXConnector connector = null;
MBeanServerConnection connection = null;
map.put("jmx.remote.x.client.connection.check.period", "0");
try {
url = new JMXServiceURL("service:jmx:rmi:///jndi/iiop://" + params.get("hostname") + ":" + params.get("port") + JNDI_NAME);
connector = JMXConnectorFactory.connect(url, map);
connection = connector.getMBeanServerConnection();
} catch (Exception e) {
throw new RuntimeException("Unable to get MBeanServerConnection for JMXServiceURL " + url.toString());
return connection;
}I don't like this solution as this implies to change the target server configuration plus it has an impact on security. -
How to connect to remote server with jmx from jvisualvm
I have a WL 10.3.2 domain running on a single box. The adminserver and managed server are running on the same box, on different ports (7001 and 8001, respectively).
I have a Spring application deployed to the managed server and I've configured it to register a Spring bean as a JMX mbean.
When I run this entire configuration on my laptop, I can run jvisualvm and connect to my server and see and manipulate my registered mbean.
I'm having trouble figuring out how to get a remote connection working, however. I want to run jvisualvm on my laptop and connect to the remote server.
I first did "Add Remote Host", where I specified the IP address. It appears that this was created successfully, and it apparently was able to determine the DNS name for it.
I then tried to add a JMX connection. In the "Connection" field, I just entered the IP address followed by a colon and 8001 (managed server port number).
In the "Use security credentials" section, I entered the weblogic admin principal and credentials.
When I click OK, it chugs for a while and eventually gives up, saying:
Cannot connect to [email protected]:8001 using
service:jmx:rmi:///jndi/rmi://nn.nn.nn.nn:8001/jmxrmi
What might I be missing?I've resolved this. At least I was able to configure an authenticated connection. It doesn't use SSL yet, but I'm ok with that for a while.
Resolving this only required changing the command line parameters for the managed server, and being aware of the "jmxremote.access" and jmxremote.password" files. The following blog article helped a lot: [http://www.dzone.com/links/r/monitoring_your_java_application_with_jmx_part_2.html] .
I'm now passing the following command-line parameters:
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true
The default "role" configured in "jmxremote.access" is "controlRole", and the "jmxremote.password" file specifies the credentials for that principal. I simply used that principal and credential in JVisualVM, and the connection succeeded.
And I just used the "host:port" form, not the protocol form.
Edited by: david.karr on Feb 4, 2011 12:47 PM -
Applet java.rmi.RemoteException class not found
Hi,
my applet uses the RMI connection to server. Applet working fine with appletviewer. i try to load my applet in IE its giving class not found error.
error message :
java.lang.ClassNotFoundException: java.rmi.RemoteException
at com/ms/vm/loader/URLClassLoader.loadClass
at java/lang/ClassLoader.loadClassInternal
at comp345/lab5/InventoryApplet.init
at com/ms/applet/AppletPanel.securedCall0
at com/ms/applet/AppletPanel.securedCall
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run
any idea, about this.
-ThanksI found the solution for this. my IE browser is not having java RMI plugin. this plugin you can download from IBM or Microsoft site.
IMB site download file name.
RmiPatch.zip -
How to Enable JMX Console in the Weblogic 10.3
Note : Sorry, i am cross posting this thread from "management", but this is extremely urgent for me and i did not get any response from yesterday. Hope to have a solution atleast from this group.
I have an application that is JMX enabled. It has its own JMX Agent and some MBeans. When i deploy and launch the application in WebLogic, i am able to connect to the JMX agent via JConsole with the RMI url.
But when i get into the Weblogic console, i can not see any JMX consoles! So, basically i am trying to see if there is any JConsole equivalent stuff in Weblogic and how to enable it.
How can i enable the JMX console in Weblogic ?
Edited by: SureshKrishna on Jun 19, 2009 10:38 AMI suggest also this
http://www.performanceengineer.com/blog/monitoring-weblogic-using-jmx/
To enable JXM you should add these in the startup script of the server:
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
then you can access from Jconsole putting this URL in :
service:jmx:rmi:///jndi/rmi://127.0.0.1:8888/jmxrmi
Edited by: user3873926 on 19-giu-2009 11.53 -
Hi,
I have an multi MBean servers running on diffrent JBoss(not JBoss Mbean server).(server)
I have another MBean server running also on another JBoss (client)
Server Side
private CSAPLMBeanFactory()
// aachour for SSL enabling
// Get the JBoss MBean Server -- Note the JBOSS specific locator ...
log_.info("Instantiate the CSAPL MBean factory");
// localMBeanServer_ = org.jboss.mx.util.MBeanServerLocator.locateJBoss();
try
String cSAPLMbsHost = CSAPLConfiguration.getInstance().getHost();
int cSAPLMbsPort = CSAPLConfiguration.getInstance().getCsaplMBSPort_();
String address = cSAPLMbsHost + ":" + cSAPLMbsPort;
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
HashMap env = new HashMap();
RMIClientSocketFactory csf = new SslRMIClientSocketFactory();
RMIServerSocketFactory ssf = new SslRMIServerSocketFactory();
env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf);
env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, ssf);
try
LocateRegistry.createRegistry(cSAPLMbsPort);
System.out.println("RMI registry ready.");
catch (Exception e)
System.out.println("Exception starting RMI registry:");
e.printStackTrace();
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + address + "/CSAPL");
JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
cs.start();
localMBeanServer_ = mbs;
catch (Exception e)
e.printStackTrace();
plLogName_ = CSAPLConfiguration.getInstance().getPLLogicalName();
}Client side :method to connect to the MBean server
public synchronized MBeanServerConnection getMBeanServer() throws CSAPLException
if (server == null)
String address = host + ":" + port;
if (log.isTraceEnabled())
log.trace("Getting reference to mbean server connection in " + address);
try
Hashtable env = new Hashtable();
if (certifPath != null)
env.put("javax.net.ssl.trustStore", certifPath);
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + address + "/CSAPL");
JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
server = jmxc.getMBeanServerConnection();
catch (Exception e)
log.error("cannot get reference to mbean server connection");
if (e instanceof javax.naming.NameNotFoundException)
log.error("Could not contact server address " + host);
}The problem is that I have this exception on client side:
java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
I don't want to use the
System.setProperty ("javax.net.ssl.trustStore", certifPath)because I have other application running on the same JVM using diffrent SSL certificate .
Please help me it is very urgent1. Note:250532.1 Configuring HTTP Server to Use SSL in Oracle Application Server 10g (9.0.4)
2. Note:250648.1 Configuring Web Cache with SSL in Oracle Application Server 10G (9.0.4)
3. Note:251046.1 How to Configure SSL for Single-Sign On Applications in Oracle Application Server 10g (9.0.4)
4. Also, see: Oracle OID administrator's Guide, Oracle SSO Administration Guide, Oracle SCA Guide, Oracle Portal Configuration Guide and Oracle Application Server Administrator's Guide. -
i have a problem connecting a jmx client to camel. i just wanna connect to the default MBeans exposed by camel
so it shouldn't be much of a problem but it appears that it is ( for me :) )
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://MHO-WS-014:1099/camel");
JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
i can get a list of the domains .. so i know the connection is made
when i monitor jcamel with jconsole .. i see the name of a bean as : ManagedService
ObjectName stdMBeanName = new ObjectName("org.apache.camel.management:type=ManagedService");
String attrValue = (String)mbsc.getAttribute(stdMBeanName, "started");
but when i try to read an attribute from it i get :
javax.management.InstanceNotFoundException: org.apache.camel.management:type=ManagedService
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(Unknown Source)
at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(Unknown Source)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(Unknown Source)
at javax.management.remote.rmi.RMIConnectionImpl.access$200(Unknown Source)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(Unknown Source)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(Unknown Source)
at javax.management.remote.rmi.RMIConnectionImpl.getAttribute(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
at javax.management.remote.rmi.RMIConnectionImpl_Stub.getAttribute(Unknown Source)
at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getAttribute(Unknown Source)
at monex.MonexJMXClient.main(MonexJMXClient.java:102)You might try adding a call to [MBeanServerConnection.queryNames(null,null)|http://java.sun.com/javase/6/docs/api/javax/management/MBeanServerConnection.html#queryNames(javax.management.ObjectName,%20javax.management.QueryExp)] to your custom client code and iterating over that list to see if the MBean Object Name you expected is registered. You can also use the [MBeanServerConnection.isRegistered|http://java.sun.com/javase/6/docs/api/javax/management/MBeanServerConnection.html#isRegistered(javax.management.ObjectName)] method.
-
JMX example LDAP lookup not working
Hi,
Section 4.4 of JMX tutorial has several examples of Server.java using LDAP lookup services. I'm trying to run the RMI connector over JRMP without an external directory. Here are the command and its results (with additional tracing):
$ java -classpath . -Xdebug -Ddebug=true -Dagent.name=test-server-a
-Durl="service:jmx:rmi://" -Djava.naming.provider.url="$provider" -Djava.naming.security.principal="$principal" -Djava
.naming.security.credentials="$credentials" jndi.Server
Creating MBeanServer...
Creating Connector: service:jmx:rmi://
In rmi()
Context.SECURITY_CREDENTIALS is: java.naming.security.credentials
Entry: java.naming.security.authentication simple
Entry: java.naming.provider.url ldap://localhost:389/dc=Test
Entry: java.naming.security.principal cn=Manager,dc=test
Entry: jmx.remote.jndi.rebind true
Entry: java.naming.security.credentials secret
Creating RMI Connector: service:jmx:rmi://
In start()
In getRootContext()
java.naming.provider.url=ldap://localhost:389/dc=Test
java.naming.security.principal=cn=Manager,dc=test
java.naming.security.credentials=******
In register()
dn: cn=test-server-a
Unexpected exception caught in main: javax.naming.directory.InvalidAttributeValueException: [LDAP: error code 21 - objec
tClass: value #1 invalid per syntax]; remaining name 'cn=test-server-a'
javax.naming.directory.InvalidAttributeValueException: [LDAP: error code 21 - objectClass: value #1 invalid per syntax];
remaining name 'cn=test-server-a'
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:2998)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2931)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2737)
at com.sun.jndi.ldap.LdapCtx.c_createSubcontext(LdapCtx.java:770)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_createSubcontext(ComponentDirContext.java:319)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.createSubcontext(PartialCompositeDirContext.java:248)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.createSubcontext(PartialCompositeDirContext.java:236)
at jndi.Server.register(Server.java:238)
at jndi.Server.start(Server.java:396)
at jndi.Server.rmi(Server.java:364)
at jndi.Server.main(Server.java:492)
I'm using OpenLDAP (with Cygwin) on a Windows XP machine. I have also rmiregistry running in the background. Since I'm executing slapd -d -1, OpenLDAP shows that it is encountering the error here:
conn=0 op=3 ADD dn="cn=test-server-a,dc=Test"
send_ldap_result: conn=0 op=3 p=3
send_ldap_result: err=21 matched="" text="objectClass: value #1 invalid per syntax"
send_ldap_response: msgid=4 tag=105 err=21
ber_flush: 54 bytes to sd 8
0000: 30 34 02 01 04 69 2f 0a 01 15 04 00 04 28 6f 62 04...i/......(ob
0010: 6a 65 63 74 43 6c 61 73 73 3a 20 76 61 6c 75 65 jectClass: value
0020: 20 23 31 20 69 6e 76 61 6c 69 64 20 70 65 72 20 #1 invalid per
0030: 73 79 6e 74 61 78 syntax
ldap_write: want=54, written=54
0000: 30 34 02 01 04 69 2f 0a 01 15 04 00 04 28 6f 62 04...i/......(ob
0010: 6a 65 63 74 43 6c 61 73 73 3a 20 76 61 6c 75 65 jectClass: value
0020: 20 23 31 20 69 6e 76 61 6c 69 64 20 70 65 72 20 #1 invalid per
0030: 73 79 6e 74 61 78 syntax
conn=0 op=3 RESULT tag=105 err=21 text=objectClass: value #1 invalid per syntax
Does this mean there is a configuration problem with OpenLDAP (something missing in the schema)? Or does the problem lie elsewhere? Your guidance will be highly appreciated. Thanks!Hello,
I am using example at http://www.cris.com/~adhawan/tutorial/ with OpenLDAP on WinXP.
I am getting following error message when I execute the MakeRoot java class
javax.naming.directory.InvalidAttributeValueException: [LDAP: error code 21 � objectClass: value #0 invalid per syntax]; remaining name 'o=jndiTest'
Please help.
Regards,
Atul Mathur -
HI all im really not sure how to fix this error that im having, to be honest im not really sure what i have done wrong, or where im going wrong with pulling information from my interface or and implimentation.
Okies here is all the code
Interface:
public interface RMIServ
extends java.rmi.Remote {
public String PassCheck(String pass, String user)
throws java.rmi.RemoteException;
Implimentation:
public class RMIServImpl
extends
java.rmi.server.UnicastRemoteObject
implements RMIServ {
// Implementations must have an
//explicit constructor
// in order to declare the
//RemoteException exception
public RMIServImpl()
throws java.rmi.RemoteException {
super();
public String PassCheck(String pass, String user)//takes the user and switch number
throws java.rmi.RemoteException {
String result;
int password = Integer.parseInt(pass);//converts the string to an int
int info = Integer.parseInt(user);//converts the string to an int
if (password==72)//checks password
switch(info) //start switch.
case 1: result="Hello my name is Gareth Gates.";break;
case 2: result= "My student number is 0302814.";break;
case 3: result= "I am Taking Computer Science and Robotics.";break;
case 4: result= "This semester i am taking 4 units, this is one.";break;
case 5: result= "my project is on server times.";break;
case 6: result= "i live in luton during the week.";break;
case 7: result= "i work in a garden centre.";break;
case 8: result= "please let me know what you think of my server.";break;
case 9: result= "Email: [email protected]";break;
case 10: result= "Email me any time, thanks.";break;
default : result= "You entered a number bigger then 10 please try again.";break;
} //end switch.
return result; //sends string back to client.
else
return result= "You entered the wrong password";//send back an error
Server:
import java.rmi.Naming;
public class RMIServServer {
public RMIServServer() {
try {
RMIServ c = new RMIServImpl();
Naming.rebind("rmi://localhost:1099/RMIServService", c);
} catch (Exception e) {
System.out.println("Trouble: " + e);
public static void main(String args[]) {
new RMIServServer();
Client:
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.net.MalformedURLException;
import java.rmi.NotBoundException;
import javax.swing.*;
public class RMIServClient {
public static void main(String[] args) {
try {
RMIServ c = (RMIServ)
Naming.lookup("rmi://localhost/RMIServService");
String password = JOptionPane.showInputDialog("Please enter your password");
if (password == c.PassCheck(pass)){
JOptionPane.showMessageDialog(null, "Password Correct");
catch (MalformedURLException murle) {
System.out.println();
System.out.println(
"MalformedURLException");
System.out.println(murle);
catch (RemoteException re) {
System.out.println();
System.out.println(
"RemoteException");
System.out.println(re);
catch (NotBoundException nbe) {
System.out.println();
System.out.println(
"NotBoundException");
System.out.println(nbe);
catch (
java.lang.ArithmeticException
ae) {
System.out.println();
System.out.println(
"java.lang.ArithmeticException");
System.out.println(ae);
Any light that you could shed on my problem would be much appreciated, thanks for the help in advance
the bold is where my problem lies
Joe de Ronde
Message was edited by:
joederondetry
String password = JOptionPane
.showInputDialog("Please enter your password");
if (password == c.PassCheck(password, "username")) {
JOptionPane.showMessageDialog(null, "Password Correct");
}Also your implementation is wrong, you better take a look at some examples (like the java tutorial, including the rmi tutorial, or if you're using eclipse there are some working ready to use examples in the rmi plugin for eclipse (google it). -
Hi ,
I am trying to implement SSL with JMX. I took the example of Luis Miguel Alventosa to see how it works. I imported all the classes, password a access properties file. When I am able to start the MyApp server in the example. But when I am trying to run MyClient, it is giving me the following exception
Initialize the environment map
Create an RMI connector client and connect it to the RMI connector server
Exception in thread "main" java.rmi.ConnectIOException: Exception creating connection to: <IP>; nested exception is:
java.net.SocketException: Default SSL context init failed: null
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at com.example.MyClient.main(MyClient.java:30)
Caused by: java.net.SocketException: Default SSL context init failed: null
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(Unknown Source)
at javax.rmi.ssl.SslRMIClientSocketFactory.createSocket(Unknown Source)
... 6 moreHere is the MyApp code I used
package com.example;
import java.lang.management.*;
import java.rmi.registry.*;
import java.util.*;
import javax.management.*;
import javax.management.remote.*;
import javax.management.remote.rmi.*;
import javax.rmi.ssl.*;
public class MyApp {
public static void main(String[] args) throws Exception {
// Ensure cryptographically strong random number generator used
// to choose the object number - see java.rmi.server.ObjID
System.setProperty("java.rmi.server.randomIDs", "true");
// Start a secure RMI registry on port 3000.
System.out.println("Create a secure RMI registry on port 3000");
SslRMIClientSocketFactory csf = new SslRMIClientSocketFactory();
SslRMIServerSocketFactory ssf = new SslRMIServerSocketFactory(null, null, true);
Registry registry = LocateRegistry.createRegistry(3000, csf, ssf);
// Retrieve the PlatformMBeanServer.
System.out.println("Get the platform's MBean server");
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
// Environment map.
System.out.println("Initialize the environment map");
Map<String,Object> env = new HashMap<String,Object>();
// Provide the password file used by the connector server to
// perform user authentication. The password file is a properties
// based text file specifying username/password pairs.
env.put("jmx.remote.x.password.file", "password.properties");
// Provide the access level file used by the connector server to
// perform user authorization. The access level file is a properties
// based text file specifying username/access level pairs where
// access level is either "readonly" or "readwrite" access to the
// MBeanServer operations.
env.put("jmx.remote.x.access.file", "access.properties");
// Create and start an RMI connector server.
// As specified in the JMXServiceURL the RMIServer stub will be
// registered in the RMI registry running in the local host on
// port 3000 with the name "jmxrmi". This is the same name the
// out-of-the-box management agent uses to register the RMIServer
// stub too.
// JMXServiceURL = "service:jmx:rmi:///jndi/rmi://:3000/jmxrmi"
System.out.println("Create and start an RMI connector server");
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
RMIJRMPServerImpl server = new RMIJRMPServerImpl(3000, csf, ssf, env);
RMIConnectorServer cs = new RMIConnectorServer(url, env, server, mbs);
cs.start();
registry.bind("jmxrmi", server);
System.out.println("Waiting for incoming connections...");
}Here is the MyClient
package com.example;
import java.rmi.registry.*;
import java.util.*;
import javax.management.*;
import javax.management.remote.rmi.*;
import javax.rmi.ssl.SslRMIClientSocketFactory;
public class MyClient {
public static void main(String[] args) throws Exception {
// Environment map
System.out.println("\nInitialize the environment map");
Map<String,Object> env = new HashMap<String,Object>();
// Provide the credentials required by the server to successfully
// perform user authentication
String[] credentials = new String[] { "username" , "password" };
env.put("jmx.remote.credentials", credentials);
// Create an RMI connector client and
// connect it to the RMI connector server
System.out.println("\nCreate an RMI connector client and " +
"connect it to the RMI connector server");
SslRMIClientSocketFactory csf = new SslRMIClientSocketFactory();
Registry registry = LocateRegistry.getRegistry(null, 3000, csf);
RMIServer stub = (RMIServer) registry.lookup("jmxrmi");
RMIConnector jmxc = new RMIConnector(stub, env);
jmxc.connect(env);
// Get an MBeanServerConnection
System.out.println("\nGet an MBeanServerConnection");
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
// Get domains from MBeanServer
System.out.println("\nDomains:");
String domains[] = mbsc.getDomains();
for (int i = 0; i < domains.length; i++) {
System.out.println("\tDomain[" + i + "] = " + domains);
// Get MBean count
System.out.println("\nMBean count = " + mbsc.getMBeanCount());
// Close MBeanServer connection
System.out.println("\nClose the connection to the server");
jmxc.close();
System.out.println("\nBye! Bye!");
Here is the password.properties
monitorRole mrpasswd
controlRole crpasswdand access.properties
monitorRole readonly
controlRole readwriteI used the following jvm parameters to run the apps
-Djavax.net.ssl.keyStore=.keystore -Djavax.net.ssl.keyStorePassword=keypass -Djavax.net.ssl.trustStore=proxytruststore -Djavax.net.ssl.trustStorePassword=trustpassI really don't know where I am doing the mistake. Can anyone please give any idea ? For security I didnt disclosed the IP of my mechine in the error, insted I replace it with <IP>Hi,
I assume you did create a keystore and trustore, right?
Could you verify that the paths to these files you give in your java options
are correct?
You could also try to activate debug traces - in particular security traces - see
at the end of this blog:
http://blogs.sun.com/jmxetc/entry/troubleshooting_connection_problems_in_jconsole
This may help you diagnose what is going wrong.
Hope this helps,
-- daniel
JMX, SNMP, Java, etc...
http://blogs.sun.com/jmxetc -
i can get the MBean's name attribute name type descrep in JBOSS but i cannot get the Value of MBean's Attribute. Who can tell me how to get it.....
my code:
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
import javax.management.Attribute;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanInfo;
import javax.management.MBeanOperationInfo;
import javax.management.MBeanParameterInfo;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.modelmbean.ModelMBean;
import javax.naming.InitialContext;
import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
import org.jboss.management.j2ee.MBean;
public class TestJMX {
public static void main(String[] args) throws Exception {
//Get RMIAdaptor Object
Properties pro = new Properties();
pro.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
pro.setProperty("java.naming.provider.url", "jnp://localhost:1099");
pro.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
InitialContext ic = new InitialContext(pro);
RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/rmi/RMIAdaptor");
// Get the MBeanInfo for the JNDIView MBean
ObjectName name = new ObjectName("jboss:service=JNDIView");
MBeanInfo info = server.getMBeanInfo(name);
System.out.println("JNDIView Class: " + info.getClassName());
MBeanOperationInfo[] opInfo = info.getOperations();
System.out.println("JNDIView Operations: ");
Set mbSet = server.queryMBeans(null, null); //
for (Iterator it = mbSet.iterator(); it.hasNext();) {
ObjectInstance oi = (ObjectInstance) it.next();
MBeanInfo mbeaninfo = server.getMBeanInfo(oi.getObjectName());
System.out.println(oi.getObjectName() + " ��-------MBeanName " );
System.out.println(" Class: " + mbeaninfo.getClassName());
for(int i = 0; i < mbeaninfo.getAttributes().length; i++){
System.out.println(" Attriber Name�F" + mbeaninfo.getAttributes().getName());
System.out.println(" Attriber Type�F" + mbeaninfo.getAttributes()[i].getType());
System.out.println(" Attriber Description�F" + mbeaninfo.getAttributes()[i].getDescription());
//System.out.println(" Attriber�F" + ((Attribute) mbeaninfo.getAttributes()[i]).getValue());
for(int i = 0; i < mbeaninfo.getOperations().length; i++)
System.out.println(" Operation�F" + mbeaninfo.getOperations()[i].getName());
//+ value);
System.out.println("MBean count = " + server.getMBeanCount());
Maybe you are looking for
-
I can't open up a Numbers document that was just used yesterday because today, my mac is saying I need the latest Numbers version. But there's no updates available for it...so how do I get the latest version without paying?
-
Belkin KVM makes Acer monitor unrecognisable to OSX
I have bought a belkin KVM. (Belkin Omniview 2-Port KVM Switch with Built-In Cabling, USB) I am using MacOSX 10.5.8 on a MacBookPro. My monitor is not recognised through the Belkin KVM. It IS recognised when I directly connect it to my MBP through a
-
Dual external monitor setup?
I'd like to use dual external monitors, ideally also plus the laptop screen for a total of 3 monitors, with my new 5th gen 17" MBP. I hear that USB-to-DVI options out there due have very poor poor refresh rates and picture quality. I'd like to use th
-
Songs out of Album Order on iPod
All my songs appear in the correct album order in iTunes. But for a few albums they are all jumbled up on my iPod Touch. So for example, one particular album will have all the tracks appearing in ascending order from 1 to 10 in iTunes. However, on th
-
I have Adobe Flash CS3 Video Encoder on my Mac OS X and am trying to convert movies to .flv files. They encode OK, but on playback, the movies are consistently cut off in the middle. Seems other folks are having this problem and are getting no answer