Java Code Examples for javax.naming.NamingException#initCause()
The following examples show how to use
javax.naming.NamingException#initCause() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TomcatContext.java From mdw with Apache License 2.0 | 6 votes |
public Object lookup(String hostPort, String name, Class<?> cls) throws NamingException { if (cls.getName().equals("javax.transaction.TransactionManager") && useMdwTransactionManager) { return MdwTransactionManager.getInstance(); } else if (cls.getName().equals("javax.jms.Topic")) { JmsProvider jmsProvider = ApplicationContext.getJmsProvider(); if (!(jmsProvider instanceof ActiveMqJms)) throw new NamingException("Unsupported JMS Provider: " + jmsProvider); ActiveMqJms activeMqJms = (ActiveMqJms) jmsProvider; return activeMqJms.getTopic(name); } try { Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); return envCtx.lookup(name); } catch (Exception e) { NamingException ne = new NamingException("Failed to look up " + name); ne.initCause(e); throw ne; } }
Example 2
Source File: JmsInitialContextFactory.java From qpid-jms with Apache License 2.0 | 6 votes |
private void createConnectionFactories(Hashtable<Object, Object> environment, Map<String, Object> bindings) throws NamingException { Map<String, String> factories = getConnectionFactoryNamesAndURIs(environment); Map<String, String> defaults = getConnectionFactoryDefaults(environment); for (Entry<String, String> entry : factories.entrySet()) { String name = entry.getKey(); String uri = entry.getValue(); JmsConnectionFactory factory = null; try { factory = createConnectionFactory(name, uri, defaults, environment); } catch (Exception e) { NamingException ne = new NamingException("Exception while creating ConnectionFactory '" + name + "'."); ne.initCause(e); throw ne; } bindings.put(name, factory); } }
Example 3
Source File: JndiContext.java From seed with Mozilla Public License 2.0 | 6 votes |
@Override public Object lookup(String name) throws NamingException { if (injector == null) { throw new IllegalStateException("Missing SeedStack injector, cannot lookup for " + name); } try { int separatorIdx = name.indexOf('/'); if (separatorIdx != -1) { String className = name.substring(0, separatorIdx); String qualifier = name.substring(separatorIdx + 1); return injector.getInstance(Key.get(Class.forName(className), Names.named(qualifier))); } else { return injector.getInstance(Class.forName(name)); } } catch (ClassNotFoundException e) { NamingException exception = new NamingException("Unable to find " + name + " in SeedStack JNDI context"); exception.initCause(e); throw exception; } }
Example 4
Source File: DataSourceLinkFactory.java From Tomcat8-Source-Read with MIT License | 5 votes |
protected Object wrapDataSource(Object datasource, String username, String password) throws NamingException { try { DataSourceHandler handler = new DataSourceHandler((DataSource)datasource, username, password); return Proxy.newProxyInstance(datasource.getClass().getClassLoader(), datasource.getClass().getInterfaces(), handler); }catch (Exception x) { if (x instanceof InvocationTargetException) { Throwable cause = x.getCause(); if (cause instanceof ThreadDeath) { throw (ThreadDeath) cause; } if (cause instanceof VirtualMachineError) { throw (VirtualMachineError) cause; } if (cause instanceof Exception) { x = (Exception) cause; } } if (x instanceof NamingException) throw (NamingException)x; else { NamingException nx = new NamingException(x.getMessage()); nx.initCause(x); throw nx; } } }
Example 5
Source File: DataSourceLinkFactory.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
protected Object wrapDataSource(Object datasource, String username, String password) throws NamingException { try { Class<?> proxyClass = Proxy.getProxyClass(datasource.getClass().getClassLoader(), datasource.getClass().getInterfaces()); Constructor<?> proxyConstructor = proxyClass.getConstructor(new Class[] { InvocationHandler.class }); DataSourceHandler handler = new DataSourceHandler((DataSource)datasource, username, password); return proxyConstructor.newInstance(handler); }catch (Exception x) { if (x instanceof InvocationTargetException) { Throwable cause = x.getCause(); if (cause instanceof ThreadDeath) { throw (ThreadDeath) cause; } if (cause instanceof VirtualMachineError) { throw (VirtualMachineError) cause; } if (cause instanceof Exception) { x = (Exception) cause; } } if (x instanceof NamingException) throw (NamingException)x; else { NamingException nx = new NamingException(x.getMessage()); nx.initCause(x); throw nx; } } }
Example 6
Source File: DataSourceLinkFactory.java From tomcatsrc with Apache License 2.0 | 5 votes |
protected Object wrapDataSource(Object datasource, String username, String password) throws NamingException { try { Class<?> proxyClass = Proxy.getProxyClass(datasource.getClass().getClassLoader(), datasource.getClass().getInterfaces()); Constructor<?> proxyConstructor = proxyClass.getConstructor(new Class[] { InvocationHandler.class }); DataSourceHandler handler = new DataSourceHandler((DataSource)datasource, username, password); return proxyConstructor.newInstance(handler); }catch (Exception x) { if (x instanceof InvocationTargetException) { Throwable cause = x.getCause(); if (cause instanceof ThreadDeath) { throw (ThreadDeath) cause; } if (cause instanceof VirtualMachineError) { throw (VirtualMachineError) cause; } if (cause instanceof Exception) { x = (Exception) cause; } } if (x instanceof NamingException) throw (NamingException)x; else { NamingException nx = new NamingException(x.getMessage()); nx.initCause(x); throw nx; } } }