Calling ejb 1.1(WAS7) from a cmd line client

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.

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”)

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

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

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.

$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'

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

However i’m stuck at creating an ejb.

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()

Thanks.
–JB

[UPDATE]

correct call is

mbUserHome = PortableRemoteObject.narrow(connobj, MyEjbHome.java_class)

but nil is returned, java returns the correct object.

[UPDATE]

sorry guys, missed out using the stubs’ jars in CLASSPATH.