You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by "Stephan Siano (JIRA)" <ji...@apache.org> on 2011/02/28 12:54:43 UTC

[jira] Updated: (ARIES-572) NamingException in JMXConnectionFactory.connect() calls with JMX over RMI calls

     [ https://issues.apache.org/jira/browse/ARIES-572?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stephan Siano updated ARIES-572:
--------------------------------

    Attachment: ObjectFactoryHelper.java.patch

getObjectInstanceUsingObjectFactoryBuilders() is using a similar construction, so I attach a patch here

> NamingException in JMXConnectionFactory.connect() calls with JMX over RMI calls
> -------------------------------------------------------------------------------
>
>                 Key: ARIES-572
>                 URL: https://issues.apache.org/jira/browse/ARIES-572
>             Project: Aries
>          Issue Type: Bug
>          Components: JNDI
>    Affects Versions: 0.3, 0.4
>            Reporter: Stephan Siano
>         Attachments: ObjectFactoryHelper.java.patch
>
>
> I get a NamingException with the following bundle activator if aries-jndi is present (I tried the current 0.4-SNAPSOT and 0.3):
> public class Activator implements BundleActivator {
> 	@Override
> 	public void start(BundleContext bundleContext) throws Exception {
> 		Map<String, Object> env = new HashMap<String, Object>();
> 		env.put("osgi.service.jndi.bundleContext", bundleContext);
> 		JMXConnectorFactory.connect(new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1717/jmxrmi"), env);
> 	}
> 	@Override
> 	public void stop(BundleContext arg0) throws Exception {
> 	}
> }
> The bundle context in the environment is necessary to work around another issue.
> The NamingException is thrown by com.sun.jndi.url.rmi.rmiURLContextFactory.getObjectInstance() if the first parameter is not an URL. This method is called from org.apache.aries.jndi.ObjectFactoryHelper.getObjectInstanceUsingObjectFactories(). This method iterates over all registered ObjectFactories to check if there is a better implementation than the one provided in the first argument, however if it comes to Sun's object factory the NamingException occurs (and will be propagated upwards) even though the proxy object that is already there is actually fine.
> Therefore I would propose the following change:
> Index: src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java
> ===================================================================
> --- src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java	(revision 1068918)
> +++ src/main/java/org/apache/aries/jndi/ObjectFactoryHelper.java	(working copy)
> @@ -115,6 +115,7 @@
>  
>                      try {
>                          result = factory.getObjectInstance(obj, name, nameCtx, environment);
> +                    } catch (NamingException e) {
>                      } finally {
>                          callerContext.ungetService(ref);
>                      }
> The empty catch block is needed because obviously some ObjectFactories throw a NamingException instead of returning null in some circumstances.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira