Forum: Ruby Getting YAJB to work at all

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.
828f1d90727a1f3972e0fe55a66be56f?d=identicon&s=25 Tom Harris (tharrisx)
on 2006-01-13 10:19
I have been trying to get YAJB to work on my system for the last three
days, without success. The platform I'm running on is Windows 2003
Server, with Ruby 1.8.3 and YAJB 0.8.1.

I have ruby installed in the default location on Windows, which is
c:\ruby

I have my JAVA_HOME set to the root of my Java folder: D:\jdk1.5.0_06

When I run "ruby setup.rb", everything seems fine.

I then go into the sample folder and run "ruby gui_simple.rb", and
nothing happens. It just sits there.

I then modified gui_simple.rb to include the following after the include
statement, so I could see what was going wrong:

JBRIDGE_OPTIONS = {
  :jvm_stdout => :t,
  :jvm_log_level => "debug",
  :bridge_log => true
}

The output follows:

JavaBridge: Startup communication bridge...
CLASSPATH: "$CLASSPATH";c:/ruby/lib/ruby/site_ruby/1.8/yajb/yajb.jar
java  -classpath
""$CLASSPATH";c:/ruby/lib/ruby/site_ruby/1.8/yajb/yajb.jar"
jbridge.BridgeBuilder jbridge.comm.
binstream.BStream_JBServer -remoteport:2390 -logLevel:debug
JVM: Start main routine.
JVM: CodeGen: ImplFlagField
JVM: CodeGen: SuperClassField
JVM: CodeGen: MethodFinderField
JVM: CodeGen: SessionManagerField
JVM: CodeGen: IdField
JVM: CodeGen: InjectMethod
JVM: CodeGen: SendMessage
JVM: CodeGen: OverrideMethod_check
JVM: CodeGen: OverrideMethod_return
JVM: CodeGen: SuperCaller
JVM: CodeGen: SuperConstructor
JVM: CG: OriginalMethod
JVM: OK.
JVM: Initialized.
start up BinStream connection on 2390
BinServer: waiting for client's connection...

It just sits there forever. No gui, nothing.

Finally, I hit CTRL-C, and get the following:

  EXIT JavaBridge...
      ----GC: begin cancelling finalizer: 0
nil
c:/ruby/lib/ruby/site_ruby/1.8/yajb/jbridge.rb:451:in `__startup_JVM':
undefined method `message' for nil:NilCla
ss (NoMethodError)
        from c:/ruby/lib/ruby/site_ruby/1.8/yajb/jbridge.rb:440
c:/ruby/lib/ruby/site_ruby/1.8/yajb/jbridge.rb:451:in `__startup_JVM':
undefined method `message' for nil:NilCla
ss (NoMethodError)
        from c:/ruby/lib/ruby/site_ruby/1.8/yajb/jbridge.rb:440

Originally, I had been thinking my application was wrong somehow, as I
had barrelled ahead without trying the samples. But, after trying to
figure this out, I finally decided to see if the samples worked, which
as you can above, did not. So, what is going wrong here? This being the
only usable Java bridge that needs no special compilation for the
platform, I thought this would also be the only one I could use on
Windows being within Cygwin. I really need to avoid that.

My main application is Java based, but after playing with Rails I
decided that the configuration GUI had to be in Ruby. So, YAJB will be
used just to notify the main application that configuration changes have
occurred. Tha java class is very simple, and if I could just get YAJB
working, I'd be done.

Can someone please tell me what might be wrong and what I can do to fix
it?

Tom Harris
Cisco Systems, Inc.
2df1fbb4f443f3eab13d13922e542491?d=identicon&s=25 SAKURAI Masashi (Guest)
on 2006-01-13 11:39
(Received via mailing list)
Hi,

> start up BinStream connection on 2390
> BinServer: waiting for client's connection...
>
> It just sits there forever. No gui, nothing.

The situation is that the ruby side of the yajb is waiting for the
connection from the java side.

The windows firewall may block the connection. Will you check the
event-viewer and firewall setting?
2df1fbb4f443f3eab13d13922e542491?d=identicon&s=25 SAKURAI Masashi (Guest)
on 2006-01-13 11:39
(Received via mailing list)
Hi,

> start up BinStream connection on 2390
> BinServer: waiting for client's connection...
>
> It just sits there forever. No gui, nothing.

The situation is that the ruby side of the yajb is waiting for the
connection from the java side.

The windows firewall may block the connection. Will you check the
event-viewer and firewall setting?
828f1d90727a1f3972e0fe55a66be56f?d=identicon&s=25 Tom Harris (tharrisx)
on 2006-01-13 12:10
SAKURAI Masashi wrote:
> Hi,
>
>> start up BinStream connection on 2390
>> BinServer: waiting for client's connection...
>>
>> It just sits there forever. No gui, nothing.
>
> The situation is that the ruby side of the yajb is waiting for the
> connection from the java side.
>
> The windows firewall may block the connection. Will you check the
> event-viewer and firewall setting?

I do not use windows firewall, and the Windows event viewer shows
nothing of consequence. Any other ideas?

Tom
828f1d90727a1f3972e0fe55a66be56f?d=identicon&s=25 Tom Harris (tharrisx)
on 2006-01-13 13:17
Tom Harris wrote:
> SAKURAI Masashi wrote:
>> Hi,
>>
>>> start up BinStream connection on 2390
>>> BinServer: waiting for client's connection...
>>>
>>> It just sits there forever. No gui, nothing.
>>
>> The situation is that the ruby side of the yajb is waiting for the
>> connection from the java side.
>>
>> The windows firewall may block the connection. Will you check the
>> event-viewer and firewall setting?
>
> I do not use windows firewall, and the Windows event viewer shows
> nothing of consequence. Any other ideas?
>
> Tom

I also just tried to use a completely different JVM, as I thought
perhaps Java 1.5 was causing the problem. I switched my path and my
JAVA_HOME to point to a 1.4.2 version of java, and tried again. Same
result.

I just made a second double-check to see if windows firewall was
running, and the Firewall depends on connection sharing/ICS service,
which is disabled here. I have a hardware firewall between my computers
and my cable modem, to avoid the bulk of evil. I would never run a
firewall on one of my computers.

Any other ideas?

Tom
2df1fbb4f443f3eab13d13922e542491?d=identicon&s=25 SAKURAI Masashi (Guest)
on 2006-01-13 14:24
(Received via mailing list)
Tom Harris wrote:
> >> The situation is that the ruby side of the yajb is waiting for the
> >> connection from the java side.
> >>
> >> The windows firewall may block the connection. Will you check the
> >> event-viewer and firewall setting?
> >
> > I do not use windows firewall, and the Windows event viewer shows
> > nothing of consequence. Any other ideas?

Will you try following options and check the log file output by java,
"jlog.txt".

JBRIDGE_OPTIONS = {
  :jvm_stdout => :t,
  :jvm_log_file => "jlog.txt",
  :jvm_log_level => "debug",
  :bridge_log => true
}

If the log file is too large, please send me the file.
After checking the problem, I will report here.
828f1d90727a1f3972e0fe55a66be56f?d=identicon&s=25 Tom Harris (tharrisx)
on 2006-01-13 20:24
SAKURAI Masashi wrote:
> Tom Harris wrote:
>> >> The situation is that the ruby side of the yajb is waiting for the
>> >> connection from the java side.
>> >>
>> >> The windows firewall may block the connection. Will you check the
>> >> event-viewer and firewall setting?
>> >
>> > I do not use windows firewall, and the Windows event viewer shows
>> > nothing of consequence. Any other ideas?
>
> Will you try following options and check the log file output by java,
> "jlog.txt".
>
> JBRIDGE_OPTIONS = {
>   :jvm_stdout => :t,
>   :jvm_log_file => "jlog.txt",
>   :jvm_log_level => "debug",
>   :bridge_log => true
> }
>
> If the log file is too large, please send me the file.
> After checking the problem, I will report here.

Here is the contents of the jlog.txt file:

Start main routine.
CodeGen: ImplFlagField
CodeGen: SuperClassField
CodeGen: MethodFinderField
CodeGen: SessionManagerField
CodeGen: IdField
CodeGen: InjectMethod
CodeGen: SendMessage
CodeGen: OverrideMethod_check
CodeGen: OverrideMethod_return
CodeGen: SuperCaller
CodeGen: SuperConstructor
CG: OriginalMethod
BinServer: waiting for client's connection...

Process is still hung without any results. The console window shows:

JavaBridge: Startup communication bridge...
CLASSPATH: "$CLASSPATH";c:/ruby/lib/ruby/site_ruby/1.8/yajb/yajb.jar
java  -classpath
""$CLASSPATH";c:/ruby/lib/ruby/site_ruby/1.8/yajb/yajb.jar"
jbridge.BridgeBuilder jbridge.comm.
binstream.BStream_JBServer -remoteport:1105 -logLevel:debug
-logfile:jlog.txt
JVM: OK.
JVM: Initialized.
start up BinStream connection on 1105

Ctrl-C was then pressed.

  EXIT JavaBridge...
      ----GC: begin cancelling finalizer: 0
nil
c:/ruby/lib/ruby/site_ruby/1.8/yajb/jbridge.rb:451:in `__startup_JVM':
undefined method `message' for nil:NilCla
ss (NoMethodError)
        from c:/ruby/lib/ruby/site_ruby/1.8/yajb/jbridge.rb:440
c:/ruby/lib/ruby/site_ruby/1.8/yajb/jbridge.rb:451:in `__startup_JVM':
undefined method `message' for nil:NilCla
ss (NoMethodError)
        from c:/ruby/lib/ruby/site_ruby/1.8/yajb/jbridge.rb:440

Tom
2df1fbb4f443f3eab13d13922e542491?d=identicon&s=25 SAKURAI Masashi (Guest)
on 2006-01-14 23:09
(Received via mailing list)
Tom Harris wrote:
> Process is still hung without any results. The console window shows:
Because the java side didn't throw any exception during stalling, I
think that either java or ruby has a trouble of networking.

Will you try the following tests?

1) Connecting the bridge port of the java side

When the yajb is stalling, please connect to the bridge port and
report the result of telnet and yajb logs.

$ telnet localhost (bridge port number)

The bridge port number is shown in the yajb log. For example, the
number is 1105 in your last report. The port number may be changed
each time you run yajb.

If the connection is established, the java side is not wrong. Then,
try the next test.

2) Ruby network test

Please run the networking test in the "test" directory in the yajb
distribution. Following lines are the result on my computer, Windows
XP Pro SP2.

| $ ruby bstream_cstest.rb
| Loaded suite bstream_cstest
| Started
| . 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 
1...
| Finished in 12.494 seconds.
|
| 4 tests, 1575 assertions, 0 failures, 0 errors

My environmnent information is here.

| $ ruby -v
| ruby 1.8.3 (2005-09-21) [i386-cygwin]
| $ uname -a
| CYGWIN_NT-5.1 x31 1.5.18(0.132/4/2) 2005-07-02 20:30 i686 unknown unknown Cygwin
828f1d90727a1f3972e0fe55a66be56f?d=identicon&s=25 Tom Harris (tharrisx)
on 2006-01-15 01:55
SAKURAI Masashi wrote:
> 1) Connecting the bridge port of the java side

jlog.txt after telnet:

Start main routine.
CodeGen: ImplFlagField
CodeGen: SuperClassField
CodeGen: MethodFinderField
CodeGen: SessionManagerField
CodeGen: IdField
CodeGen: InjectMethod
CodeGen: SendMessage
CodeGen: OverrideMethod_check
CodeGen: OverrideMethod_return
CodeGen: SuperCaller
CodeGen: SuperConstructor
CG: OriginalMethod
BinServer: waiting for client's connection...
MS:ready for I/O stream.
BinServer: connection established.
MS:started working block.
Unrecoverable error occued. [jbridge.comm.binstream.BinStreamException :
Decoder: wrong header:13]
jbridge.comm.binstream.BinStreamException: Decoder: wrong header:13
	at jbridge.comm.binstream.BinDecoder.read(BinDecoder.java:49)
	at jbridge.comm.binstream.BinDecoder.read(BinDecoder.java:14)
	at
jbridge.comm.binstream.MessageServer.receivingLoop(MessageServer.java:343)
	at
jbridge.comm.binstream.MessageServer.access$400(MessageServer.java:25)
	at jbridge.comm.binstream.MessageServer$2.run(MessageServer.java:308)
	at java.lang.Thread.run(Thread.java:595)

jbridge.comm.binstream.BinStreamException: Decoder: wrong header:13
	at jbridge.comm.binstream.BinDecoder.read(BinDecoder.java:49)
	at jbridge.comm.binstream.BinDecoder.read(BinDecoder.java:14)
	at
jbridge.comm.binstream.MessageServer.receivingLoop(MessageServer.java:343)
	at
jbridge.comm.binstream.MessageServer.access$400(MessageServer.java:25)
	at jbridge.comm.binstream.MessageServer$2.run(MessageServer.java:308)
	at java.lang.Thread.run(Thread.java:595)

MS: [rcvloop] try to reset the connection.
MS: Receive-thread finished.
MS: sender-thread terminating...
MS: Sender-thread finished.
MS:closing socket.
MS:finished working block.
BinServer: disconnected.
BinServer: waiting for client's connection...

> 2) Ruby network test

C:\yajb-0.8.1\test>ruby bstream_cstest.rb
Loaded suite bstream_cstest
Started
. 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8 7 6 5 4 3 2 1...
Finished in 6.547 seconds.

4 tests, 1593 assertions, 0 failures, 0 errors

> My environmnent information is here.

c:\>ruby -v
ruby 1.8.2 (2004-12-25) [i386-mswin32]
c:\>ver
Microsoft Windows [Version 5.2.3790]

Tom
2df1fbb4f443f3eab13d13922e542491?d=identicon&s=25 SAKURAI Masashi (Guest)
on 2006-01-15 18:12
(Received via mailing list)
Tom Harris wrote:
>
> SAKURAI Masashi wrote:
> > 1) Connecting the bridge port of the java side
>  :
> BinServer: connection established.
>  :
> > 2) Ruby network test
>  :
> 4 tests, 1593 assertions, 0 failures, 0 errors

Your reports showed that the tests of both java and ruby were working.
So I think the networking is not wrong.

> > My environment information is here.
>
> c:\>ruby -v
> ruby 1.8.2 (2004-12-25) [i386-mswin32]

OK. I could reproduce your situation, installing the ruby
[i386-mswin32] by the RubyInstaller, ruby182-15.exe. The ruby may have
the trouble around I/O and thread event.

I could run the yajb, setting {:jvm_stdout => :never} in
JBRIDGE_OPTIONS. Please try the option on your Windows.

But you can not get the stdout from the java with the yajb option.  If
you want to get the stdout, the cygwin ruby [i386-cygwin] is
alternate.
828f1d90727a1f3972e0fe55a66be56f?d=identicon&s=25 Tom Harris (tharrisx)
on 2006-01-15 22:51
SAKURAI Masashi wrote:
> I could run the yajb, setting {:jvm_stdout => :never} in
> JBRIDGE_OPTIONS. Please try the option on your Windows.

That did it! The :t for :jvm_output caused this.

I cannot expect or require that all users of my open-source project will
have cygwin when on Windows, and since the majority of my project is in
Java, I'd like it to be platform agnostic as possible. That's why I
initially wanted to use your bridge library, as it was the only one that
seemed not to rely on native compilation.

I wound up getting RJB working on my system, though it is in fact
reliant on platform-specific native code to work. I think I'll be going
back to YAJB now, though, because, as I said before, I want this
software to work on all platforms as is, without a lot of hand-holding
or forced choices on my part.

Thanks! If there is any way to fix the library so that jvm_output works
on mswin32, I think it'd be worth it. It'll certainly make debugging
easier.

Tom
5b781ccefcaa2172e93cff8545e5caf4?d=identicon&s=25 Peter Gillogley (gillogleyp)
on 2006-06-10 01:46
Tom Harris wrote:
> SAKURAI Masashi wrote:
>> I could run the yajb, setting {:jvm_stdout => :never} in
>> JBRIDGE_OPTIONS. Please try the option on your Windows.
>
> That did it! The :t for :jvm_output caused this.
>
...
>
> Tom

Tom and SAKURAI Masashi

I am keen to be able to call some commercial-off-the-shelf Java methods
from some Ruby/WATIR test scripts I have developed. I was recommended
YAJB.

I have installed yajb and I seem to be getting the same errors as Tom
did initially.
D:\ruby\bin>ruby -v
ruby 1.8.2 (2004-12-25) [i386-mswin32]
D:\ruby\bin>ver
Microsoft Windows XP [Version 5.1.2600]


D:\Downloads\yajb-0.8.1.tar\yajb-0.8.1\test>test.rb
Loaded suite D:/Downloads/yajb-0.8.1.tar/yajb-0.8.1/test/test
Started
JavaBridge: Startup communication bridge...
CLASSPATH: "$CLASSPATH";d:/ruby/lib/ruby/site_ruby/1.8/yajb/yajb.jar
java  -classpath
""$CLASSPATH";d:/ruby/lib/ruby/site_ruby/1.8/yajb/yajb.jar"
jbridge.BridgeBuilder jbridge.comm.binstream.BStream_JBServer
-remoteport:1520 -log
Level:debug  -logfile:jlog.txt
JVM: OK.
JVM: Initialized.
^C
D:\Downloads\yajb-0.8.1.tar\yajb-0.8.1\test>

If I telnet to "localhost 1520" ... I get a connection.

However the bstream test does not work.

D:\Downloads\yajb-0.8.1.tar\yajb-0.8.1\test>ruby bstream_cstest.rb
Loaded suite bstream_cstest
Started
. 32^C
D:\Downloads\yajb-0.8.1.tar\yajb-0.8.1\test>

If the problem is security settings...What exactly do I need to disable
(so that yajb will work) on my Windows firewall and McAffe Firewall.
I have looked at Windows "event viewer" + McAfee Event log  and no
entries are being created when I run the application.

I am not sure I really understand the ":t for :jvm_output " resolution
for Tom.

Peter Gillogley

http://gillogley.com.au
This topic is locked and can not be replied to.