Forum: JRuby Strange problem with waffle-jna

Posted by Lundberg, Per (Guest)
on 2012-11-07 23:17
(Received via mailing list)
Hi!



I am trying to use the Waffle Java library
(https://github.com/dblock/waffle) with JRuby, but with very little
success.



The strange thing is this: I am trying to import a Java type from the
waffle-jna.jar file. The 'require' lines all work, but when it get to 
the
java_import line, I get an error like this:



NameError: undefined local variable or method `waffle' for main:Object



This indicates to the me that the types in the JAR file have not been
loaded correctly. Which is strange. When I make a simple "hello world" 
Java
class, things work like they should which indicate to me that the jar 
file
is OK. But I've spent hours now trying to get this simple thing working
with JRuby. What am I doing wrong? I tried enabling
jruby.debug.loadService=true but it didn't give me any help...



Is there any way to see what types JRuby has found in a given jar file, 
to
be able to better debug scenarios like this?



Thanks in advance for any suggestions. Below is my sample code. If you 
want
to try it, you can run it with the waffle 1.5 release from the link 
above.
I have tested with both JRuby 1.6.8 and 1.7.0 with similar results.



Best regards,

Per





require 'java'

require 'guava-13.0.1.jar'

require 'jna-3.5.0.jar'

require 'platform-3.5.0.jar'

require 'slf4j-api-1.7.2.jar'

require 'waffle-jna.jar'



java_import waffle.windows.auth.impl.WindowsAuthProviderImpl
Posted by Thomas E Enebo (Guest)
on 2012-11-08 00:10
(Received via mailing list)
Two ways to fix this:

1. java_import 'waffle.windows.auth.impl.WindowsAuthProviderImpl'
2. java_import Java.waffle.windows.auth.impl.WindowsAuthProviderImpl

-Tom

On Wed, Nov 7, 2012 at 4:15 PM, Lundberg, Per <Per.Lundberg@ecraft.com> 
wrote:
> waffle-jna.jar file. The require lines all work, but when it get to the
> things work like they should which indicate to me that the jar file is OK.
>
>
>
> require 'slf4j-api-1.7.2.jar'
>
> require 'waffle-jna.jar'
>
>
>
> java_import waffle.windows.auth.impl.WindowsAuthProviderImpl



--
blog: http://blog.enebo.com       twitter: tom_enebo
mail: tom.enebo@gmail.com
Posted by Thomas E Enebo (Guest)
on 2012-11-08 00:13
(Received via mailing list)
whoops.  I should probably say what was wrong too :)

We make a bunch of magic methods com,org,java,javax which get defined
on Kernel for those very common package roots.  This is why those
appear to just work.  Since waffle is not defined you get a NameError.

-Tom

On Wed, Nov 7, 2012 at 5:09 PM, Thomas E Enebo <tom.enebo@gmail.com> 
wrote:
>>
>>
>> didnt give me any help
>> have tested with both JRuby 1.6.8 and 1.7.0 with similar results.
>>
>> require 'waffle-jna.jar'
>>
>>
>>
>> java_import waffle.windows.auth.impl.WindowsAuthProviderImpl
>
>
>
> --
> blog: http://blog.enebo.com       twitter: tom_enebo
> mail: tom.enebo@gmail.com



--
blog: http://blog.enebo.com       twitter: tom_enebo
mail: tom.enebo@gmail.com
Posted by kristian (Guest)
on 2012-11-08 06:32
(Received via mailing list)
nice to know - I always wondered why sometime my imports worked and
sometimes not :)

- Kristian
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.