- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Description
Dhaval Powar opened SPR-10689 and commented
THIS BUG LIES IN SPRING 2.5 AND HIGHER
Dynamic language support is added to Spring by using the <lang:> namespace.
For eg. for a groovy script, the following xml should handle dynamic language support in Spring.
<lang:groovy id="refreshableMessenger" 
    script-source="classpath:org/fw/scripting/groovy/Messenger.groovy"> 
    <lang:property name="message" value="Hello World!"/> 
</lang:groovy>
How this functions under the hood is:
- 
The <lang:groovy>instantiates theLangNamespaceHandlerclass which parses the xml and identifies the type of dynamic language ie. groovy, JRuby or BSH.
- 
LangNamespaceHandlerthen calls theregisterScriptBeanDefinitionParsermethod which in turn, makes a call toregisterBeanDefinitionParserto register the bean. The call to this method instantiates aScriptBeanDefinitionParserobject which does the following:
a. Resolve the script source
b. Set up infrastructure
c. Create script factory bean definition
d. and many more other specific functionalities....
In step (b.), to setup the architecture, the LangNamespaceUtils class sets up the scriptFactoryPostProcessor object. This object handles ScriptFactory definitions, replacing each factory with the actual scripted Java object generated by it.
The bug lies in the LangNamespaceUtils class due to an invalid variable initialization.
This class contains a variable name
SCRIPT_FACTORY_POST_PROCESSOR_BEAN_NAME="org.springframework.scripting.config.ScriptFactoryPostProcessor"The value of this variable is invalid because the full qualified name of the ScriptFactoryPostProcessor class is org.springframework.scripting.support.ScriptFactoryPostProcessor.
This means that ScriptFactoryPostProcessor lies in the package org.springframework.scripting.support and NOT org.springframework.scripting.config. Due to this the ScriptFactoryPostProcessor bean does not get instantiated and the dynamic language support does not work.
However, this issue did not exist in Spring 2.0 & earlier since the <lang:grovy> xml namespace and tag were handled in a different way. Please fix the bug.
Affects: 3.1.2
Attachments:
- LangNamespaceUtils.java (2.25 kB)
- scripting.zip (34.00 kB)
Issue Links:
- Annotated Groovy controllers don't work properly [SPR-6268] #10935 Annotated Groovy controllers don't work properly
3 votes, 5 watchers