Forum: JRuby calling ejb 1.1(WAS7) from a cmd line client

Posted by Jayabalan A. (jayabalan_a)
on 2012-11-16 12:03
Hi,

ejb1.1 service is deployed on WAS7.

jruby cmd line client is on jre7 and referencing webshpere components
jar and the ejb jar on classpath.

exception on context#lookup:
#<NativeException: javax.naming.NamingException: Failed to initialize
the ORB>
["com/ibm/ws/naming/util/Helpers.java:365:in `getOrb'",

unable to understand the exception.

<code>
require 'java'

java_import 'java.util.Properties'
java_import 'javax.naming.InitialContext'
java_import 'javax.naming.Context'

require 'D:\java_ext\ibm\1.6\com.ibm.ws.admin.client_7.0.0.jar'
require 'D:\java_ext\ibm\1.6\ibmorb.jar'

require 'D:\my\ejb.jar'

require 'pp'

class EjbFactory
  def self.create(jndiBeanName)

    prop=Properties.new
    prop.put(Context::INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory")
    prop.put(Context::PROVIDER_URL, "IIOP://server:2811/")

    begin
      context = InitialContext.new(prop)
      context.lookup(jndiBeanName)
    rescue Exception => e
      pp e
      pp e.backtrace
    end
  end
end

EjbFactory.create("ctx/my/ejb/EjbClass")
</code>
Posted by Bruce Adams (Guest)
on 2012-11-16 12:30
(Received via mailing list)
I don't think you can use the IBM Corba client that way (but I may be
out of date). My memory of the IBM Corba stuff is that it is fairly
deeply entangled with their Java.

Can you try running JRuby on IBM's Java? (You mention jre7, but then
refer to IBM Java 1.6 jar files, so I'm assuming you are not running on
the IBM's Java.)

Also, note that older JRuby releases have some quirks running on IBM's
Java on Linux: frequent segmentation faults during JVM shutdown. This is
fixed in JRuby 1.7.0 and I think also in JRuby 1.6.8.

- Bruce
Posted by Jayabalan A. (jayabalan_a)
on 2012-11-22 08:48
hi Bruce,

Thanks for the reply.

We have used the ibm#was components from a sun#java (java code)client 
earlier, it works mostly, as you said some quirks were observed, but 
works mostly.

--JB
Posted by Jayabalan A. (jayabalan_a)
on 2012-11-23 08:58
Hi,

[UPDATE]

I got it wot work (partially though)

the jars were not in class path and had to instruct jvm to load the 
correct ORB impl.

[code]
$CLASSPATH  << 'D:\java_ext\ibm\1.6\ibmorb.jar'
$CLASSPATH  << 'D:\java_ext\ibm\1.6\com.ibm.ws.admin.client_7.0.0.jar'
$CLASSPATH  << 'D:\java_ext\ibm\1.6\ibmcfw.jar'
[/code]

[cmdline]
-J-Dorg.omg.CORBA.ORBClass=com.ibm.CORBA.iiop.ORB
[/cmdline]

However i'm stuck at creating an ejb.

[code]
objref = lookup("my/EJB")

myEjbHome = PortableRemoteObject.narrow(objref, MyEjbHome.class)
# fails with
# NativeException: java.lang.ClassCastException: Class 
org.jruby.RubyModule is not a valid remote interface

ejb = myEjbHome.create()
[/code]

Thanks.
--JB
Posted by Jayabalan A. (jayabalan_a)
on 2012-11-23 09:48
[UPDATE]

correct call is
[code]
mbUserHome = PortableRemoteObject.narrow(connobj, MyEjbHome.java_class)
[/code]

but nil is returned, java returns the correct object.
Posted by Jayabalan A. (jayabalan_a)
on 2012-11-23 10:21
[UPDATE]

sorry guys, missed out using the stubs' jars in CLASSPATH.
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.