NativeException when connecting to LDAP/Active Directory server, only in WAR

I’m trying to track down this NativeException when a Rails app tries
to connect to an LDAP server (it’s an Active Directory server,
actually, if that makes any difference) and search from a WAR.

Here’s a way to reproduce this problem minimally:

  1. jruby rails ldaptest
  2. cd ldaptest
  3. Remove ActiveRecord from environment.rb (since we don’t need to
    connect to a database).
  4. warble config
  5. config.gems << “jruby-ldap” in warble.rb
  6. jruby script/generate controller home index
  7. Edit app/controllers/home_controller.rb to define a simple
    connection, like so: http://pastie.org/315012

Starting the server with ‘script/server’, going to ‘/home/index’ will
render the familiar “Find me in …” template. This is fine in either
development or production environment.

However, if you create WAR with ‘warble’ and deploy it, same action
triggers this error: http://pastie.org/315013

I’d appreciate any insight.

Hiro


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hirotsugu A. wrote:

  1. config.gems << “jruby-ldap” in warble.rb

I’d appreciate any insight.

It looks like an LDAP error saying the context is not a DirContext. Does
the jruby-ldap library try to hook up to a specific context right away?
Looks like you’re deploying to GlassFish, yes?

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Nov 15, 2008, at 11:02 PM, Charles Oliver N. wrote:

  1. warble config

It looks like an LDAP error saying the context is not a DirContext.
Does the jruby-ldap library try to hook up to a specific context
right away? Looks like you’re deploying to GlassFish, yes?

  • Charlie

Yes, I’m deploying to GlassFish. I haven’t tried other deployment
methods, because I’m not very familiar with them.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

We had a problem similar to this. From what I remember, it had to do
with the way that jruby-ldap picked a context factory. When we deployed
to WebSphere, the default factory that jruby-ldap pulled out of
WebSphere caused exceptions similar to yours. I had figured it was just
because of WebSphere, but evidently it’s more common.

Here’s the code that I wrote to fix it. http://pastie.org/316793 That
includes the fix (changing the context factory) and some code that dumps
more details about LDAP problems, which was helpful when trying to
figure out why our binds were failing.

Hope that helps,
Matt

Hirotsugu A. wrote:

  1. config.gems << “jruby-ldap” in warble.rb

I’d appreciate any insight.

Hiro


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hirotsugu A. wrote:

Yes, I’m deploying to GlassFish. I haven’t tried other deployment
methods, because I’m not very familiar with them.

Can you boil it down to a simple app and file a JRuby bug? Ideally throw
required gems into vendor and toss it our way.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

It took me a couple of days, but I did get around to this fix. And a
fix it was!

Thank you, Matt.


Hirotsugu A.

On Nov 17, 2008, at 7:31 AM, Matt B. wrote:

  1. jruby rails ldaptest
    in either development or production environment.
    To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Sounds like a good topic for a wiki page or faq :slight_smile:

Matt B. wrote:

  1. jruby rails ldaptest
    render the familiar “Find me in …” template. This is fine in either
    To unsubscribe from this list, please visit:

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email