commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fumo, Vince" <Vince.F...@acs-inc.com>
Subject DBCP Registering a PoolingDataSource in JNDI
Date Fri, 30 Jan 2004 18:24:31 GMT
I'm trying to register a valid PoolingDataSource in JNDI using the following
method and code:

	private final static String INITIAL_CONTEXT_FACTORY =
"com.sun.jndi.fscontext.RefFSContextFactory";
	private final static String FACTORY_URL = "file:/D:/jndi";

	public static void register(PoolingDataSource datasource, String
bindName) throws Exception {
		Hashtable env = new Hashtable();
		env.put(Context.INITIAL_CONTEXT_FACTORY,
INITIAL_CONTEXT_FACTORY);
		env.put(Context.PROVIDER_URL, FACTORY_URL);
		
		Context context = null;
		try {
			context = new InitialContext(env);
		}
		catch (NamingException e) {
			String msg = "Could not initialize the context : " +
e.getMessage();;
			_log.error(msg);
			e.printStackTrace();
			throw new Exception(msg);
		}
		
		try {
			context.rebind(bindName, datasource);
		}
		catch (NamingException e) {
			String msg = "Could not bind the datasource : " +
e.getMessage();
			_log.error(msg);
			e.printStackTrace();
			throw new Exception(msg);
		}	
	}	

The problem happens with the call to context.rebind. Apparantly JNDI is
complaining as follows:

javax.naming.OperationNotSupportedException: Can only bind References or
Referenceable objects
	at
com.sun.jndi.fscontext.RefFSContext.addObjectToBindings(RefFSContext.java:47
9)
	at
com.sun.jndi.fscontext.RefFSContext.bindObject(RefFSContext.java:337)
	at com.sun.jndi.fscontext.RefFSContext.rebind(RefFSContext.java:189)
	at com.sun.jndi.fscontext.FSContext.rebind(FSContext.java:194)
	at javax.naming.InitialContext.rebind(Unknown Source)

Any ideas on what's wrong?	

Vincent Fumo
Software Engineer
ACS State and Local Solutions
Government Systems



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message