Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
0.3, 0.4
-
None
Description
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
@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
The empty catch block is needed because obviously some ObjectFactories throw a NamingException instead of returning null in some circumstances.