aspose file tools*
The moose likes Other Application Frameworks and the fly likes Spring - Beanshell IllegalAccessError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Spring - Beanshell IllegalAccessError" Watch "Spring - Beanshell IllegalAccessError" New topic
Author

Spring - Beanshell IllegalAccessError

Caly LeeAnn
Ranch Hand

Joined: Nov 22, 2005
Posts: 55
Hi,

I am trying the BeanShell example provided at <a href="http://www.springframework.org/docs/reference/dynamic-language.html">Chapter 24. Dynamic language support</a> - 24.3.4. BeanShell beans.

And I have an 'IllegalAccessError' when I try to use the scripted bean in my java code.

The scripted bean 'BshMessenger.bsh' is written as the following and is deployed under ${mydomain}/config.
String message = "Hello World";

String getMessage() {
return message;
}

The interface 'Messenger' is like the following.
package org.testing.scripting.beanshell;

public interface Messenger {

String getMessage();
}

The configuration in the Spring xml file is like the following:

<lang:bsh id="messageService" refresh-check-delay="2000" script-source="classpath:config/BshMessenger.bsh" script-interfaces="org.testing.scripting.beanshell.Messenger">
</lang:bsh>

<bean class="com.testing.Cube">
<property name="messenger" ref="messageService" />
</bean>


Any advices of how to solve this problem will be appreciated. Thank you.


--------------------------------------------------------------------------------------------------------------------------------

Jun-05-2007 17:31:26 WARN (CommonsLoggingOutput.java:67) - Method execution failed:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scriptedObject.messageService': Instanti
ation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public
java.lang.Object org.springframework.scripting.bsh.BshScriptFactory.getScriptedObject(org.springframework.scripting.ScriptSourc
e,java.lang.Class[]) throws java.io.IOException,org.springframework.scripting.ScriptCompilationException] threw exception; neste
d exception is java.lang.IllegalAccessError: bsh/XThis
Caused by:
org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public java.lang.Object org.springframework.scri
pting.bsh.BshScriptFactory.getScriptedObject(org.springframework.scripting.ScriptSource,java.lang.Class[]) throws java.io.IOExce
ption,org.springframework.scripting.ScriptCompilationException] threw exception; nested exception is java.lang.IllegalAccessErro
r: bsh/XThis
Caused by:
java.lang.IllegalAccessError: bsh/XThis
at org.springframework.scripting.bsh.BshScriptUtils.evaluateBshScript(Ljava.lang.String;[Ljava.lang.Class;Ljava.lang.Cla
ssLoader Ljava.lang.Object;(BshScriptUtils.java:159)
at org.springframework.scripting.bsh.BshScriptUtils.createBshObject(Ljava.lang.String;[Ljava.lang.Class;Ljava.lang.Class
Loader Ljava.lang.Object;(BshScriptUtils.java:90)
at org.springframework.scripting.bsh.BshScriptFactory.getScriptedObject(Lorg.springframework.scripting.ScriptSource;[Lja
va.lang.Class Ljava.lang.Object;(BshScriptFactory.java:145)
at jrockit.reflect.NativeMethodInvoker.invoke0(Ljava.lang.Object;ILjava.lang.Object;[Ljava.lang.Object Ljava.lang.Objec
t;(Unknown Source)
at jrockit.reflect.NativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object Ljava.lang.Object;(Unknown Source)
at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object Ljava.lang.Object;(Unknown So
urce)
at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(Lorg.springframework.beans.factory.
support.RootBeanDefinition;Ljava.lang.String;Lorg.springframework.beans.factory.BeanFactory;Ljava.lang.Object;Ljava.lang.reflect
.Method;[Ljava.lang.Object Ljava.lang.Object;(SimpleInstantiationStrategy.java:118)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(Ljava.lang.String;Lorg.sp
ringframework.beans.factory.support.RootBeanDefinition;[Ljava.lang.Object Lorg.springframework.beans.BeanWrapper;(ConstructorRe
solver.java:315)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(Ljava.lang
.String;Lorg.springframework.beans.factory.support.RootBeanDefinition;[Ljava.lang.Object Lorg.springframework.beans.BeanWrapper
;(AbstractAutowireCapableBeanFactory.java:758)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(Ljava.lang.String;Lor
g.springframework.beans.factory.support.RootBeanDefinition;[Ljava.lang.Object Lorg.springframework.beans.BeanWrapper;(AbstractA
utowireCapableBeanFactory.java:712)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(Ljava.lang.String;Lorg.spring
framework.beans.factory.support.RootBeanDefinition;[Ljava.lang.Object Ljava.lang.Object;(AbstractAutowireCapableBeanFactory.jav
a:386)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ljava.lang.String;Ljava.lang.Class;[Ljava.lang.
Object Ljava.lang.Object;(AbstractBeanFactory.java:270)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ljava.lang.String Ljava.lang.Object;(AbstractB
eanFactory.java:160)
at org.springframework.aop.target.dynamic.BeanFactoryRefreshableTargetSource.freshTarget()Ljava.lang.Object;(BeanFactory
RefreshableTargetSource.java:65)
at org.springframework.aop.target.dynamic.AbstractRefreshableTargetSource.refresh()V(AbstractRefreshableTargetSource.jav
a:95)
at org.springframework.aop.target.dynamic.AbstractRefreshableTargetSource.getTarget()Ljava.lang.Object;(AbstractRefresha
bleTargetSource.java:80)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(Ljava.lang.Object;Ljava.lang.reflect.Method;[Ljava.lang.O
bject Ljava.lang.Object;(JdkDynamicAopProxy.java:183)
at $Proxy13.toString()Ljava.lang.String;(Unknown Source)
at java.lang.String.valueOf(Ljava.lang.Object Ljava.lang.String;(Unknown Source)
at java.lang.StringBuffer.append(Ljava.lang.Object Ljava.lang.StringBuffer;(Unknown Source)
.....
Jun-05-2007 17:31:26 WARN (CommonsLoggingOutput.java:59) - --Erroring: batchId[0] message[org.springframework.beans.factory.Bea
nCreationException: Error creating bean with name 'scriptedObject.messageService': Instantiation of bean failed; nested exceptio
n is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public java.lang.Object org.springframework
.scripting.bsh.BshScriptFactory.getScriptedObject(org.springframework.scripting.ScriptSource,java.lang.Class[]) throws java.io.I
OException,org.springframework.scripting.ScriptCompilationException] threw exception; nested exception is java.lang.IllegalAcces
sError: bsh/XThis]
Caly LeeAnn
Ranch Hand

Joined: Nov 22, 2005
Posts: 55
Problem solved.
 
jQuery in Action, 2nd edition
 
subject: Spring - Beanshell IllegalAccessError