commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dongsheng Song <dongsheng.s...@gmail.com>
Subject [patch] DBCP JNDI PATCH
Date Fri, 03 Dec 2004 02:43:04 GMT
This resolve  InstanceKeyDataSource.getReference return a result that
reference abstract class InstanceKeyObjectFactory, and 
javax.naming.spi.NamingManager.getObjectFactoryFromReference try to
create an instance of class InstanceKeyObjectFactory bug.

The following patch remove getReference from InstanceKeyDataSource, 
implement getReference  within class SharedPoolDataSource and
PerUserPoolDataSource.


diff -r dbcp.old/datasources/InstanceKeyDataSource.java
dbcp/datasources/InstanceKeyDataSource.java
740,753d739
< 
<     // ----------------------------------------------------------------------
<     // Referenceable implementation 
< 
<     /**
<      * <CODE>Referenceable</CODE> implementation prepares object for
<      * binding in jndi.
<      */
<     public Reference getReference() throws NamingException {
<         Reference ref = new Reference(getClass().getName(), 
<             InstanceKeyObjectFactory.class.getName(), null);
<         ref.add(new StringRefAddr("instanceKey", instanceKey));
<         return ref;
<     }
diff -r dbcp.old/datasources/PerUserPoolDataSource.java
dbcp/datasources/PerUserPoolDataSource.java
27a28,29
> import javax.naming.Reference;
> import javax.naming.StringRefAddr;
501a504,513
>     
>     // ----------------------------------------------------------------------
>     // Referenceable implementation 
> 
>     public Reference getReference() throws NamingException {
>         Reference ref = new Reference(getClass().getName(), 
>                 PerUserPoolDataSourceFactory.class.getName(), null);
>         ref.add(new StringRefAddr("instanceKey", instanceKey));
>         return ref;
>     }
diff -r dbcp.old/datasources/SharedPoolDataSource.java
dbcp/datasources/SharedPoolDataSource.java
25a26,27
> import javax.naming.Reference;
> import javax.naming.StringRefAddr;
241a244,253
>     
>     // ----------------------------------------------------------------------
>     // Referenceable implementation 
> 
>     public Reference getReference() throws NamingException {
>         Reference ref = new Reference(getClass().getName(), 
>                 SharedPoolDataSourceFactory.class.getName(), null);
>         ref.add(new StringRefAddr("instanceKey", instanceKey));
>         return ref;
>     }



On Thu, 2 Dec 2004 19:35:09 +0800, Dongsheng Song
<dongsheng.song@gmail.com> wrote:
> I use jnpserver pulish SharedPoolDataSource from jndi,
> 
> ctx.rebind("/falcon",  SharedPoolDataSource);
> 
> but
> 
> DataSource ds = (DataSource) ctx.lookup("falcon");
> 
> throws exception:
> 
> javax.naming.NamingException: Could not dereference object [Root
> exception is java.lang.IllegalAccessException: Class
> javax.naming.spi.NamingManager can not access a member of class
> org.apache.commons.dbcp.datasources.InstanceKeyObjectFactory with
> modifiers ""]
>         at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:633)
>         at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:509)
>         at javax.naming.InitialContext.lookup(InitialContext.java:347)
>         at org.matrix.ds.RemoteDataSource.main(RemoteDataSource.java:80)
> Caused by: java.lang.IllegalAccessException: Class
> javax.naming.spi.NamingManager can not access a member of class
> org.apache.commons.dbcp.datasources.InstanceKeyObjectFactory with
> modifiers ""
>         at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)
>         at java.lang.Class.newInstance0(Class.java:302)
>         at java.lang.Class.newInstance(Class.java:261)
>         at javax.naming.spi.NamingManager.getObjectFactoryFromReference(NamingManager.java:146)
>         at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:299)
>         at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:622)
>         ... 3 more
> Exception in thread "main"
> 
> Thanks fro some help
> 
> Dongsheng Song
>

Mime
View raw message