Hi all, I tried the fix that was suggested and now the following exception gets thrown.
java.io.IOException: Failed to retrieve RMIServer stub: > javax.naming.NamingException: Tenants cannot close the context. > at > javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:338) > at > javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248) > at > org.wso2.carbon.bam.jmx.agent.JmxAgentWebInterface.getMBeans(JmxAgentWebInterface.java:253) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > .............................. > .............................. > .............................. .............................. > Caused by: javax.naming.NamingException: Tenants cannot close the context. > at > org.wso2.carbon.context.internal.CarbonContextDataHolder$CarbonInitialJNDIContext.close(CarbonContextDataHolder.java:1147) > at javax.naming.InitialContext.close(InitialContext.java:531) > at > javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1887) > at > javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1856) > at > javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:255) > ... 73 more > > On Mon, Dec 3, 2012 at 12:07 PM, Ishan Somasiri <ish...@wso2.com> wrote: > Hi all, > > I logged in as a tenant to BAM and tried to access the MBeans list of BAM > using a deployed carbon component (More specifically, using the JMX agent). > > But when the method javax.management.remote.JMXConnectorFactory.connect() > is called an exception gets thrown. > > > Caused by: java.lang.IllegalArgumentException: rmiURLContext: name is not >> an RMI URL: 1 >> at >> com.sun.jndi.url.rmi.rmiURLContext.getRootURLContext(rmiURLContext.java:47) >> at >> com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:182) >> at >> org.wso2.carbon.context.internal.CarbonContextDataHolder$CarbonInitialJNDIContext.getInitialContext(CarbonContextDataHolder.java:965) >> at >> org.wso2.carbon.context.internal.CarbonContextDataHolder$CarbonInitialJNDIContext.lookup(CarbonContextDataHolder.java:1030) >> at javax.naming.InitialContext.lookup(InitialContext.java:392) >> at >> javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1886) >> at >> javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1856) >> at >> javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:255) >> at >> javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248) >> at >> org.wso2.carbon.bam.jmx.agent.JmxAgentWebInterface.getMBeans(JmxAgentWebInterface.java:253) >> ... 71 more >> >> > So I debugged the > org.wso2.carbon.context.internal.CarbonContextDataHolder.getInitialContext() > method. Whether the user is a tenant or the admin (this works fine for > admin), the parameter (*name*) passed to the *getInitialContext *method > is *rmi://localhost:9999/jmxrmi*. > > If the user is *admin*, base(initialContext) is returned because of the > following line segment. > > if (!isSubTenant(tenantId)) { >> return base; >> } >> > > But if the user is a tenant, all the following if conditions becomes false. > > if (!isSubTenant(tenantId)) { >> return base; >> } else if (scheme != null) { >> if (allTenantUrlContextSchemes.contains(scheme)) { >> return base; >> } else if >> (superTenantOnlyUrlContextSchemes.contains(scheme)) { >> throw new SecurityException("Tenants are not allowed >> to use JNDI contexts " + >> "with scheme: " + scheme); >> } >> } > > > So the tenant ID is passed to the *base.lookup* method thus causing the > above exception. > > > Will it cause problems if I add the following line to the above code so > that *base *is returned if the scheme is rmi? > > if (!isSubTenant(tenantId)) { >> return base; >> } else if (scheme != null) { >> if (allTenantUrlContextSchemes.contains(scheme)) { >> return base; >> } else if >> (superTenantOnlyUrlContextSchemes.contains(scheme)) { >> throw new SecurityException("Tenants are not allowed >> to use JNDI contexts " + >> "with scheme: " + scheme); >> } >> > * } else if ("rmi".equalsIgnoreCase(scheme)) { >> * > > * return base; >> } * >> > } > > > > Or is there any proper way to fix this...? > -- > Thanks! > -- > Ishan Thilina Somasiri > www.blog.ishans.info > > -- Thanks! -- Ishan Thilina Somasiri www.blog.ishans.info
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev