Hi, I am tring to use jruby in spring. The basic example works and I was stuck when I tried to make it ApplicationContextAware
I followed the document and I got these:
the configuration file:
the ruby file context_util.rb
Code:
require 'java'
include_class 'org.springframework.beans.BeansException'
include_class 'org.springframework.context.ApplicationContext'
include_class 'org.springframework.context.ApplicationContextAware'
include_class 'java.util.GregorianCalendar'
class ContextUtil < ApplicationContextAware
def setApplicationContext(applicationContext)
calendar = GregorianCalendar.new
puts calendar.firstDayOfWeek
puts applicationContext
end
end
ContextUtil.new
It seems everything works. but if I add a line to the ruby code
puts applicationContext.getDisplayName
that is
Code:
require 'java'
include_class 'org.springframework.beans.BeansException'
include_class 'org.springframework.context.ApplicationContext'
include_class 'org.springframework.context.ApplicationContextAware'
include_class 'java.util.GregorianCalendar'
class ContextUtil < ApplicationContextAware
def setApplicationContext(applicationContext)
calendar = GregorianCalendar.new
puts calendar.firstDayOfWeek
puts applicationContext
puts applicationContext.getDisplayName
end
end
ContextUtil.new
I got an Exception:
Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'scriptedObject.contextUtil': Initialization of bean failed; nested exception is org.jruby.exceptions.RaiseException: undefined method `getDisplayName' for org.springframework.context.support.FileSystemXmlA pplicationContext: display name [org.springframework.context.support.FileSystemXmlA pplicationContext;hashCode=131577]; startup date [Mon Sep 04 23:24:14 CST 2006]; root of context hierarchy:Java::JavaObject
Caused by: org.jruby.exceptions.RaiseException: undefined method `getDisplayName' for org.springframework.context.support.FileSystemXmlA pplicationContext: display name [org.springframework.context.support.FileSystemXmlA pplicationContext;hashCode=131577]; startup date [Mon Sep 04 23:24:14 CST 2006]; root of context hierarchy:Java::JavaObject
basically it says FileSystemXmlApplicationContext doesn't have a methond named getDisplayName, but it does.
Any idea?
Thanks!