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/10 11:21:57 UTC

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

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


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

        

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

Posted by "Stephan Siano (JIRA)" <ji...@apache.org>.
     [ 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

        

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

Posted by "Alasdair Nottingham (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ARIES-572?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alasdair Nottingham reassigned ARIES-572:
-----------------------------------------

    Assignee: Alasdair Nottingham

> 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
>            Assignee: Alasdair Nottingham
>         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

        

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

Posted by "Alasdair Nottingham (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ARIES-572?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alasdair Nottingham resolved ARIES-572.
---------------------------------------

    Resolution: Fixed

> 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
>            Assignee: Alasdair Nottingham
>         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

        

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

Posted by "Jeremy Hughes (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ARIES-572?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeremy Hughes updated ARIES-572:
--------------------------------

    Fix Version/s: jndi uber bundle 0.3.1
                   jndi.core-0.3.1
    
> 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
>            Assignee: Alasdair Nottingham
>             Fix For: jndi.core-0.3.1, jndi uber bundle 0.3.1
>
>         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.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

Posted by "Stephan Siano (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ARIES-572?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12993485#comment-12993485 ] 

Stephan Siano commented on ARIES-572:
-------------------------------------

After giving the issue another thought and consulting the javax.spi.naming.ObjectFactory javadoc I guess that the code should not only catch NamingException but all Exceptions and do a break as the exception handler, because the javadoc says:
"Throws: Exception - if this object factory encountered an exception while attempting to create an object, and no other object factories are to be tried.". At least the code cannot rely on the implementation just returning null because "If obj is of any other type [than null, an URL or an array of URL objects], the behavior of getObjectInstance() is determined by the context factory implementation. ", so it is probably legal to throw an exception here as the com.sun.jndi.url.rmi.rmiURLContextFactory does.

I still don't understand why the ObjectFactoryHelper.getObjectInstance() gets called at all with a valid RMI proxy instance as the first parameter, but if the Exception is caught the code will proceed with the instance it already has, which works fine.


> 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
>
> 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