My Jruby script is as follows:
require ‘java’
Dir[“c:/yantraeclipse/yantra_server/webcontent/web-inf/lib/*.jar”].each
{ |jar| require jar;puts jar; }
require “c:/jruby-1.6.5/tejas.jar”
puts “hello done loading jars”
include_class “com.yantranet.platform.dao.AppDao”
include_class “com.yantranet.helpers.PageAndSize”
include_class “org.springframework.context.ApplicationContext”
include_class
“org.springframework.context.support.ClassPathXmlApplicationContext”
include_class
“org.springframework.context.support.FileSystemXmlApplicationContext”
def beans
[“DataSource”, “Hibernate”, “User” ].map { |c|
“file:c:/yantraeclipse/yantra_server/webcontent/WEB-INF/spring/config/#{c}.xml”
}.to_java :string
end
application_context = ClassPathXmlApplicationContext.new(beans)
app = application_context.getBean(“cleanAppDao”)
ps = PageAndSize.new(1,10)
The problem is with Java’s URLClassLoader that tries to instantiate a
SessionFactory bean which is defined thus:
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop
key=“hibernate.dialect”>org.hibernate.dialect.MySQLDialect
false
</props>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="annotatedClasses">
<list>
<value>com.yantranet.model.DeviceProperty</value>
<value>com.yantranet.model.DevicePropertyValue</value>
</list>
</property>
<!-- <property name="configLocation"
value="/WEB-INF/spring/hibernate/hbm.cfg.xml"/> -->
<property name="mappingResources">
<list>
<value>com/yantranet/model/User.hbm.xml</value>
<value>com/yantranet/model/Role.hbm.xml</value>
<value>com/yantranet/model/App.hbm.xml</value>
The exception when I run JRuby script is:
NativeException:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name ‘sessionFactory’ defined in URL
[file:c:/yantraeclipse/y
antra_server/webcontent/WEB-INF/spring/config/Hibernate.xml]: Invocation
of init
method failed; nested exception is java.lang.NoClassDefFoundError:
org/slf4j/Lo
ggerFactory
(root) at apptest.rb:41
I run the script as:
C:\jruby-1.6.5>jruby -J-cp c:\jruby-1.6.5\tejas.jar -Ic:\slf4j
apptest.rb
I am trying to provide the slf4j-api-1.6.1.jar which has the
org.slf4j.LoggerFactory in various ways. Nothing seems to work so far.
It seems java is not getting the classpath for the slf4j jar.
I would appreciate your kind help.
Thanks
Murthy