Return-Path: X-Original-To: apmail-aries-dev-archive@www.apache.org Delivered-To: apmail-aries-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 201A57FF7 for ; Tue, 26 Jul 2011 17:39:33 +0000 (UTC) Received: (qmail 23471 invoked by uid 500); 26 Jul 2011 17:39:32 -0000 Delivered-To: apmail-aries-dev-archive@aries.apache.org Received: (qmail 23380 invoked by uid 500); 26 Jul 2011 17:39:32 -0000 Mailing-List: contact dev-help@aries.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aries.apache.org Delivered-To: mailing list dev@aries.apache.org Received: (qmail 23372 invoked by uid 99); 26 Jul 2011 17:39:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Jul 2011 17:39:31 +0000 X-ASF-Spam-Status: No, hits=-2001.2 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Jul 2011 17:39:30 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 3C91C88374 for ; Tue, 26 Jul 2011 17:39:10 +0000 (UTC) Date: Tue, 26 Jul 2011 17:39:10 +0000 (UTC) From: "Alasdair Nottingham (JIRA)" To: dev@aries.apache.org Message-ID: <80246927.8512.1311701950244.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <932131177.7595.1297333317552.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Resolved] (ARIES-572) NamingException in JMXConnectionFactory.connect() calls with JMX over RMI calls MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ 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 env = new HashMap(); > 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