[Rabbit-dev] ad blocking

Luis Soltero lsoltero at globalmarinenet.com
Mon Dec 27 22:41:12 CET 2010


Hi Robo,

I think I have discovered the problem. The problem is that the Mysql connector does not support many of the methods you
have listed in the db resource sections. For example, if i define setUser then I get an exception in the error logs
stating that mysql... has no method setUser. The same is true for setServerName, setDatabaseName, setPassword,
setDataSource, url, etc..

So i have now created the following entries in rabbit.conf and now getting a new error. Here is the new config.

[data_sources]
resources=user_database,host_blocker

[Filters]
accessfilters=rabbit.filter.AccessFilter
httpinfilters=rabbit.filter.HttpBaseFilter,rabbit.filter.ProxyAuth,rabbit.filter.DontFilterFilter,rabbit.filter.BlockFilter,rabbit.filter.RevalidateFilter.SQLBlockFilter

[rabbit.filter.SQLBlockFilter]
resource=jdbc/host_blocker
url=jdbc:mysql://localhost:3306/xauth
select=select 1 from banedhosts where hostname=?
user=xauth
password=xxxxx

[rabbit.filter.ProxyAuth]
one_ip_only=false
cachetime=5
allow_without_auth=(^http://(www.)?globalmarinenet.com/|^http://webmail([0-9])?.gmn-usa.com)
authenticator=sql
userfile=conf/allowed
url=jdbc:mysql://localhost:3306/xauth
resource=jdbc/user_database
user=xauth
password=xxxxxx
select=select password from rabbit where username=?

[user_database]
bind_name=java:comp/env/jdbc/user_database
class=com.mysql.jdbc.Driver

[host_blocker]
bind_name=java:comp/env/jdbc/user_database
class=com.mysql.jdbc.Driver

And here is the new error
Exception in thread "main" java.lang.ClassCastException: com.mysql.jdbc.Driver cannot be cast to javax.sql.DataSource
    at rabbit.filter.DataSourceHelper.<init>(DataSourceHelper.java:37)
    at rabbit.filter.authenticate.SQLAuthenticator.<init>(SQLAuthenticator.java:40)
    at rabbit.filter.ProxyAuth.setup(ProxyAuth.java:127)
    at rabbit.proxy.HttpHeaderFilterer.loadHttpFilters(HttpHeaderFilterer.java:119)
    at rabbit.proxy.HttpHeaderFilterer.<init>(HttpHeaderFilterer.java:25)
    at rabbit.proxy.HttpProxy.loadClasses(HttpProxy.java:479)
    at rabbit.proxy.HttpProxy.setConfig(HttpProxy.java:394)
    at rabbit.proxy.HttpProxy.setConfig(HttpProxy.java:145)
    at rabbit.proxy.ProxyStarter.startProxy(ProxyStarter.java:69)
    at rabbit.proxy.ProxyStarter.start(ProxyStarter.java:63)
    at rabbit.proxy.ProxyStarter.main(ProxyStarter.java:18)

and

Dec 27, 2010 3:46:18 PM rabbit.proxy.ProxyLogger setup
INFO: Log level set to: INFO
Dec 27, 2010 3:46:18 PM rabbit.proxy.ResourceLoader setupResource
WARNING: Failed to setup resource: host_blocker
javax.naming.NameAlreadyBoundException: Use rebind to override
    at rabbit.jndi.HierContext.bind(HierContext.java:138)
    at rabbit.jndi.HierContext.bind(HierContext.java:153)
    at rabbit.jndi.HierContext.bind(HierContext.java:153)
    at rabbit.jndi.HierContext.bind(HierContext.java:153)
    at rabbit.jndi.HierContext.bind(HierContext.java:123)
    at javax.naming.InitialContext.bind(InitialContext.java:400)
    at rabbit.proxy.ResourceLoader.setupResource(ResourceLoader.java:58)
    at rabbit.proxy.HttpProxy.setupResources(HttpProxy.java:273)
    at rabbit.proxy.HttpProxy.setConfig(HttpProxy.java:391)
    at rabbit.proxy.HttpProxy.setConfig(HttpProxy.java:145)
    at rabbit.proxy.ProxyStarter.startProxy(ProxyStarter.java:69)
    at rabbit.proxy.ProxyStarter.start(ProxyStarter.java:63)
    at rabbit.proxy.ProxyStarter.main(ProxyStarter.java:18)
Dec 27, 2010 3:46:18 PM rabbit.cache.NCache readCacheIndex
WARNING: Couldnt read /var/rabbit/rcache-dev/rabbit4/cache.index, This is bad( but not serius).
Treating as empty.
java.io.FileNotFoundException: /var/rabbit/rcache-dev/rabbit4/cache.index (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at java.io.FileInputStream.<init>(FileInputStream.java:66)
    at rabbit.cache.NCache.readCacheIndex(NCache.java:518)
    at rabbit.cache.NCache.setCacheDir(NCache.java:147)
    at rabbit.cache.NCache.setup(NCache.java:672)
    at rabbit.cache.NCache.<init>(NCache.java:83)
    at rabbit.proxy.HttpProxy.setupCache(HttpProxy.java:286)
    at rabbit.proxy.HttpProxy.setConfig(HttpProxy.java:392)
    at rabbit.proxy.HttpProxy.setConfig(HttpProxy.java:145)
    at rabbit.proxy.ProxyStarter.startProxy(ProxyStarter.java:69)
    at rabbit.proxy.ProxyStarter.start(ProxyStarter.java:63)
    at rabbit.proxy.ProxyStarter.main(ProxyStarter.java:18)


Let me know what I am missing. I really want to get this working!

I look forward to your response.

--luis

On 12/27/10 2:29 PM, Robert Olofsson wrote:
> On Mon, 27 Dec 2010 02:56:01 -0500
> Luis Soltero <lsoltero at globalmarinenet.com> wrote:
>
>> mysql> select 1 from banedhosts where hostname='www.winaproduct.com';
> Ok. 
>
>> when i try to start rabbit I get the following error...
>> Exception in thread "main" java.lang.RuntimeException: javax.naming.NotContextException: java:comp does not name a
>> context, bindings: {} 
>> ...
>> Obviously there is some issue connecting to the database. Here are my settings from rabbit.conf
>> [data_sources]
>> resources=user_database,host_blocker
>>
>> [rabbit.filter.SQLBlockFilter]
>> resource=host_blocker
> This is the first error, the resource should be:
> jdbc/host_blocker
>
>> user=xauth
>> password=xxxxx
>> select=select 1 from banedhosts where hostname=?
>>
>> [rabbit.filter.ProxyAuth]
>> cachetime=5
>> allow_without_auth=(^http://(www.)?globalmarinenet.com/|^http://webmail([0-9])?.gmn-usa.com)
>> authenticator=sql
>> userfile=conf/allowed
>> resource=user_database
> Same error here, try 
> resource=jdbc/user_database
>
>> [user_database]
>> class=com.mysql.jdbc.Driver
>> url=jdbc:mysql://localhost:3306/xauth
>> setUser=xauth
>> setPassword=xxxxxxx
> You do need to set the bind_name here:
> bind_name=java:comp/env/jdbc/user_database
>
> And if you set the user and password here you should not need
> to set them in the SQLBlockFilter.
>
>> [host_blocker]
>> class=com.mysql.jdbc.Driver
>> url=jdbc:mysql://localhost:3306/xauth
>> setUser=xauth
>> setPassword=xxxxx
> Same problem here, you do need to specify the bind_name
>
>> I have tried many different iterations of the above but always get the same error.  I have tried using bind_name in
>> several permutations but still get the java:comp does not name a context binding error.
> Odd, that should be the problem.
>
>> I am sure I am making a simple mistake... Any pointers are greatly appreciated. I look forward to hearing back from you.
> Well, now I know that the documentation needs some more explanations, thank you :-)
>
> Good luck.
> /robo
>


-- 


Luis Soltero, Ph.D., MCS
Director of Software Development, CTO
Global Marine Networks, LLC
StarPilot, LLC
Tel: 865-379-8723
Fax: 865-681-5017
E-Mail: lsoltero at globalmarinenet.net
Web: http://www.globalmarinenet.net
Web: http://www.starpilotllc.com





More information about the Rabbit-dev mailing list