Results 1 to 5 of 5

Thread: Jruby backed bean can't be ApplicationContextAware

  1. #1
    Join Date
    Oct 2005
    Posts
    29

    Red face 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:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:lang="http://www.springframework.org/schema/lang"
           xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd">
        <lang:jruby id="contextUtil" script-source="classpath:context_util.rb" script-interfaces="org.springframework.context.ApplicationContextAware"/>
    </beans>
    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!
    Last edited by siberian; Sep 4th, 2006 at 10:35 AM.

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    The issue looks odd - can you please submit an issue on JIRA (with some simple test case if possible)? thanks.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    Anybody know if there is a JIRA issue for this now? What's the ID?

  4. #4
    Join Date
    Jun 2005
    Posts
    4,230

  5. #5
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Fixed in the current nightly builds.

    Rob
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •