JRubycons,
i’m trying to call – from jruby – a java class i’ve developed. i’ve
got
the class archived in a jar file; but, every procedure i can find for
using
java code from jruby fails. i’ve included my latest attempt below. Any
help
would be greatly appreciated.
Best wishes,
–greg
pipes_controller.rb:
include Java
$CLASSPATH <<
“…/pipes_to_cal/target/classes/com/biosimilarity/magritte”
$CLASSPATH <<
“…/…/…/quant/quant/target/classes/com/biosimilarity/mcbond”
$CLASSPATH <<
“/Users/lgm/work/src/projex/bobj/quant/quant/target/classes/com/biosimilarity/mcbond”
require
‘/Users/lgm/work/src/projex/bobj/quant/quant/target/quant-1.0-SNAPSHOT’
require
‘/Users/lgm/work/src/projex/bobj/magritte/pipe-cutter/pipes_to_cal/target/pipes_to_cal-1.0-SNAPSHOT’
module Quant
include_package “com.biosimilarity.quant.mcbond”
end
module PipesToCAL
include_package “com.biosimilarity.magritte”
end
import “com.biosimilarity.magritte.PipesToCALBridge”
class PipesController < ApplicationController
todo: make preview the only thing that’s posted?
def index
@categories = Category.find(:all, :order => :name)
end
def ajax_pipe_load
end
def ajax_pipe_preview
# to grab the request
begin
reqOutputF = File.open("reqOutput.json","w+")
reqOutputF << "\n JSON string\n"
reqOutputF << params[:def]
com.biosimilarity.magritte.PipesToCALBridge.parseRequest(params[:def])
reqOutputF << "\n Done\n"
rescue Exception => msg
reqOutputF << "\n Error calling Pipes to CAL bridge \n"
reqOutputF << msg.to_s
ensure
reqOutputF.close
render(:json => '{"ok":1,
"errors":{
"modules":{},"pipe":null
},
"preview":{
},
"stats":{
"pua":{}
}
}
')
end
end
console output:
bash-3.2$ ls -al
/Users/lgm/work/src/projex/bobj/magritte/pipe-cutter/pipes_to_cal/target/
total 32
drwxr-xr-x 9 lgm lgm 306 May 28 18:00 .
drwxr-xr-x 5 lgm lgm 170 May 28 17:10 …
drwxr-xr-x 3 lgm lgm 102 May 28 17:11 classes
-rw-r–r-- 1 lgm lgm 1 May 29 04:03 classes.timestamp
drwxr-xr-x 3 lgm lgm 102 May 28 17:23 maven-archiver
-rw-r–r-- 1 lgm lgm 4578 May 29 03:19 pipes_to_cal-1.0-SNAPSHOT.jar
drwxr-xr-x 4 lgm lgm 136 May 28 17:20 surefire-reports
drwxr-xr-x 3 lgm lgm 102 May 28 17:20 test-classes
-rw-r–r-- 1 lgm lgm 1 May 28 17:23 test-classes.timestamp
bash-3.2$ script/server
=> Booting WEBrick…
JRuby limited openssl loaded. gem install jruby-openssl for full
support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2008-05-29 05:42:31] INFO WEBrick 1.3.1
[2008-05-29 05:42:31] INFO ruby 1.8.6 (2008-05-27) [java]
[2008-05-29 05:42:31] INFO WEBrick::HTTPServer#start: pid=26634
port=3000
0:0:0:0:0:0:0:1%0 - - [29/May/2008:05:42:46 PDT] “GET / HTTP/1.1” 500
2357
- -> /
response display in browser:
NameError in PipesController#index
cannot link Java class com.biosimilarity.magritte.PipesToCALBridge
RAILS_ROOT: /Users/lgm/work/src/projex/bobj/magritte/pipe-cutter/rails
Application Trace http://localhost:3000/# | Framework
Tracehttp://localhost:3000/#| Full
Trace http://localhost:3000/#
Request
Parameters:
None
Show session dump http://localhost:3000/#
flash: !map:ActionController::Flash::FlashHash {}
Response
Headers:
{“Cache-Control”=>“no-cache”,
“cookie”=>[]}
manifest of jar file:
bash-3.2$ pwd
/Users/lgm/work/src/projex/bobj/magritte/pipe-cutter/pipes_to_cal/target
bash-3.2$ jar tvf pipes_to_cal-1.0-SNAPSHOT.jar
0 Thu May 29 03:19:06 PDT 2008 META-INF/
122 Thu May 29 03:19:04 PDT 2008 META-INF/MANIFEST.MF
0 Wed May 28 17:11:26 PDT 2008 com/
0 Wed May 28 17:11:26 PDT 2008 com/biosimilarity/
0 Wed May 28 17:11:26 PDT 2008 com/biosimilarity/magritte/
1097 Wed May 28 17:11:26 PDT 2008
com/biosimilarity/magritte/App$.class
702 Wed May 28 17:11:26 PDT 2008 com/biosimilarity/magritte/App.class
1045 Thu May 29 03:12:52 PDT 2008
com/biosimilarity/magritte/PipesToCALBridge.class
0 Thu May 29 03:19:06 PDT 2008 META-INF/maven/
0 Thu May 29 03:19:06 PDT 2008
META-INF/maven/com.biosimilarity.magritte/
0 Thu May 29 03:19:06 PDT 2008
META-INF/maven/com.biosimilarity.magritte/pipes_to_cal/
2838 Wed May 28 17:07:34 PDT 2008
META-INF/maven/com.biosimilarity.magritte/pipes_to_cal/pom.xml
130 Wed May 28 17:23:42 PDT 2008
META-INF/maven/com.biosimilarity.magritte/pipes_to_cal/pom.properties
bash-3.2$
L.G. Meredith
Managing Partner
Biosimilarity LLC
806 55th St NE
Seattle, WA 98105
+1 206.650.3740