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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Hirotsugu A. (Guest)
on 2008-11-15 03:15
(Received via mailing list)
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
Charles Oliver N. (Guest)
on 2008-11-16 07:02
(Received via mailing list)
Hirotsugu A. wrote:
> 5. 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
Hirotsugu A. (Guest)
on 2008-11-16 15:11
(Received via mailing list)
On Nov 15, 2008, at 11:02 PM, Charles Oliver N. wrote:

>> 4. 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
Charles Oliver N. (Guest)
on 2008-11-17 00:03
(Received via mailing list)
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
Matt B. (Guest)
on 2008-11-17 15:32
(Received via mailing list)
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:
> 5. 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
Charles Oliver N. (Guest)
on 2008-11-17 16:26
(Received via mailing list)
Sounds like a good topic for a wiki page or faq :)

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
Hirotsugu A. (Guest)
on 2008-11-20 02:35
(Received via mailing list)
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
This topic is locked and can not be replied to.