use of javax.naming.InitialContext in project aries by apache.
the class InitialContextTest method testURLContextErrorPropagation.
@Test
public void testURLContextErrorPropagation() throws Exception {
ObjectFactory of = new ObjectFactory() {
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
throw new Exception("doh");
}
};
registerURLObjectFactory(of, "test");
ic = initialContext();
try {
ic.lookup("test:something");
Assert.fail("Expected NamingException");
} catch (NamingException ne) {
assertNotNull(ne.getCause());
assertEquals("doh", ne.getCause().getMessage());
}
}
use of javax.naming.InitialContext in project aries by apache.
the class JndiExtensionTests method testGetBeanManagerThroughJNDI.
public void testGetBeanManagerThroughJNDI() throws Exception {
Hashtable<String, Object> env = new Hashtable<>();
env.put(JNDIConstants.BUNDLE_CONTEXT, cdiBundle.getBundleContext());
InitialContext context = new InitialContext(env);
BeanManager beanManager = (BeanManager) context.lookup("java:comp/BeanManager");
assertNotNull(beanManager);
assertPojoExists(beanManager);
}
use of javax.naming.InitialContext in project geode by apache.
the class GemfireSessionManager method registerMBean.
/**
* Register a bean for statistic gathering purposes
*/
private void registerMBean() {
mbean = new SessionStatistics();
try {
InitialContext ctx = new InitialContext();
MBeanServer mbs = MBeanServer.class.cast(ctx.lookup("java:comp/env/jmx/runtime"));
ObjectName oname = new ObjectName(Constants.SESSION_STATISTICS_MBEAN_NAME);
mbs.registerMBean(mbean, oname);
} catch (Exception ex) {
LOG.warn("Unable to register statistics MBean. Error: {}", ex.getMessage());
}
}
use of javax.naming.InitialContext in project deltaspike by apache.
the class OpenEjbContainerControl method boot.
@Override
public synchronized void boot(Map<?, ?> properties) {
if (context == null) {
// this immediately boots the container
final Properties p = new Properties();
p.putAll(PROPERTIES);
if (// override with user config
properties != null) {
p.putAll(properties);
}
try {
context = new InitialContext(p);
} catch (final NamingException e) {
throw new RuntimeException(e);
}
beanManager = WebBeansContext.currentInstance().getBeanManagerImpl();
}
}
use of javax.naming.InitialContext in project geode by apache.
the class ContextJUnitTest method setUp.
@Before
public void setUp() throws Exception {
Hashtable table = new Hashtable();
table.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.geode.internal.jndi.InitialContextFactoryImpl");
initialContext = new InitialContext(table);
initialContext.bind("java:gf/env/datasource/oracle", "a");
gemfireContext = (Context) initialContext.lookup("java:gf");
envContext = (Context) gemfireContext.lookup("env");
dataSourceContext = (Context) envContext.lookup("datasource");
}
Aggregations