|
|
Jruby backed bean can't be ApplicationContextAware
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:
Code:
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;beans xmlns=quot;schema/beansquot; xmlns:xsi=quot;2001/XMLSchema-instancequot; xmlns:lang=quot;schema/langquot; xsi:schemaLocation=quot;
schema/beans schem...ring-beans.xsd
schema/lang schema/lang/spring-lang.xsdquot;gt; lt;lang:jruby id=quot;contextUtilquot; script-source=quot;classpath:context_util.rbquot; script-interfaces=quot;org..context.ApplicationContextAwarequot;/gt;
lt;/beansgt;
the ruby file context_util.rb
Code:
require 'java'
include_class 'org..beans.BeansException'
include_class 'org..context.ApplicationContext'
include_class 'org..context.ApplicationContextAware'
include_class 'java.util.GregorianCalendar'
class ContextUtil lt; 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..beans.BeansException'
include_class 'org..context.ApplicationContext'
include_class 'org..context.ApplicationContextAware'
include_class 'java.util.GregorianCalendar'
class ContextUtil lt; 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 quot;mainquot; org..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..context.support.FileSystemXmlA pplicationContext: display name [org..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..context.support.FileSystemXmlA pplicationContext: display name [org..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!
The issue looks odd - can you please submit an issue on JIRA (with some simple test case if possible)? thanks.
Anybody know if there is a JIRA issue for this now? What's the ID?
proj...rowse/SPR-2880
Fixed in the current nightly builds.
Rob |
|