I recently upgraded to Spring 3 and JRuby1.4. After doing so, we began getting the following exception. Everything appears to be working correctly, we are just getting an exception in the console. I contacted the JRuby mailing list and Mr. Nutter believed that he has tracked the problem down to spring JRubyScriptUtils. The entire mailing list thread is here: http://markmail.org/search/list:org....state:results;

I was hoping someone here could check my spring code to make sure I'm not doing anything wrong here before I submit any kind of bug.

xml:

<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...-beans-3.0.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd">


<lang:jruby id="rubyLabeler"
script-interfaces="com.mycompany.Labeler"
script-source="file:${fileName}" />


</beans>


java code:
private Labeler getLabeler(){
Resource resource;
try {
resource = new FileSystemResource(contextFile);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
return null;
}

XmlBeanFactory factory = new XmlBeanFactory(resource);

String path = getRubyFilePath();

PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
Properties props = new Properties();
props.put("fileName", localPath);
cfg.setProperties(props);

cfg.postProcessBeanFactory(factory);

ScriptFactoryPostProcessor proc = new ScriptFactoryPostProcessor();

proc.setBeanFactory(factory);
factory.addBeanPostProcessor(proc);

return factory.getBean(BEAN_NAME); //where error is thrown
}

Ruby File:

require 'java'

java_import "com.myCompany.DisplayTypes"

class RubyLabeler

def initialize
@a1 = getDisplayType("A1")
@a2 = getDisplayType("A2")
end

def getDisplayType(id)
DisplayTypes.find(id).label
end

def labelSubject(subject)
subject = subject.strip;
labeledSubject = "(";
labeledSubject << @a1;
labeledSubject << "--";
labeledSubject << @a2;
labeledSubject << ") ";
end


def labelBody(body)
labeledBody = "";
labeledBody << @a2;
end

end

RubyLabeler.new


Error:

warning: could not compile: because of: "Illegal class name "" in class file "
java.lang.ClassFormatError: Illegal class name "" in class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java :621)
at org.jruby.util.JRubyClassLoader.defineClass(JRubyC lassLoader.java:39)
at org.jruby.compiler.impl.StandardASMCompiler.loadCl ass(StandardASMCompiler.java:191)
at org.jruby.Ruby.tryCompile(Ruby.java:611)
at org.jruby.Ruby.runNormally(Ruby.java:556)
at org.jruby.Ruby.runNormally(Ruby.java:540)
at org.springframework.scripting.jruby.JRubyScriptUti ls.createJRubyObject(JRubyScriptUtils.java:83)
at org.springframework.scripting.jruby.JRubyScriptFac tory.getScriptedObject(JRubyScriptFactory.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:146)
at org.springframework.beans.factory.support.Construc torResolver.instantiateUsingFactoryMethod(Construc torResolver.java:540)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateUsingFactory Method(AbstractAutowireCapableBeanFactory.java:964 )
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:870)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:479)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 90)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:287 )
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:189)
at org.springframework.scripting.support.ScriptFactor yPostProcessor.postProcessBeforeInstantiation(Scri ptFactoryPostProcessor.java:313)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyBeanPostProcessors BeforeInstantiation(AbstractAutowireCapableBeanFac tory.java:839)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.resolveBeforeInstantiat ion(AbstractAutowireCapableBeanFactory.java:811)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 90)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:287 )
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:189)
at com.myCompany.LabelerFactory.getLabeler(LabelerFac tory.java:45)
at com.myCompany.LabelledEmail.<init>(LabelledEmail.j ava:10)
at com.ensco.myCompanyLabelledEmailTest.setUp(Labelle dEmailTest.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runRefle ctiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallabl e.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExpl osively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.e valuate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.ev aluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner. java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRu nner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentR unner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRu nner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRu nner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.ja va:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)